Created
April 7, 2011 14:41
-
-
Save simonbrandhof/907880 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| root : | |
| <sonar:sonar_project key="foo" version="1.1"> | |
| <modules> | |
| <path location="one"/> | |
| <path location="two"/> | |
| </modules> | |
| </sonar:sonar_project> | |
| modules : | |
| <sonar:sonar_project key="<module key>" version="<module version>"> | |
| </sonar:sonar_project> | |
| Task : | |
| public class SonarProjectTask extends Task { | |
| private String key; | |
| private String version; | |
| private Path modules; | |
| public void setKey(String key) { | |
| this.key = key; | |
| } | |
| public String getKey() { | |
| return key; | |
| } | |
| public void setVersion(String version) { | |
| this.version = version; | |
| } | |
| public String getVersion() { | |
| return version; | |
| } | |
| public Path createModules() { | |
| if (modules == null) { | |
| modules = new Path(getProject()); | |
| } | |
| return modules; | |
| } | |
| @Override | |
| public void execute() { | |
| getProject().setProperty("sonar.key", key); | |
| getProject().addReference("sonar.version", version); | |
| if (modules != null) { | |
| System.out.println(String.format("--------- modules of %s-----------", getProject().getName())); | |
| for (String path : modules.list()) { | |
| Project module = getProject().createSubProject(); | |
| ProjectHelper.configureProject(module, new File(path, "build.xml")); | |
| System.out.println(module.getProperty("sonar.key") + " v." + module.getReference("sonar.version")); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment