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


Java Resource.setDirectory方法代碼示例

本文整理匯總了Java中org.apache.maven.model.Resource.setDirectory方法的典型用法代碼示例。如果您正苦於以下問題:Java Resource.setDirectory方法的具體用法?Java Resource.setDirectory怎麽用?Java Resource.setDirectory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.maven.model.Resource的用法示例。


在下文中一共展示了Resource.setDirectory方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    try {

        final Resource resource = new Resource();
        resource.setDirectory(outputDir.getCanonicalPath());
        project.addResource(resource);

        final Set<File> generated = new HashSet<>();

        final ReadApiClientData reader = new ReadApiClientData();
        final List<ModelData<?>> modelList = reader.readDataFromFile("io/syndesis/dao/deployment.json");
        for (final ModelData<?> model : modelList) {
            if (model.getKind() == Kind.Connector) {
                final Connector connector = (Connector) model.getData();

                for (final ConnectorAction action : connector.getActions()) {
                    process(generated, connector, action, action.getInputDataShape());
                    process(generated, connector, action, action.getOutputDataShape());
                }
            }
        }
    } catch (final IOException e) {
        throw new MojoFailureException(e.getMessage(), e);
    }
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:27,代碼來源:GenerateMapperInspectionsMojo.java

示例2: install

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
@Override
public boolean install() {
  if (!this.isInstalled()) {
    getResourceDirectories().forEach(DirectoryResource::mkdirs);
  }

  // Update Maven model - main resource only
  MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
  Model pom = maven.getModel();
  Resource main = new Resource();
  main.setDirectory("${project.basedir}/src/main/" + name);
  pom.getBuild().getResources().add(main);

  maven.setModel(pom);

  return true;
}
 
開發者ID:cescoffier,項目名稱:vertx-forge-addon,代碼行數:18,代碼來源:CustomResourceFacet.java

示例3: execute

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
/**
 * Triggers thee execution of SJS compilation.
 *
 * @throws MojoExecutionException
 *     whenever an unexpected error occurs when executing mojo.
 */
@Override
public void execute() throws MojoExecutionException {
  if (isChangeDetected()) {
    try {
      runSjsCompilation();
    } catch (IOException | DependencyResolutionRequiredException | ScriptException | ResourceException ex) {
      throw new MojoExecutionException(
          "An unexpected exception occurred when running SJS compilation.", ex);
    }
  } else {
    getLog().info("No change detected. Skipping generation.");
  }
  Resource outputResource = new Resource();
  outputResource.setDirectory(outputDir.getPath());
  project.addResource(outputResource);
}
 
開發者ID:jspresso,項目名稱:jspresso-ce,代碼行數:23,代碼來源:SjsMojo.java

示例4: execute

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
/**
 * Main plugin execution
 */
public void execute()
{
    for ( Resource resource : resources )
    {
        // Check for relative paths in the resource configuration.
        // http://maven.apache.org/plugin-developers/common-bugs.html#Resolving_Relative_Paths
        File resourceDir = new File( resource.getDirectory() );
        if ( !resourceDir.isAbsolute() )
        {
            resourceDir = new File( project.getBasedir(), resource.getDirectory() );
            resource.setDirectory( resourceDir.getAbsolutePath() );
        }

        addResource( resource );
    }
}
 
開發者ID:mojohaus,項目名稱:build-helper-maven-plugin,代碼行數:20,代碼來源:AbstractAddResourceMojo.java

示例5: setupMavenPaths

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
/**
 * Updates XJC's compilePath ans resources and update hyperjaxb2's
 * resources, that is, *.hbm.xml files and hibernate.config.xml file.
 * 
 * @param xjcOpts
 * @throws MojoExecutionException
 */
protected void setupMavenPaths() {
	super.setupMavenPaths();

	final Resource resource = new Resource();
	resource.setDirectory(getGenerateDirectory().getPath());
	for (String resourceInclude : resourceIncludes) {
		resource.addInclude(resourceInclude);
	}
	getProject().addResource(resource);

	if (this.roundtripTestClassName != null) {
		getProject().addTestCompileSourceRoot(
				getGenerateDirectory().getPath());
	}
}
 
開發者ID:highsource,項目名稱:hyperjaxb3,代碼行數:23,代碼來源:Hyperjaxb3Mojo.java

示例6: getResources

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
Resource[] getResources() throws MojoExecutionException {
    final Resource resourceNonGenerated = new Resource();
    resourceNonGenerated.setDirectory(getTopDirectory().getPath());
    try {
        addNonPartialsToResources(getTopDirectory(),resourceNonGenerated);
    } catch (CodeGenException e) {
        throw new MojoExecutionException("Couldn't add non partial specifications to resources");
    }
    if (resourceNonGenerated.getIncludes().isEmpty()) {
        resourceNonGenerated.addExclude("**/*");
    }
    Resource resourceGenerated = new Resource();
    final File specificationOutputDir = getSpecificationOutput();
    resourceGenerated.setDirectory(specificationOutputDir.getPath());
    resourceGenerated.addInclude("**/*.json");
    final Resource[] resources = {resourceNonGenerated,resourceGenerated};
    return resources;

}
 
開發者ID:indeedeng,項目名稱:proctor,代碼行數:20,代碼來源:AbstractProctorMojo.java

示例7: 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

示例8: testMojoHandlingSchemaInvalidBpmn

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
@Test
public void testMojoHandlingSchemaInvalidBpmn()
		throws XPathExpressionException, SAXException, IOException,
		MojoExecutionException {
	Resource res = new Resource();
	res.setDirectory("src/test/invalid-resources");
	mojo.resources.add(res);
	mojo.application = "Yaoqiang BPMN Editor 2.2.6";
	mojo.execute();

	assertTrue(overview.exists());
	Document document = docBuilder.parse(overview);

	XPathExpression xpath = createXpathExpression("//div[@class=\"test\" and @testcase=\"A.1.0\"  and contains(@tool, \"Yaoqiang\")]");
	NodeList nodes = (NodeList) xpath.evaluate(document,
			XPathConstants.NODESET);

	Node invalidNode = nodes.item(0);

	// There should be 2 findings: an invalid element and an invalid
	// attribute
	assertEquals("2",
			invalidNode.getAttributes().getNamedItem("data-xsd-finding")
					.getNodeValue());
}
 
開發者ID:bpmn-miwg,項目名稱:bpmn-miwg-tools,代碼行數:26,代碼來源:ModelInterchangeMojoTest.java

示例9: 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

示例10: 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

示例11: handleWebResources

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
/**
 * Handles the web resources.
 *
 * @param context the packaging context
 * @throws MojoExecutionException if a resource could not be copied
 */
protected void handleWebResources( WarPackagingContext context )
    throws MojoExecutionException
{
    for ( Resource resource : webResources )
    {

        // MWAR-246
        if ( resource.getDirectory() == null )
        {
            throw new MojoExecutionException( "The <directory> tag is missing from the <resource> tag." );
        }

        if ( !( new File( resource.getDirectory() ) ).isAbsolute() )
        {
            resource.setDirectory( context.getProject().getBasedir() + File.separator + resource.getDirectory() );
        }

        // Make sure that the resource directory is not the same as the webappDirectory
        if ( !resource.getDirectory().equals( context.getWebappDirectory().getPath() ) )
        {

            try
            {
                copyResources( context, resource );
            }
            catch ( IOException e )
            {
                throw new MojoExecutionException( "Could not copy resource [" + resource.getDirectory() + "]", e );
            }
        }
    }
}
 
開發者ID:zhegexiaohuozi,項目名稱:maven-seimicrawler-plugin,代碼行數:39,代碼來源:WarProjectPackagingTask.java

示例12: createGeneratedDir

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
private File createGeneratedDir(File buildDir) {
    File generatedDir = new File(buildDir, "generated-resources");
    Resource resource = new Resource();
    resource.setDirectory(generatedDir.getPath());
    project.addResource(resource);
    return generatedDir;
}
 
開發者ID:apache,項目名稱:karaf-boot,代碼行數:8,代碼來源:GenerateMojo.java

示例13: addingCompileSource

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
private void addingCompileSource()
{
    String generatedSourcePath = getGeneratedResourceFolder();
    File generatedSourcesDir = new File(generatedSourcePath);
    getLog().info("Adding " + generatedSourcePath + " to compile source.");
    project.addCompileSourceRoot(generatedSourcesDir.getAbsolutePath());
    Resource resource = new Resource();
    resource.setDirectory(generatedSourcesDir.getAbsolutePath());
    resource.setFiltering(false);
    project.addResource(resource);
    buildContext.refresh(generatedSourcesDir);
}
 
開發者ID:mytaxi,項目名稱:phrase-maven-plugin,代碼行數:13,代碼來源:PhraseAppMojo.java

示例14: 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

示例15: 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


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