List of usage examples for org.apache.maven.project MavenProject getCompileSourceRoots
public List<String> getCompileSourceRoots()
From source file:org.mobicents.maven.plugin.EclipseMojo.java
License:Open Source License
/** * Processes the project compile source roots (adds all appropriate ones to the projects) * so that they're avialable to the eclipse mojos. * * @param projects the projects to process. * @return the source roots./*w ww. jav a2 s.c o m*/ * @throws Exception */ private void processCompileSourceRoots(final List projects) throws Exception { for (final Iterator iterator = projects.iterator(); iterator.hasNext();) { final MavenProject project = (MavenProject) iterator.next(); final Set compileSourceRoots = new LinkedHashSet(project.getCompileSourceRoots()); compileSourceRoots.addAll(this.getExtraSourceDirectories(project)); final String testSourceDirectory = project.getBuild().getTestSourceDirectory(); if (testSourceDirectory != null && testSourceDirectory.trim().length() > 0) { compileSourceRoots.add(testSourceDirectory); } project.getCompileSourceRoots().clear(); project.getCompileSourceRoots().addAll(compileSourceRoots); } }
From source file:org.netbeans.modules.jackpot30.maven.RunJackpot30.java
License:Open Source License
protected final void doRun(MavenProject project, boolean apply) throws MojoExecutionException, MojoFailureException { try {/* ww w. ja v a2 s . c o m*/ String sourceLevel = "1.5"; Xpp3Dom sourceLevelConfiguration = Utils.getPluginConfiguration(project, "org.apache.maven.plugins", "maven-compiler-plugin"); if (sourceLevelConfiguration != null) { Xpp3Dom source = sourceLevelConfiguration.getChild("source"); if (source != null) { sourceLevel = source.getValue(); } } String configurationFile = Utils.getJackpotConfigurationFile(project); List<String> cmdLine = new ArrayList<String>(); if (apply) cmdLine.add("--apply"); else cmdLine.add("--no-apply"); cmdLine.addAll(sourceAndCompileClassPaths(Collections.singletonList(project))); cmdLine.add("--source"); cmdLine.add(sourceLevel); if (configurationFile != null) { cmdLine.add("--config-file"); cmdLine.add(configurationFile); } boolean hasSourceRoots = false; for (String sr : (List<String>) project.getCompileSourceRoots()) { if (!hasSourceRoots && new File(sr).isDirectory()) { hasSourceRoots = true; } cmdLine.add(sr); } if (!hasSourceRoots) { getLog().debug("jackpot30 analyze: Not source roots to operate on"); return; } Main.compile(cmdLine.toArray(new String[0])); } catch (IOException ex) { throw new MojoExecutionException(ex.getMessage(), ex); } catch (ClassNotFoundException ex) { throw new MojoExecutionException(ex.getMessage(), ex); } catch (DependencyResolutionRequiredException ex) { throw new MojoExecutionException(ex.getMessage(), ex); } }
From source file:org.netbeans.modules.jackpot30.maven.RunJackpot30.java
License:Open Source License
@SuppressWarnings("unchecked") public static List<String> sourceAndCompileClassPaths(Iterable<? extends MavenProject> projects) throws DependencyResolutionRequiredException { List<String> compileSourceRoots = new ArrayList<String>(); List<String> compileClassPath = new ArrayList<String>(); for (MavenProject project : projects) { compileSourceRoots.addAll((List<String>) project.getCompileSourceRoots()); for (Resource r : (List<Resource>) project.getResources()) { compileSourceRoots.add(r.getDirectory()); }/*from www . j a v a2s .c o m*/ compileClassPath.addAll((List<String>) project.getCompileClasspathElements()); } return Arrays.asList("--sourcepath", toClassPathString(compileSourceRoots), "--classpath", toClassPathString(compileClassPath)); }
From source file:org.sonar.batch.maven.MavenProjectConverter.java
License:Open Source License
private List<File> mainDirs(MavenProject pom) { return sourceDirs(pom, ProjectDefinition.SOURCE_DIRS_PROPERTY, pom.getCompileSourceRoots()); }
From source file:org.sonar.batch.MavenProjectConverter.java
License:Open Source License
public static void synchronizeFileSystem(MavenProject pom, ProjectDefinition into) { into.setBaseDir(pom.getBasedir());//from w ww . j a v a 2 s . co m into.setWorkDir(new File(resolvePath(pom.getBuild().getDirectory(), pom.getBasedir()), "sonar")); into.setSourceDirs( (String[]) pom.getCompileSourceRoots().toArray(new String[pom.getCompileSourceRoots().size()])); into.setTestDirs((String[]) pom.getTestCompileSourceRoots() .toArray(new String[pom.getTestCompileSourceRoots().size()])); }
From source file:org.sonar.batch.scan.maven.MavenProjectConverter.java
License:Open Source License
public static void synchronizeFileSystem(MavenProject pom, ProjectDefinition into) { into.setBaseDir(pom.getBasedir());//from ww w . j av a 2 s .c o m File buildDir = resolvePath(pom.getBuild().getDirectory(), pom.getBasedir()); if (buildDir != null) { into.setBuildDir(buildDir); into.setWorkDir(new File(buildDir, "sonar")); } into.setSourceDirs( (String[]) pom.getCompileSourceRoots().toArray(new String[pom.getCompileSourceRoots().size()])); into.setTestDirs((String[]) pom.getTestCompileSourceRoots() .toArray(new String[pom.getTestCompileSourceRoots().size()])); File binaryDir = resolvePath(pom.getBuild().getOutputDirectory(), pom.getBasedir()); if (binaryDir != null) { into.addBinaryDir(binaryDir); } }
From source file:org.sonar.batch.scan.maven.MavenProjectConverter.java
License:Open Source License
public static void synchronizeFileSystem(MavenProject pom, DefaultModuleFileSystem into) { into.resetDirs(pom.getBasedir(), resolvePath(pom.getBuild().getDirectory(), pom.getBasedir()), resolvePaths((List<String>) pom.getCompileSourceRoots(), pom.getBasedir()), resolvePaths((List<String>) pom.getTestCompileSourceRoots(), pom.getBasedir()), Arrays.asList(resolvePath(pom.getBuild().getOutputDirectory(), pom.getBasedir()))); }
From source file:org.sonar.plugins.maven.MavenProjectConverter.java
License:Open Source License
public static void synchronizeFileSystem(MavenProject pom, ProjectDefinition into) { into.setBaseDir(pom.getBasedir());/*ww w . j a v a2s .c o m*/ File buildDir = getBuildDir(pom); if (buildDir != null) { into.setBuildDir(buildDir); into.setWorkDir(getSonarWorkDir(pom)); } List<String> filteredCompileSourceRoots = filterExisting(pom.getCompileSourceRoots(), pom.getBasedir()); List<String> filteredTestCompileSourceRoots = filterExisting(pom.getTestCompileSourceRoots(), pom.getBasedir()); into.setSourceDirs( (String[]) filteredCompileSourceRoots.toArray(new String[filteredCompileSourceRoots.size()])); into.setTestDirs((String[]) filteredTestCompileSourceRoots .toArray(new String[filteredTestCompileSourceRoots.size()])); File binaryDir = resolvePath(pom.getBuild().getOutputDirectory(), pom.getBasedir()); if (binaryDir != null) { into.addBinaryDir(binaryDir); } }
From source file:org.sonar.plugins.maven.MavenProjectConverter.java
License:Open Source License
public static void synchronizeFileSystem(MavenProject pom, DefaultModuleFileSystem into) { into.resetDirs(pom.getBasedir(), getBuildDir(pom), resolvePaths(pom.getCompileSourceRoots(), pom.getBasedir()), resolvePaths(pom.getTestCompileSourceRoots(), pom.getBasedir()), Arrays.asList(resolvePath(pom.getBuild().getOutputDirectory(), pom.getBasedir()))); }
From source file:org.sonarsource.scanner.maven.bootstrap.MavenProjectConverter.java
License:Open Source License
private List<File> mainSources(MavenProject pom) throws MojoExecutionException { Set<String> sources = new LinkedHashSet<>(); if (MAVEN_PACKAGING_WAR.equals(pom.getModel().getPackaging())) { sources.add(MavenUtils.getPluginSetting(pom, MavenUtils.GROUP_ID_APACHE_MAVEN, ARTIFACTID_MAVEN_WAR_PLUGIN, "warSourceDirectory", "src/main/webapp")); }//w w w .j av a 2 s. c o m sources.add(pom.getFile().getPath()); sources.addAll(pom.getCompileSourceRoots()); return sourcePaths(pom, ScanProperties.PROJECT_SOURCE_DIRS, sources); }