当前位置: 首页>>代码示例>>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;未经允许,请勿转载。