Skip to content

Instantly share code, notes, and snippets.

@simonbrandhof
Created April 7, 2011 14:41
Show Gist options
  • Select an option

  • Save simonbrandhof/907880 to your computer and use it in GitHub Desktop.

Select an option

Save simonbrandhof/907880 to your computer and use it in GitHub Desktop.
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