use of org.gradle.api.internal.plugins.DslObject in project gradle by gradle.
the class JavaBasePlugin method createProcessResourcesTaskForBinary.
private void createProcessResourcesTaskForBinary(final SourceSet sourceSet, SourceDirectorySet resourceSet, final Project target) {
Copy resourcesTask = target.getTasks().create(sourceSet.getProcessResourcesTaskName(), ProcessResources.class);
resourcesTask.setDescription("Processes " + resourceSet + ".");
new DslObject(resourcesTask).getConventionMapping().map("destinationDir", new Callable<File>() {
public File call() throws Exception {
return sourceSet.getOutput().getResourcesDir();
}
});
resourcesTask.from(resourceSet);
}
use of org.gradle.api.internal.plugins.DslObject in project gradle by gradle.
the class JavaBasePlugin method configureTestDefaults.
private void configureTestDefaults(final Test test, Project project, final JavaPluginConvention convention) {
DslObject htmlReport = new DslObject(test.getReports().getHtml());
DslObject xmlReport = new DslObject(test.getReports().getJunitXml());
xmlReport.getConventionMapping().map("destination", new Callable<Object>() {
public Object call() throws Exception {
return new File(convention.getTestResultsDir(), test.getName());
}
});
htmlReport.getConventionMapping().map("destination", new Callable<Object>() {
public Object call() throws Exception {
return new File(convention.getTestReportDir(), test.getName());
}
});
test.getConventionMapping().map("binResultsDir", new Callable<Object>() {
public Object call() throws Exception {
return new File(convention.getTestResultsDir(), test.getName() + "/binary");
}
});
test.workingDir(project.getProjectDir());
}
use of org.gradle.api.internal.plugins.DslObject in project gradle by gradle.
the class ProjectReportsPlugin method apply.
@Override
public void apply(Project project) {
project.getPluginManager().apply(ReportingBasePlugin.class);
final ProjectReportsPluginConvention convention = new ProjectReportsPluginConvention(project);
project.getConvention().getPlugins().put("projectReports", convention);
TaskReportTask taskReportTask = project.getTasks().create(TASK_REPORT, TaskReportTask.class);
taskReportTask.setDescription("Generates a report about your tasks.");
taskReportTask.conventionMapping("outputFile", new Callable<Object>() {
public Object call() throws Exception {
return new File(convention.getProjectReportDir(), "tasks.txt");
}
});
taskReportTask.conventionMapping("projects", new Callable<Object>() {
public Object call() throws Exception {
return convention.getProjects();
}
});
PropertyReportTask propertyReportTask = project.getTasks().create(PROPERTY_REPORT, PropertyReportTask.class);
propertyReportTask.setDescription("Generates a report about your properties.");
propertyReportTask.conventionMapping("outputFile", new Callable<Object>() {
public Object call() throws Exception {
return new File(convention.getProjectReportDir(), "properties.txt");
}
});
propertyReportTask.conventionMapping("projects", new Callable<Object>() {
public Object call() throws Exception {
return convention.getProjects();
}
});
DependencyReportTask dependencyReportTask = project.getTasks().create(DEPENDENCY_REPORT, DependencyReportTask.class);
dependencyReportTask.setDescription("Generates a report about your library dependencies.");
dependencyReportTask.conventionMapping("outputFile", new Callable<Object>() {
public Object call() throws Exception {
return new File(convention.getProjectReportDir(), "dependencies.txt");
}
});
dependencyReportTask.conventionMapping("projects", new Callable<Object>() {
public Object call() throws Exception {
return convention.getProjects();
}
});
HtmlDependencyReportTask htmlDependencyReportTask = project.getTasks().create(HTML_DEPENDENCY_REPORT, HtmlDependencyReportTask.class);
htmlDependencyReportTask.setDescription("Generates an HTML report about your library dependencies.");
new DslObject(htmlDependencyReportTask.getReports().getHtml()).getConventionMapping().map("destination", new Callable<Object>() {
public Object call() throws Exception {
return new File(convention.getProjectReportDir(), "dependencies");
}
});
htmlDependencyReportTask.conventionMapping("projects", new Callable<Object>() {
public Object call() throws Exception {
return convention.getProjects();
}
});
Task projectReportTask = project.getTasks().create(PROJECT_REPORT);
projectReportTask.dependsOn(TASK_REPORT, PROPERTY_REPORT, DEPENDENCY_REPORT, HTML_DEPENDENCY_REPORT);
projectReportTask.setDescription("Generates a report about your project.");
projectReportTask.setGroup("reporting");
}
use of org.gradle.api.internal.plugins.DslObject in project gradle by gradle.
the class CodeNarcPlugin method configureForSourceSet.
@Override
protected void configureForSourceSet(final SourceSet sourceSet, CodeNarc task) {
task.setDescription("Run CodeNarc analysis for " + sourceSet.getName() + " classes");
DynamicObject dynamicObject = new DslObject(sourceSet).getAsDynamicObject();
task.setSource(dynamicObject.getProperty("allGroovy"));
}
use of org.gradle.api.internal.plugins.DslObject in project gradle by gradle.
the class BridgedCollections method registration.
public static <I, C extends NamedDomainObjectCollection<I>> ModelRegistrations.Builder registration(final ModelReference<C> containerReference, final Transformer<? extends C, ? super MutableModelNode> containerFactory, final Namer<? super I> namer, String descriptor, final Transformer<String, String> itemDescriptorGenerator) {
final ModelPath containerPath = containerReference.getPath();
final ModelType<C> containerType = containerReference.getType();
assert containerPath != null : "container reference path cannot be null";
return ModelRegistrations.of(containerPath).action(ModelActionRole.Create, new Action<MutableModelNode>() {
public void execute(final MutableModelNode containerNode) {
final C container = containerFactory.transform(containerNode);
containerNode.setPrivateData(containerType, container);
container.all(new Action<I>() {
public void execute(final I item) {
final String name = namer.determineName(item);
// For now, ignore elements added after the container has been closed
if (!containerNode.isMutable()) {
LOGGER.debug("Ignoring element '{}' added to '{}' after it is closed.", containerPath, name);
return;
}
if (!containerNode.hasLink(name)) {
ModelRegistration itemRegistration = ModelRegistrations.unmanagedInstanceOf(ModelReference.of(containerPath.child(name), new DslObject(item).getDeclaredType()), new ExtractFromParentContainer<I, C>(name, containerType)).descriptor(new SimpleModelRuleDescriptor(new Factory<String>() {
@Override
public String create() {
return itemDescriptorGenerator.transform(name);
}
})).build();
containerNode.addLink(itemRegistration);
}
}
});
container.whenObjectRemoved(new Action<I>() {
public void execute(I item) {
String name = namer.determineName(item);
containerNode.removeLink(name);
}
});
}
}).descriptor(descriptor);
}
Aggregations