private void configureSourceSetDefaults(final JavaPluginConvention pluginConvention) {
pluginConvention.getSourceSets().allObjects(new Action<SourceSet>() {
public void execute(final SourceSet sourceSet) {
final Project project = pluginConvention.getProject();
ConventionMapping conventionMapping = ((IConventionAware) sourceSet).getConventionMapping();
conventionMapping.map("classesDir", new ConventionValue() {
public Object getValue(Convention convention, IConventionAware conventionAwareObject) {
String classesDirName = String.format("classes/%s", sourceSet.getName());
return new File(project.getBuildDir(), classesDirName);
}
});
sourceSet.getJava().srcDir(String.format("src/%s/java", sourceSet.getName()));
sourceSet.getResources().srcDir(String.format("src/%s/resources", sourceSet.getName()));
Copy processResources = project.getTasks().add(sourceSet.getProcessResourcesTaskName(), ProcessResources.class);
processResources.setDescription(String.format("Processes the %s.", sourceSet.getResources()));
conventionMapping = processResources.getConventionMapping();
conventionMapping.map("defaultSource", new ConventionValue() {
public Object getValue(Convention convention, IConventionAware conventionAwareObject) {
return sourceSet.getResources();
}
});
conventionMapping.map("destinationDir", new ConventionValue() {
public Object getValue(Convention convention, IConventionAware conventionAwareObject) {
return sourceSet.getClassesDir();
}
});