Java Code Examples for org.apache.maven.model.Resource#addInclude()
The following examples show how to use
org.apache.maven.model.Resource#addInclude() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Hyperjaxb3Mojo.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
/** * 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()); } }
Example 2
Source File: AbstractProctorMojo.java From proctor with Apache License 2.0 | 6 votes |
private void addNonPartialsToResources(final File dir, final Resource resource) throws CodeGenException { if (dir.equals(null)) { throw new CodeGenException("Could not read from directory " + dir.getPath()); } final File[] files = dir.listFiles(); if (files == null) { return; } for (final File entry : files) { try { if (entry.isDirectory()) { addNonPartialsToResources(entry, resource); } else if (entry.getName().endsWith(".json") && ProctorUtils.readJsonFromFile(entry).has("tests")) { resource.addInclude(entry.getPath().substring(getTopDirectory().getPath().length() + 1)); } } catch (final IOException e) { throw new CodeGenException("Could not read from file " + entry.getName(),e); } } }
Example 3
Source File: AbstractProctorMojo.java From proctor with Apache License 2.0 | 6 votes |
Resource[] getResources() throws MojoExecutionException { final Resource resourceNonGenerated = new Resource(); resourceNonGenerated.setDirectory(getTopDirectory().getPath()); try { addNonPartialsToResources(getTopDirectory(),resourceNonGenerated); } catch (final CodeGenException e) { throw new MojoExecutionException("Couldn't add non partial specifications to resources"); } if (resourceNonGenerated.getIncludes().isEmpty()) { resourceNonGenerated.addExclude("**/*"); } final Resource resourceGenerated = new Resource(); final File specificationOutputDir = getSpecificationOutput(); resourceGenerated.setDirectory(specificationOutputDir.getPath()); resourceGenerated.addInclude("**/*.json"); final Resource[] resources = {resourceNonGenerated,resourceGenerated}; return resources; }
Example 4
Source File: RawXJC2Mojo.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 5 votes |
/** * Augments Maven paths with generated resources. */ protected void setupMavenPaths() { if (getAddCompileSourceRoot()) { getProject().addCompileSourceRoot(getGenerateDirectory().getPath()); } if (getAddTestCompileSourceRoot()) { getProject().addTestCompileSourceRoot(getGenerateDirectory().getPath()); } if (getEpisode() && getEpisodeFile() != null) { final String episodeFilePath = getEpisodeFile().getAbsolutePath(); final String generatedDirectoryPath = getGenerateDirectory().getAbsolutePath(); if (episodeFilePath.startsWith(generatedDirectoryPath + File.separator)) { final String path = episodeFilePath.substring(generatedDirectoryPath.length() + 1); final Resource resource = new Resource(); resource.setDirectory(generatedDirectoryPath); resource.addInclude(path); if (getAddCompileSourceRoot()) { getProject().addResource(resource); } if (getAddTestCompileSourceRoot()) { getProject().addTestResource(resource); } } } }
Example 5
Source File: CopyContracts.java From spring-cloud-contract with Apache License 2.0 | 4 votes |
public void copy(File contractsDirectory, File outputDirectory) throws MojoExecutionException { log.info("Copying Spring Cloud Contract Verifier contracts to [" + outputDirectory + "]" + ". Only files matching [" + this.config.getIncludedContracts() + "] pattern will end up in " + "the final JAR with stubs."); Resource resource = new Resource(); String includedRootFolderAntPattern = this.config .getIncludedRootFolderAntPattern() + "*.*"; String slashSeparatedGroupIdAntPattern = slashSeparatedGroupIdAntPattern( includedRootFolderAntPattern); String dotSeparatedGroupIdAntPattern = dotSeparatedGroupIdAntPattern( includedRootFolderAntPattern); // by default group id is slash separated... resource.addInclude(slashSeparatedGroupIdAntPattern); if (!slashSeparatedGroupIdAntPattern.equals(dotSeparatedGroupIdAntPattern)) { // ...we also want to allow dot separation resource.addInclude(dotSeparatedGroupIdAntPattern); } if (this.config.isExcludeBuildFolders()) { resource.addExclude("**/target/**"); resource.addExclude("**/.mvn/**"); resource.addExclude("**/build/**"); resource.addExclude("**/.gradle/**"); } resource.setDirectory(contractsDirectory.getAbsolutePath()); MavenResourcesExecution execution = new MavenResourcesExecution(); execution.setResources(Collections.singletonList(resource)); execution.setOutputDirectory(outputDirectory); execution.setMavenProject(this.project); execution.setEncoding("UTF-8"); execution.setMavenSession(this.mavenSession); execution.setInjectProjectBuildFilters(false); execution.setOverwrite(true); execution.setIncludeEmptyDirs(false); execution.setFilterFilenames(false); execution.setFilters(Collections.emptyList()); try { this.mavenResourcesFiltering.filterResources(execution); } catch (MavenFilteringException e) { throw new MojoExecutionException(e.getMessage(), e); } }