List of usage examples for org.apache.maven.project MavenProject addResource
public void addResource(Resource resource)
From source file:com.github.veithen.alta.GenerateResourcesMojo.java
License:Apache License
@Override protected void addResource(MavenProject project, Resource resource) { project.addResource(resource); }
From source file:net.java.javabuild.SourceFoldersUtils.java
License:Apache License
public static void addSourceFolders(MavenProject project) { project.addTestCompileSourceRoot(BuilderFolders.BUILD_SOURCES); project.addTestResource(toResource(BuilderFolders.BUILD_RESOURCES, project)); project.addCompileSourceRoot(BuilderFolders.GENERATED_SOURCES); project.addResource(toResource(BuilderFolders.GENERATED_RESOURCES, project)); project.addTestCompileSourceRoot(BuilderFolders.GENERATED_TEST_SOURCES); project.addTestResource(toResource(BuilderFolders.GENERATED_TEST_RESOURCES, project)); }
From source file:org.codehaus.mojo.license.MojoHelper.java
License:Open Source License
/** * Add the directory as a resource in the given resource list. * * @param dir the directory to add * @param project the project involved * @param resources the list of existing resources * @param includes includes of the new resources * @return {@code true} if the resource was added (not already existing) *//*from w w w . ja v a2 s . com*/ public static boolean addResourceDir(File dir, MavenProject project, List<?> resources, String... includes) { String newresourceDir = dir.getAbsolutePath(); boolean shouldAdd = true; for (Object o : resources) { Resource r = (Resource) o; if (!r.getDirectory().equals(newresourceDir)) { continue; } for (String i : includes) { if (!r.getIncludes().contains(i)) { r.addInclude(i); } } shouldAdd = false; break; } if (shouldAdd) { Resource r = new Resource(); r.setDirectory(newresourceDir); for (String i : includes) { if (!r.getIncludes().contains(i)) { r.addInclude(i); } } project.addResource(r); } return shouldAdd; }
From source file:org.codehaus.mojo.xml.TransformMojo.java
License:Apache License
private void addToClasspath(File pOutputDir) { MavenProject project = getProject(); for (Iterator<Resource> iter = project.getResources().iterator(); iter.hasNext();) { Resource resource = iter.next(); if (resource.getDirectory().equals(pOutputDir)) { return; }// w w w .j a va2 s .com } Resource resource = new Resource(); resource.setDirectory(pOutputDir.getPath()); resource.setFiltering(false); project.addResource(resource); }
From source file:org.codehaus.mojo.xmlbeans.CompileXmlBeansMojo.java
License:Apache License
protected void updateProject(MavenProject project, SchemaCompiler.Parameters compilerParams, boolean stale) throws DependencyResolutionRequiredException, XmlBeansException { if (getLog().isDebugEnabled()) { getLog().debug("Adding " + compilerParams.getSrcDir().getAbsolutePath() + " to the project's compile sources."); }//ww w. java 2 s. com project.addCompileSourceRoot(compilerParams.getSrcDir().getAbsolutePath()); Resource resource = new Resource(); resource.setDirectory(compilerParams.getClassesDir().getAbsolutePath()); resource.setFiltering(false); project.addResource(resource); }
From source file:org.efaps.maven_java5.EfapsAnnotationDescriptorExtractor.java
License:Open Source License
/** * * @param _project//w w w. ja v a 2 s. c o m * @param _pluginDescriptor */ public List<MojoDescriptor> execute(final MavenProject _project, final PluginDescriptor _pluginDescriptor) throws InvalidPluginDescriptorException { final List<MojoDescriptor> descriptors = new ArrayList<MojoDescriptor>(); // check all compiled classes for mojos final File classesDirectory = new File(_project.getBuild().getOutputDirectory()); final DirectoryScanner scanner = new DirectoryScanner(); scanner.setBasedir(classesDirectory); scanner.setIncludes(new String[] { "**/*.class" }); scanner.scan(); if (getLogger().isDebugEnabled()) { getLogger().debug("Scanning " + scanner.getIncludedFiles().length + " classes"); } final String[] included = scanner.getIncludedFiles(); if (included.length > 0) { final ClassLoader cl = getClassLoader(_project); for (final String file : scanner.getIncludedFiles()) { final MojoDescriptor desc = scan(cl, file.substring(0, file.lastIndexOf(".class")).replace('/', '.')); if (desc != null) { desc.setPluginDescriptor(_pluginDescriptor); descriptors.add(desc); if (getLogger().isInfoEnabled()) { getLogger().info("Found mojo " + desc.getImplementation()); } } } } final Resource resource = new Resource(); resource.setDirectory(classesDirectory.getAbsolutePath()); resource.setIncludes(Collections.EMPTY_LIST); resource.setExcludes(Collections.EMPTY_LIST); _project.addResource(resource); return descriptors; }
From source file:org.onosproject.yang.compiler.plugin.maven.YangPluginUtils.java
License:Apache License
static void addToProjectResource(String dir, MavenProject project) { Resource rsc = new Resource(); rsc.setDirectory(dir);/*from ww w . j a va 2 s .c o m*/ project.addResource(rsc); }
From source file:org.onosproject.yangutils.plugin.manager.YangPluginUtils.java
License:Apache License
private static void addToProjectResource(String dir, MavenProject project) { Resource rsc = new Resource(); rsc.setDirectory(dir);//w w w.ja v a 2 s . c o m project.addResource(rsc); }
From source file:org.onosproject.yangutils.utils.io.impl.YangIoUtils.java
License:Apache License
/** * Copy YANG files to the current project's output directory. * * @param yangFiles list of YANG files/*from w ww. j a v a2 s. co m*/ * @param outputDir project's output directory * @param project maven project * @throws IOException when fails to copy files to destination resource directory */ public static void copyYangFilesToTarget(List<String> yangFiles, String outputDir, MavenProject project) throws IOException { List<File> files = getListOfFile(yangFiles); String path = outputDir + TARGET_RESOURCE_PATH; File targetDir = new File(path); targetDir.mkdirs(); for (File file : files) { Files.copy(file.toPath(), (new File(path + file.getName())).toPath(), StandardCopyOption.REPLACE_EXISTING); } Resource rsc = new Resource(); rsc.setDirectory(outputDir + SLASH + TEMP + SLASH); project.addResource(rsc); }
From source file:org.opendaylight.yangtools.yang2sources.plugin.YangProvider.java
License:Open Source License
static void setResource(final File targetYangDir, final MavenProject project) { Resource res = new Resource(); res.setDirectory(targetYangDir.getPath()); project.addResource(res); }