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

The following examples show how to use org.apache.maven.project.MavenProject#getCompileSourceRoots() . 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: IdlToDSMojoTest.java    From cougar with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void checkSourcePaths(MavenProject project) {

    List<String> paths = project.getCompileSourceRoots();

    assertEquals(1, paths.size());

    // this jiggery-pokery because I lack the resolve to fiddle with paths and separators and
    //	escapes for a simple string comparison that works on all platforms
    File path = new File(paths.get(0));
    assertEquals("java", path.getName());
    path = path.getParentFile();
    assertEquals("generated-sources", path.getName());
    path = path.getParentFile();
    assertEquals("target", path.getName());

}
 
Example 2
Source File: DefaultDescriptorsExtractor.java    From james-project with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private Collection<JavaClass> javaClasses(MavenProject project) {
    JavaProjectBuilder builder = new JavaProjectBuilder();
    for (String s : (Iterable<String>) project.getCompileSourceRoots()) {
        builder.addSourceTree(new File(s));
    }
    return builder.getClasses();
}
 
Example 3
Source File: CompileMojo.java    From takari-lifecycle with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void addGeneratedSources(MavenProject project) {
  List<String> roots = project.getCompileSourceRoots();
  String root = generatedSourcesDirectory.getAbsolutePath();
  if (!roots.contains(root)) {
    roots.add(root);
  }
}
 
Example 4
Source File: DeployMojoSupport.java    From ci.maven with Apache License 2.0 5 votes vote down vote up
private boolean containsJavaSource(MavenProject proj) {
    List<String> srcDirs = proj.getCompileSourceRoots();
    for (String dir : srcDirs) {
        File javaSourceDir = new File(dir);
        if (javaSourceDir.exists() && javaSourceDir.isDirectory() && containsJavaSource(javaSourceDir)) {
            return true;
        }
    }
    return false;
}
 
Example 5
Source File: ModuleInfoSupport.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static Collection<String> getRoots(MavenProject mp, DependencyType type) {
    final Collection<String> roots = type == DependencyType.TEST ? mp.getTestCompileSourceRoots() : mp.getCompileSourceRoots();
    return roots;
}
 
Example 6
Source File: ModuleInfoSupport.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private FileObject getModuleInfo() {
    MavenProject mp = project.getOriginalMavenProject();
    Collection<String> roots = type == DependencyType.TEST ? mp.getTestCompileSourceRoots() : mp.getCompileSourceRoots();
    return getModuleInfo(roots);
}