diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-01-24 02:01:46 +0300 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-01-24 10:39:02 +0300 |
commit | fc8c36d5b3e6f3fb844c1fc303bf41540b730602 (patch) | |
tree | 603024ac95033c1fb4ede1d9f8e7e847ffc75c90 | |
parent | fe9937de8631f275d52a00db06eb92a0ab668a37 (diff) | |
download | sonarqube-fc8c36d5b3e6f3fb844c1fc303bf41540b730602.tar.gz sonarqube-fc8c36d5b3e6f3fb844c1fc303bf41540b730602.zip |
SONAR-2106: Improve batch bootstrap
5 files changed, 52 insertions, 28 deletions
diff --git a/sonar-batch-bootstrapper/src/main/java/org/sonar/batch/bootstrapper/BatchDownloader.java b/sonar-batch-bootstrapper/src/main/java/org/sonar/batch/bootstrapper/BatchDownloader.java index b5eba165324..83d003007e0 100644 --- a/sonar-batch-bootstrapper/src/main/java/org/sonar/batch/bootstrapper/BatchDownloader.java +++ b/sonar-batch-bootstrapper/src/main/java/org/sonar/batch/bootstrapper/BatchDownloader.java @@ -66,6 +66,8 @@ public class BatchDownloader { } /** + * To use this method version of Sonar should be at least 2.6. + * * @return list of downloaded files */ public List<File> downloadBatchFiles(File toDir) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/Batch.java b/sonar-batch/src/main/java/org/sonar/batch/Batch.java index 373300542ec..df943c51fd5 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/Batch.java +++ b/sonar-batch/src/main/java/org/sonar/batch/Batch.java @@ -25,7 +25,6 @@ import org.picocontainer.MutablePicoContainer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.Plugins; -import org.sonar.api.batch.maven.MavenPluginHandler; import org.sonar.api.resources.Project; import org.sonar.api.utils.HttpDownloader; import org.sonar.api.utils.IocContainer; @@ -144,17 +143,6 @@ public class Batch { return false; } - class FakeMavenPluginExecutor implements MavenPluginExecutor { - public void execute(Project project, String goal) { - // do nothing - } - - public MavenPluginHandler execute(Project project, MavenPluginHandler handler) { - // do nothing - return handler; - } - } - private void register(MutablePicoContainer container, Object component) { container.as(Characteristics.CACHE).addComponent(component); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/FakeMavenPluginExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/FakeMavenPluginExecutor.java new file mode 100644 index 00000000000..a155cc369c0 --- /dev/null +++ b/sonar-batch/src/main/java/org/sonar/batch/FakeMavenPluginExecutor.java @@ -0,0 +1,15 @@ +package org.sonar.batch; + +import org.sonar.api.batch.maven.MavenPluginHandler; +import org.sonar.api.resources.Project; + +public class FakeMavenPluginExecutor implements MavenPluginExecutor { + public void execute(Project project, String goal) { + // do nothing + } + + public MavenPluginHandler execute(Project project, MavenPluginHandler handler) { + // do nothing + return handler; + } +}
\ No newline at end of file diff --git a/sonar-batch/src/main/java/org/sonar/batch/ProjectTree.java b/sonar-batch/src/main/java/org/sonar/batch/ProjectTree.java index 8adf4987039..69c4828e4d4 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/ProjectTree.java +++ b/sonar-batch/src/main/java/org/sonar/batch/ProjectTree.java @@ -19,10 +19,6 @@ */ package org.sonar.batch; -import org.sonar.batch.bootstrapper.ProjectDefinition; - -import org.sonar.batch.bootstrapper.Reactor; - import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.apache.maven.model.Reporting; @@ -30,6 +26,8 @@ import org.apache.maven.project.MavenProject; import org.slf4j.LoggerFactory; import org.sonar.api.database.DatabaseSession; import org.sonar.api.resources.Project; +import org.sonar.batch.bootstrapper.ProjectDefinition; +import org.sonar.batch.bootstrapper.Reactor; import java.io.File; import java.io.IOException; @@ -84,20 +82,14 @@ public class ProjectTree { pom.setReporting(reporting); // Configure source directories - // TODO - // for (FileSystemDirectory dir : project.getDirs()) { - // if (dir.getNature() == Natures.MAIN) { - // pom.addCompileSourceRoot(dir.getLocation().getAbsolutePath()); - // } - // } + for (String dir : project.getSourceDirs()) { + pom.addCompileSourceRoot(dir); + } // Configure test directories - // TODO - // for (FileSystemDirectory dir : project.getDirs()) { - // if (dir.getNature() == Natures.TEST) { - // pom.addTestCompileSourceRoot(dir.getLocation().getAbsolutePath()); - // } - // } + for (String dir : project.getSourceDirs()) { + pom.addTestCompileSourceRoot(dir); + } return pom; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/ProjectDefinition.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/ProjectDefinition.java index 2b0a2a27205..a5546d500b9 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/ProjectDefinition.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/ProjectDefinition.java @@ -19,9 +19,11 @@ */ package org.sonar.batch.bootstrapper; +import com.google.common.collect.Lists; import org.apache.commons.configuration.Configuration; import java.io.File; +import java.util.List; /** * Defines project in a form suitable to bootstrap Sonar batch. @@ -34,6 +36,8 @@ public class ProjectDefinition { private File baseDir; private Configuration properties; + private List<String> sourceDirs = Lists.newArrayList(); + private List<String> testDirs = Lists.newArrayList(); /** * @param baseDir project base directory @@ -52,4 +56,27 @@ public class ProjectDefinition { return properties; } + public List<String> getSourceDirs() { + return sourceDirs; + } + + /** + * @param path path to directory with main sources. + * It can be absolute or relative to project directory. + */ + public void addSourceDir(String path) { + sourceDirs.add(path); + } + + public List<String> getTestDirs() { + return testDirs; + } + + /** + * @param path path to directory with test sources. + * It can be absolute or relative to project directory. + */ + public void addTestDir(String path) { + testDirs.add(path); + } } |