本文整理汇总了Java中org.apache.maven.model.Resource.setIncludes方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.setIncludes方法的具体用法?Java Resource.setIncludes怎么用?Java Resource.setIncludes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.model.Resource
的用法示例。
在下文中一共展示了Resource.setIncludes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResources
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
protected List<Resource> getResources() {
final Resource resource = new Resource();
resource.setDirectory(getBuildDirectoryAbsolutePath());
resource.setTargetPath("/");
resource.setFiltering(false);
resource.setIncludes(Arrays.asList("*.jar"));
return Arrays.asList(resource);
}
示例2: execute
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
@Override
public void execute() {
try {
sourceDirectory = makeAbsolute(sourceDirectory);
outputDirectory = makeAbsolute(outputDirectory);
if ( ! sourceDirectory.exists() ) return;
getLog().debug("Running ApiGen\n\tsourceDirectory=" + sourceDirectory +
"\n\toutputDirectory=" + outputDirectory);
ClassLoader cp = getCompileClassLoader();
ApiGen apiGen = new ApiGen.Builder()
.withOutputDirectory(outputDirectory.toPath())
.withGuiceModuleName(guiceModuleName)
.withDefaultPackageName(defaultPackageName)
.build();
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(cp);
for ( org.springframework.core.io.Resource resource : resolver.getResources("classpath*:graphql-apigen-schema/*.graphql{,s}") ) {
URL url = resource.getURL();
getLog().debug("Processing "+url);
apiGen.addForReference(url);
}
findGraphql(sourceDirectory, apiGen::addForGeneration);
apiGen.generate();
Resource schemaResource = new Resource();
schemaResource.setTargetPath("graphql-apigen-schema");
schemaResource.setFiltering(false);
schemaResource.setIncludes(Arrays.asList("*.graphqls","*.graphql"));
schemaResource.setDirectory(sourceDirectory.toString());
project.addResource(schemaResource);
project.addCompileSourceRoot(outputDirectory.getAbsolutePath());
} catch (Exception e) {
String msg = e.getMessage();
if ( null == msg ) msg = e.getClass().getName();
getLog().error(msg + " when trying to build sources from graphql.", e);
}
}
示例3: execute
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void execute() throws MojoExecutionException {
getLog().info("Writing plugin description file to " + outputDescriptionFile);
try {
PluginDescription description = new PluginDescription(new MavenArtifact(project.getArtifact()),
((Set<Artifact>) project.getArtifacts()).stream()
.filter(artifact -> Artifact.SCOPE_COMPILE.equals(artifact.getScope()))
.filter(artifact -> !artifact.isOptional())
.filter(artifact -> excludes == null || !excludes.contains(artifact.getGroupId() + ":" + artifact.getArtifactId()))
.map(MavenArtifact::new)
.collect(toSet()));
File outputDescriptionFileParent = outputDescriptionFile.getParentFile();
if (!outputDescriptionFileParent.exists()) {
outputDescriptionFileParent.mkdirs();
}
try (Writer writer = new OutputStreamWriter(new BufferedOutputStream(buildContext.newFileOutputStream(outputDescriptionFile)), "UTF-8")) {
gson.toJson(description, writer);
}
Resource resource = new Resource();
resource.setDirectory(outputDescriptionFile.getParentFile().getAbsolutePath());
resource.setIncludes(Arrays.asList(outputDescriptionFile.getName()));
resource.setTargetPath(outputTarget);
project.addResource(resource);
File descriptionArtifact = new File(artifactOutputDir, project.getArtifactId() + "-" + project.getVersion() + "-lolixl-plugin.json");
FileUtils.copyFile(outputDescriptionFile, descriptionArtifact);
projectHelper.attachArtifact(project, "json", "lolixl-plugin", descriptionArtifact);
} catch (IOException e) {
throw new MojoExecutionException("Couldn't generate plugin description file", e);
}
}
示例4: convertToMavenResource
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private static Resource convertToMavenResource(MavenResource mavenResource, File projectDir) {
Resource resource = new Resource();
resource.setDirectory(relativize(projectDir, mavenResource.getDirectory()));
resource.setFiltering(mavenResource.isFiltered());
resource.setTargetPath(mavenResource.getTargetPath());
resource.setIncludes(mavenResource.getIncludes());
resource.setExcludes(mavenResource.getExcludes());
return resource;
}
示例5: execute
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info("Adding plugin manifest at " + manifestLocation + " as resource");
Resource resource = new Resource();
resource.setDirectory(manifestLocation.getParent());
resource.setIncludes(Collections.singletonList(manifestLocation.getName()));
resource.setTargetPath("META-INF");
resource.setFiltering(true);
project.addResource(resource);
}
示例6: addResource
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
public void addResource( MavenProject project, String resourceDirectory, List<String> includes, List<String> excludes )
{
Resource resource = new Resource();
resource.setDirectory( resourceDirectory );
resource.setIncludes( includes );
resource.setExcludes( excludes );
project.addResource( resource );
}
示例7: addTestResource
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
public void addTestResource( MavenProject project, String resourceDirectory, List<String> includes, List<String> excludes )
{
Resource resource = new Resource();
resource.setDirectory( resourceDirectory );
resource.setIncludes( includes );
resource.setExcludes( excludes );
project.addTestResource( resource );
}
示例8: copyFileToDir
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
/**
* Copies the file <tt>file</tt> to the directory <tt>dir</tt>, keeping the structure relative to <tt>rel</tt>.
*
* @param file the file to copy
* @param rel the base 'relative'
* @param dir the directory
* @param mojo the mojo
* @param filtering the filtering component
* @param additionalProperties additional properties
* @throws IOException if the file cannot be copied.
*/
public static void copyFileToDir(File file, File rel, File dir, AbstractWisdomMojo mojo, MavenResourcesFiltering
filtering, Properties additionalProperties) throws
IOException {
if (filtering == null) {
File out = computeRelativeFile(file, rel, dir);
if (out.getParentFile() != null) {
mojo.getLog().debug("Creating " + out.getParentFile() + " : " + out.getParentFile().mkdirs());
FileUtils.copyFileToDirectory(file, out.getParentFile());
} else {
throw new IOException("Cannot copy file - parent directory not accessible for "
+ file.getAbsolutePath());
}
} else {
Resource resource = new Resource();
resource.setDirectory(rel.getAbsolutePath());
resource.setFiltering(true);
resource.setTargetPath(dir.getAbsolutePath());
resource.setIncludes(ImmutableList.of("**/" + file.getName()));
List<String> excludedExtensions = new ArrayList<>();
excludedExtensions.addAll(filtering.getDefaultNonFilteredFileExtensions());
excludedExtensions.addAll(NON_FILTERED_EXTENSIONS);
MavenResourcesExecution exec = new MavenResourcesExecution(ImmutableList.of(resource), dir, mojo.project,
"UTF-8", Collections.<String>emptyList(), excludedExtensions, mojo.session);
if (additionalProperties != null) {
exec.setAdditionalProperties(additionalProperties);
}
exec.setEscapeString("\\");
try {
filtering.filterResources(exec);
} catch (MavenFilteringException e) {
throw new IOException("Error while copying resources", e);
}
}
}
示例9: filterResources
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
protected void filterResources( File outputDirectory )
throws MojoExecutionException
{
Resource res = new Resource();
// TODO: Check how to prevent hard coding here?
res.setDirectory( getSourceDirectory().getAbsolutePath() );
res.setFiltering( true );
// TODO: Check if it makes sense to make this list configurable?
res.setIncludes( Collections.singletonList( "**/*" ) );
List<String> filtersFile = new ArrayList<String>();
MavenResourcesExecution execution =
new MavenResourcesExecution( Collections.singletonList( res ), outputDirectory, getMavenProject(),
getEncoding(), filtersFile, getNonFilteredFileExtensions(),
getMavenSession() );
execution.setEscapeString( getEscapeString() );
execution.setSupportMultiLineFiltering( isSupportMultiLineFiltering() );
execution.setIncludeEmptyDirs( isIncludeEmptyDirs() );
execution.setEscapeWindowsPaths( isEscapeWindowsPaths() );
execution.setFilterFilenames( isFileNameFiltering() );
//// execution.setFilters( filters );
//
// // TODO: Check if we need a parameter?
execution.setOverwrite( true );
execution.setDelimiters( getDelimiters(), isUseDefaultDelimiters() );
execution.setEncoding( getEncoding() );
//
// execution.setUseDefaultFilterWrappers( true );
if ( getNonFilteredFileExtensions() != null )
{
execution.setNonFilteredFileExtensions( getNonFilteredFileExtensions() );
}
try
{
mavenResourcesFiltering.filterResources( execution );
}
catch ( MavenFilteringException e )
{
getLog().error( "Failure during filtering.", e );
throw new MojoExecutionException( "Failure during filtering", e );
}
}