Java Code Examples for org.apache.maven.project.MavenProject#getTestArtifacts()

The following examples show how to use org.apache.maven.project.MavenProject#getTestArtifacts() . 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: SearchClassDependencyInRepo.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private Artifact getArtifact(NbMavenProject mavProj, List<NBVersionInfo> nbvis, boolean isTestSource) {
    MavenProject mp = mavProj.getMavenProject();
    List<Artifact> arts = new LinkedList<Artifact>(isTestSource ? mp.getTestArtifacts() : mp.getCompileArtifacts());
    for (NBVersionInfo info : nbvis) {
        for (Artifact a : arts) {
            if (a.getGroupId() != null && a.getGroupId().equals(info.getGroupId())) {
                if (a.getArtifactId() != null && a.getArtifactId().equals(info.getArtifactId())) {
                    String scope = a.getScope();
                    if ("compile".equals(scope) || "test".equals(scope)) { // NOI18N
                        return a;
                    }
                }
            }
        }
    }
    return null;
}
 
Example 2
Source File: TestCompileClassPathImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
URI[] createPath() {
    List<URI> lst = new ArrayList<>();
    MavenProject mavenProject = getMavenProject().getOriginalMavenProject();
    //TODO we shall add the test class output as well. how?
    // according the current 2.1 sources this is almost the same as getCompileClasspath()
    //except for the fact that multiproject references are not redirected to their respective
    // output folders.. we lways retrieve stuff from local repo..
    List<Artifact> arts = mavenProject.getTestArtifacts();
    boolean broken = false;
    for (Artifact art : arts) {
        if (art.getFile() != null) {
            lst.add(Utilities.toURI(art.getFile()));
            broken |= !art.getFile().exists();
        } else { //NOPMD
            //null means dependencies were not resolved..
            broken = true;
        }
    }
    if(testScoped) {
        List<URI> cmplst = new ArrayList<>();
        broken |= CompileClassPathImpl.getCompileArtifacts(mavenProject, cmplst);
        lst.removeAll(cmplst);
    }
    if (incomplete != broken) {
        incomplete = broken;
        firePropertyChange(PROP_FLAGS, null, null);
    }
    if(addTestOutDir) {
        lst.add(0, Utilities.toURI(getMavenProject().getProjectWatcher().getOutputDirectory(true)));            
    }
    lst.add(0, Utilities.toURI(getMavenProject().getProjectWatcher().getOutputDirectory(false)));
    URI[] uris = new URI[lst.size()];
    uris = lst.toArray(uris);
    return uris;
}