當前位置: 首頁>>代碼示例>>Java>>正文


Java Resource.setTargetPath方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:wisdom-framework,項目名稱:wisdom,代碼行數:21,代碼來源:ResourceCopy.java

示例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;
}
 
開發者ID:Microsoft,項目名稱:azure-maven-plugins,代碼行數:11,代碼來源:DeployMojoTest.java

示例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);
    }
}
 
開發者ID:Microsoft,項目名稱:azure-maven-plugins,代碼行數:45,代碼來源:Utils.java

示例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);
}
 
開發者ID:Microsoft,項目名稱:azure-maven-plugins,代碼行數:15,代碼來源:UtilsTest.java

示例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);
}
 
開發者ID:Microsoft,項目名稱:azure-maven-plugins,代碼行數:9,代碼來源:PackageMojo.java

示例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);
    }
}
 
開發者ID:Distelli,項目名稱:graphql-apigen,代碼行數:36,代碼來源:ApiGenMojo.java

示例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);
	}
}
 
開發者ID:to2mbn,項目名稱:LoliXL,代碼行數:35,代碼來源:GenerateDescriptionMojo.java

示例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;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:10,代碼來源:MavenModelUtil.java

示例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;
}
 
開發者ID:torquebox,項目名稱:jruby9-maven-plugins,代碼行數:16,代碼來源:WarMojo.java

示例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);
}
 
開發者ID:Guidewire,項目名稱:ijplugin-maven-plugin,代碼行數:12,代碼來源:ManifestMojo.java

示例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" ) );
        }
    }
}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:14,代碼來源:ModelMerger.java

示例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 );
}
 
開發者ID:dashie,項目名稱:m2e-plugins,代碼行數:14,代碼來源:MavenProjectResourcesStub.java

示例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 );
}
 
開發者ID:dashie,項目名稱:m2e-plugins,代碼行數:14,代碼來源:MavenProjectResourcesStub.java

示例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);
        }
    }
}
 
開發者ID:wisdom-framework,項目名稱:wisdom,代碼行數:50,代碼來源:ResourceCopy.java

示例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();
}
 
開發者ID:torquebox,項目名稱:jruby9-maven-plugins,代碼行數:55,代碼來源:WarMojo.java


注:本文中的org.apache.maven.model.Resource.setTargetPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。