本文整理汇总了Java中org.apache.maven.model.Resource.setTargetPath方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.setTargetPath方法的具体用法?Java Resource.setTargetPath怎么用?Java Resource.setTargetPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.model.Resource
的用法示例。
在下文中一共展示了Resource.setTargetPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filterAndCopy
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private static void filterAndCopy(AbstractWisdomMojo mojo, MavenResourcesFiltering filtering, File in, File out) throws IOException {
Resource resource = new Resource();
resource.setDirectory(in.getAbsolutePath());
resource.setFiltering(true);
resource.setTargetPath(out.getAbsolutePath());
List<String> excludedExtensions = new ArrayList<>();
excludedExtensions.addAll(filtering.getDefaultNonFilteredFileExtensions());
excludedExtensions.addAll(NON_FILTERED_EXTENSIONS);
MavenResourcesExecution exec = new MavenResourcesExecution(ImmutableList.of(resource), out, mojo.project,
"UTF-8", Collections.<String>emptyList(), excludedExtensions, mojo.session);
exec.setEscapeString("\\");
try {
filtering.filterResources(exec);
} catch (MavenFilteringException e) {
throw new IOException("Error while copying resources", e);
}
}
示例2: getResourceList
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private List<Resource> getResourceList() {
final Resource resource = new Resource();
resource.setDirectory("/");
resource.setTargetPath("/");
final List<Resource> resources = new ArrayList<>();
resources.add(resource);
return resources;
}
示例3: copyResources
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
/**
* Copy resources to target directory using Maven resource filtering so that we don't have to handle
* recursive directory listing and pattern matching.
* In order to disable filtering, the "filtering" property is force set to False.
*
* @param project
* @param session
* @param filtering
* @param resources
* @param targetDirectory
* @throws IOException
*/
public static void copyResources(final MavenProject project, final MavenSession session,
final MavenResourcesFiltering filtering, final List<Resource> resources,
final String targetDirectory) throws IOException {
for (final Resource resource : resources) {
resource.setTargetPath(Paths.get(targetDirectory, resource.getTargetPath()).toString());
resource.setFiltering(false);
}
final MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution(
resources,
new File(targetDirectory),
project,
"UTF-8",
null,
Collections.EMPTY_LIST,
session
);
// Configure executor
mavenResourcesExecution.setEscapeWindowsPaths(true);
mavenResourcesExecution.setInjectProjectBuildFilters(false);
mavenResourcesExecution.setOverwrite(true);
mavenResourcesExecution.setIncludeEmptyDirs(false);
mavenResourcesExecution.setSupportMultiLineFiltering(false);
// Filter resources
try {
filtering.filterResources(mavenResourcesExecution);
} catch (MavenFilteringException ex) {
throw new IOException("Failed to copy resources", ex);
}
}
示例4: copyResources
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
@Test
public void copyResources() throws Exception {
final MavenResourcesFiltering filtering = mock(MavenResourcesFiltering.class);
final Resource resource = new Resource();
resource.setTargetPath("/");
Utils.copyResources(mock(MavenProject.class),
mock(MavenSession.class),
filtering,
Arrays.asList(new Resource[] {resource}),
"target");
verify(filtering, times(1)).filterResources(any(MavenResourcesExecution.class));
verifyNoMoreInteractions(filtering);
}
示例5: 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);
}
示例6: 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);
}
}
示例7: 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);
}
}
示例8: 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;
}
示例9: createResource
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
protected Resource createResource(String source, String target) {
Resource resource = new Resource();
resource.setDirectory(source);
resource.addExclude("jetty*.css");
resource.addExclude("plugin.properties");
resource.addExclude("about.html");
resource.addExclude("about_files/**");
resource.addExclude("META-INF/ECLIPSE*");
resource.addExclude("META-INF/eclipse*");
resource.addExclude("META-INF/maven/**");
resource.addExclude("WEB-INF/**");
resource.addExclude("**/web.xml");
if (target != null) resource.setTargetPath(target);
return resource;
}
示例10: 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);
}
示例11: mergeResource_TargetPath
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
protected void mergeResource_TargetPath( Resource target, Resource source, boolean sourceDominant,
Map<Object, Object> context )
{
String src = source.getTargetPath();
if ( src != null )
{
if ( sourceDominant || target.getTargetPath() == null )
{
target.setTargetPath( src );
target.setLocation( "targetPath", source.getLocation( "targetPath" ) );
}
}
}
示例12: setupResources
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private void setupResources()
{
Resource resource = new Resource();
// see MavenProjectBasicStub for details
// of getBasedir
// setup default resources
resource.setDirectory( getBasedir().getPath() + "/src/main/resources" );
resource.setFiltering( false );
resource.setTargetPath( null );
build.addResource( resource );
}
示例13: setupTestResources
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private void setupTestResources()
{
Resource resource = new Resource();
// see MavenProjectBasicStub for details
// of getBasedir
// setup default test resources
resource.setDirectory( getBasedir().getPath() + "/src/test/resources" );
resource.setFiltering( false );
resource.setTargetPath( null );
build.addTestResource( resource );
}
示例14: 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);
}
}
}
示例15: execute
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
ArtifactHelper helper = new ArtifactHelper(unzip, system,
localRepository, getProject().getRemoteArtifactRepositories());
File jrubyWar = new File(getProject().getBuild().getDirectory(), "jrubyWar");
File jrubyWarLib = new File(jrubyWar, "lib");
File webXml = new File(jrubyWar, "web.xml");
File initRb = new File(jrubyWar, "init.rb");
File jrubyWarClasses = new File(jrubyWar, "classes");
switch(type) {
case jetty:
helper.unzip(jrubyWarClasses, "org.eclipse.jetty", "jetty-server", jettyVersion);
helper.unzip(jrubyWarClasses, "org.eclipse.jetty", "jetty-webapp", jettyVersion);
if (mainClass == null ) mainClass = "org.jruby.mains.JettyRunMain";
case runnable:
helper.unzip(jrubyWarClasses, "org.jruby.mains", "jruby-mains", jrubyMainsVersion);
if (mainClass == null ) mainClass = "org.jruby.mains.WarMain";
MavenArchiveConfiguration archive = getArchive();
archive.getManifest().setMainClass(mainClass);
createAndAddWebResource(jrubyWarClasses, "");
createAndAddWebResource(new File(getProject().getBuild().getOutputDirectory(), "bin"), "bin");
case archive:
default:
}
helper.copy(jrubyWarLib, "org.jruby", "jruby-complete", jrubyVersion);
helper.copy(jrubyWarLib, "org.jruby.rack", "jruby-rack", jrubyRackVersion,
"org.jruby:jruby-complete"); //exclude jruby-complete
// we bundle jar dependencies the ruby way
getProject().getArtifacts().clear();
createAndAddWebResource(jrubyWarLib, "WEB-INF/lib");
copyPluginResource(initRb);
Resource resource = new Resource();
resource.setDirectory(initRb.getParent());
resource.addInclude(initRb.getName());
resource.setTargetPath("META-INF");
addWebResource(resource);
if (defaultResource) {
addCommonRackApplicationResources();
}
if (getWebXml() == null) {
findWebXmlOrUseBuiltin(webXml);
}
super.execute();
}