String excludes; List allResources = project.getResources(); allResources.addAll( project.getTestResources() );
@Override protected List<Resource> getProjectResources() { return project.getTestResources(); } }
public List<Resource> getTestResources() { return wrapped.getTestResources(); }
public List getTestResources() { return getDelegate().getTestResources(); }
@Override protected List<File> getSources() { List<File> sources = Lists.newArrayList(); for (String source : mavenProject.getTestCompileSourceRoots()) { sources.add(new File(source)); } for (Resource res : mavenProject.getTestResources()) { sources.add(new File(res.getDirectory())); } return sources; }
@SuppressWarnings("unchecked") @Override protected java.util.Set<String> getClasspathElements( final java.util.Set<String> result ) { List<Resource> resources = project.getTestResources(); if( resources!=null ) { for( Resource r : resources ) { result.add(r.getDirectory()); } } result.addAll( classpathElements ); return result; }
/** * Add thedirectory as a test resource of the given project. * * @param dir the directory to add * @param project the project to update * @param includes the includes of the resource * @return {@code true} if the resources was added (not already existing) * @since 1.1.1 */ public static boolean addTestResourceDir(File dir, MavenProject project, String... includes) { List<?> resources = project.getTestResources(); boolean added = addResourceDir(dir, project, resources, includes); return added; }
/** * Add thedirectory as a test resource of the given project. * * @param dir the directory to add * @param project the project to update * @param includes the includes of the resource * @return {@code true} if the resources was added (not already existing) * @since 1.1.1 */ public static boolean addTestResourceDir(File dir, MavenProject project, String... includes) { List<?> resources = project.getTestResources(); boolean added = addResourceDir(dir, project, resources, includes); return added; }
/** * Get resources for specific scope. * * @param project * @param scope * @return */ private List<Resource> getResources( final MavenProject project, final String scope ) { if ( SCOPE_COMPILE.equals( scope ) || SCOPE_RUNTIME.equals( scope ) ) { return project.getResources(); } else if ( SCOPE_TEST.equals( scope ) ) { List<Resource> resources = new ArrayList<Resource>(); resources.addAll( project.getTestResources() ); resources.addAll( project.getResources() ); return resources; } else { throw new RuntimeException( "Not allowed scope " + scope ); } }
/** * Get resources for specific scope. * * @param project * @param scope * @return */ private List<Resource> getResources( final MavenProject project, final String scope ) { if ( SCOPE_COMPILE.equals( scope ) || SCOPE_RUNTIME.equals( scope ) ) { return project.getResources(); } else if ( SCOPE_TEST.equals( scope ) ) { List<Resource> resources = new ArrayList<Resource>(); resources.addAll( project.getTestResources() ); resources.addAll( project.getResources() ); return resources; } else { throw new RuntimeException( "Not allowed scope " + scope ); } }
private ClassLoader getResourceLoader() throws MojoExecutionException { if (resourceClassLoader == null) { try { List<?> runtimeClasspathElements = project.getRuntimeClasspathElements(); List<?> resources = project.getResources(); List<?> testResources = project.getTestResources(); URL[] runtimeUrls = new URL[runtimeClasspathElements.size() + resources.size() + testResources.size()]; for (int i = 0; i < runtimeClasspathElements.size(); i++) { String element = (String)runtimeClasspathElements.get(i); runtimeUrls[i] = new File(element).toURI().toURL(); } for (int i = 0, j = runtimeClasspathElements.size(); i < resources.size(); i++, j++) { Resource r = (Resource)resources.get(i); runtimeUrls[j] = new File(r.getDirectory()).toURI().toURL(); } for (int i = 0, j = runtimeClasspathElements.size() + resources.size(); i < testResources.size(); i++, j++) { Resource r = (Resource)testResources.get(i); runtimeUrls[j] = new File(r.getDirectory()).toURI().toURL(); } resourceClassLoader = new URLClassLoader(runtimeUrls, Thread.currentThread() .getContextClassLoader()); } catch (Exception e) { throw new MojoExecutionException(e.getMessage(), e); } } return resourceClassLoader; }
public URI[] getResources(boolean test) { List<URI> toRet = new ArrayList<URI>(); List res = test ? getOriginalMavenProject().getTestResources() : getOriginalMavenProject().getResources(); Iterator it = res.iterator(); while (it.hasNext()) { Resource elem = (Resource) it.next(); URI uri = FileUtilities.getDirURI(getProjectDirectory(), elem.getDirectory()); // if (new File(uri).exists()) { toRet.add(uri); // } } return toRet.toArray(new URI[toRet.size()]); }
private static List<Resource> getMavenResources( MavenProject currentProject, boolean test ) { List<Resource> resources = new ArrayList<Resource>( test ? currentProject.getTestResources() : currentProject.getResources() ); if ( currentProject.getCompileSourceRoots() != null ) { // also scan for any "packageinfo" files lurking in the source folders final List<String> packageInfoIncludes = Collections.singletonList( "**/packageinfo" ); for ( Iterator<String> i = currentProject.getCompileSourceRoots().iterator(); i.hasNext(); ) { String sourceRoot = i.next(); Resource packageInfoResource = new Resource(); packageInfoResource.setDirectory( sourceRoot ); packageInfoResource.setIncludes( packageInfoIncludes ); resources.add( packageInfoResource ); } } return resources; }
public void execute() throws MojoExecutionException { try { copyAllResources(project.getResources()); copyAllResources(project.getTestResources()); } catch (Exception ex) { getLog().debug("Exception thrown while copying files. Reason:", ex); throw new MojoExecutionException( "NPANDAY-1500-005: Failed to copy config files.", ex ); } }
/** * Extends the configured resources with the given resource * * @param res * The res to extend the current resources with * @throws Exception */ @SuppressWarnings("unchecked") private void extendResources(String res, boolean forTest) throws Exception { List<Resource> resources = (forTest) ? project.getTestResources() : project.getResources(); File fileRes = null; if (!new File(res).isAbsolute()) { fileRes = new File(project.getBasedir(), res); } if (!fileRes.exists()) { return; } for (Resource resource : resources) { if (resource.getDirectory().equalsIgnoreCase(res)) { return; } } getLog().info("Adding " + fileRes.getPath() + " to the list of current resources."); Resource resource = new Resource(); resource.setDirectory(fileRes.getPath()); resources.add(resource); }
@Override public String[] getAdditionalClasspathElements() { if (computedAdditionalClasspathElements == null) { List<Resource> resources = new ArrayList<>(); resources.addAll(getProject().getResources()); resources.addAll(getProject().getTestResources()); List<String> sourceRoots = new ArrayList<>(); sourceRoots.addAll(getProject().getCompileSourceRoots()); sourceRoots.addAll(getProject().getTestCompileSourceRoots()); List<String> filteredSourceRoots = SourcesAsResourcesHelper.filterSourceRoots(getLog(), resources, sourceRoots); filteredSourceRoots.addAll(Arrays.asList(super.getAdditionalClasspathElements())); computedAdditionalClasspathElements = sourceRoots.toArray(new String[filteredSourceRoots.size()]); } return computedAdditionalClasspathElements; }
protected List<Resource> getResources(boolean istest) { return istest ? project.getOriginalMavenProject().getTestResources() : project.getOriginalMavenProject().getResources(); }
resources = project.getTestResources(); for (Object obj : resources) { Resource resource = (Resource) obj;
final List<Resource> currentResources = getProject().getTestResources();
final List<Resource> currentResources = getProject().getTestResources();