Java Code Examples for org.gradle.api.internal.plugins.DslObject
The following examples show how to use
org.gradle.api.internal.plugins.DslObject. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: pushfish-android Source File: MavenPublishPlugin.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void createGeneratePomTask(CollectionBuilder<Task> tasks, final MavenPublicationInternal publication, String publicationName) { String descriptorTaskName = String.format("generatePomFileFor%sPublication", capitalize(publicationName)); tasks.create(descriptorTaskName, GenerateMavenPom.class, new Action<GenerateMavenPom>() { public void execute(final GenerateMavenPom generatePomTask) { generatePomTask.setDescription(String.format("Generates the Maven POM file for publication '%s'.", publication.getName())); generatePomTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); generatePomTask.setPom(publication.getPom()); ConventionMapping descriptorTaskConventionMapping = new DslObject(generatePomTask).getConventionMapping(); descriptorTaskConventionMapping.map("destination", new Callable<Object>() { public Object call() throws Exception { return new File(generatePomTask.getProject().getBuildDir(), "publications/" + publication.getName() + "/pom-default.xml"); } }); // Wire the generated pom into the publication. publication.setPomFile(generatePomTask.getOutputs().getFiles()); } }); }
Example 2
Source Project: pushfish-android Source File: ProjectPropertySettingBuildLoader.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void addPropertiesToProject(Project project) { Properties projectProperties = new Properties(); File projectPropertiesFile = new File(project.getProjectDir(), Project.GRADLE_PROPERTIES); LOGGER.debug("Looking for project properties from: {}", projectPropertiesFile); if (projectPropertiesFile.isFile()) { projectProperties = GUtil.loadProperties(projectPropertiesFile); LOGGER.debug("Adding project properties (if not overwritten by user properties): {}", projectProperties.keySet()); } else { LOGGER.debug("project property file does not exists. We continue!"); } Map<String, String> mergedProperties = propertiesLoader.mergeProperties(new HashMap(projectProperties)); ExtraPropertiesExtension extraProperties = new DslObject(project).getExtensions().getExtraProperties(); for (Map.Entry<String, String> entry: mergedProperties.entrySet()) { try { project.setProperty(entry.getKey(), entry.getValue()); } catch (MissingPropertyException e) { if (!entry.getKey().equals(e.getProperty())) { throw e; } // Ignore and define as an extra property extraProperties.set(entry.getKey(), entry.getValue()); } } }
Example 3
Source Project: pushfish-android Source File: GroovyBasePlugin.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) { project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() { public void execute(SourceSet sourceSet) { final DefaultGroovySourceSet groovySourceSet = new DefaultGroovySourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), fileResolver); new DslObject(sourceSet).getConvention().getPlugins().put("groovy", groovySourceSet); groovySourceSet.getGroovy().srcDir(String.format("src/%s/groovy", sourceSet.getName())); sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() { public boolean isSatisfiedBy(FileTreeElement element) { return groovySourceSet.getGroovy().contains(element.getFile()); } }); sourceSet.getAllJava().source(groovySourceSet.getGroovy()); sourceSet.getAllSource().source(groovySourceSet.getGroovy()); String compileTaskName = sourceSet.getCompileTaskName("groovy"); GroovyCompile compile = project.getTasks().create(compileTaskName, GroovyCompile.class); javaBasePlugin.configureForSourceSet(sourceSet, compile); compile.dependsOn(sourceSet.getCompileJavaTaskName()); compile.setDescription(String.format("Compiles the %s Groovy source.", sourceSet.getName())); compile.setSource(groovySourceSet.getGroovy()); project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName); } }); }
Example 4
Source Project: pushfish-android Source File: LegacyJavaComponentPlugin.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void createProcessResourcesTaskForBinary(final ClassDirectoryBinarySpecInternal binary, final Project target) { final BinaryNamingScheme namingScheme = binary.getNamingScheme(); binary.getSource().withType(JvmResourceSet.class).all(new Action<JvmResourceSet>() { public void execute(JvmResourceSet resourceSet) { Copy resourcesTask = target.getTasks().create(namingScheme.getTaskName("process", "resources"), ProcessResources.class); resourcesTask.setDescription(String.format("Processes %s.", resourceSet)); new DslObject(resourcesTask).getConventionMapping().map("destinationDir", new Callable<File>() { public File call() throws Exception { return binary.getResourcesDir(); } }); binary.getTasks().add(resourcesTask); binary.builtBy(resourcesTask); resourcesTask.from(resourceSet.getSource()); } }); }
Example 5
Source Project: pushfish-android Source File: JavaBasePlugin.java License: BSD 2-Clause "Simplified" License | 6 votes |
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 convention.getTestResultsDir(); } }); htmlReport.getConventionMapping().map("destination", new Callable<Object>() { public Object call() throws Exception { return convention.getTestReportDir(); } }); test.getConventionMapping().map("binResultsDir", new Callable<Object>() { public Object call() throws Exception { return new File(convention.getTestResultsDir(), String.format("binary/%s", test.getName())); } }); test.workingDir(project.getProjectDir()); }
Example 6
Source Project: pushfish-android Source File: MavenPublishTaskModelRule.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void createGeneratePomTask(final MavenPublicationInternal publication, String publicationName) { String descriptorTaskName = String.format("generatePomFileFor%sPublication", capitalize(publicationName)); GenerateMavenPom generatePomTask = project.getTasks().create(descriptorTaskName, GenerateMavenPom.class); generatePomTask.setDescription(String.format("Generates the Maven POM file for publication '%s'.", publication.getName())); generatePomTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); generatePomTask.setPom(publication.getPom()); ConventionMapping descriptorTaskConventionMapping = new DslObject(generatePomTask).getConventionMapping(); descriptorTaskConventionMapping.map("destination", new Callable<Object>() { public Object call() throws Exception { return new File(project.getBuildDir(), "publications/" + publication.getName() + "/pom-default.xml"); } }); // Wire the generated pom into the publication. publication.setPomFile(generatePomTask.getOutputs().getFiles()); }
Example 7
Source Project: pushfish-android Source File: ProjectPropertySettingBuildLoader.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void addPropertiesToProject(Project project) { Properties projectProperties = new Properties(); File projectPropertiesFile = new File(project.getProjectDir(), Project.GRADLE_PROPERTIES); LOGGER.debug("Looking for project properties from: {}", projectPropertiesFile); if (projectPropertiesFile.isFile()) { projectProperties = GUtil.loadProperties(projectPropertiesFile); LOGGER.debug("Adding project properties (if not overwritten by user properties): {}", projectProperties.keySet()); } else { LOGGER.debug("project property file does not exists. We continue!"); } Map<String, String> mergedProperties = propertiesLoader.mergeProperties(new HashMap(projectProperties)); ExtraPropertiesExtension extraProperties = new DslObject(project).getExtensions().getExtraProperties(); for (Map.Entry<String, String> entry: mergedProperties.entrySet()) { if (project.hasProperty(entry.getKey())) { project.setProperty(entry.getKey(), entry.getValue()); } else { extraProperties.set(entry.getKey(), entry.getValue()); } } }
Example 8
Source Project: pushfish-android Source File: GroovyBasePlugin.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) { project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() { public void execute(SourceSet sourceSet) { final DefaultGroovySourceSet groovySourceSet = new DefaultGroovySourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), fileResolver); new DslObject(sourceSet).getConvention().getPlugins().put("groovy", groovySourceSet); groovySourceSet.getGroovy().srcDir(String.format("src/%s/groovy", sourceSet.getName())); sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() { public boolean isSatisfiedBy(FileTreeElement element) { return groovySourceSet.getGroovy().contains(element.getFile()); } }); sourceSet.getAllJava().source(groovySourceSet.getGroovy()); sourceSet.getAllSource().source(groovySourceSet.getGroovy()); String compileTaskName = sourceSet.getCompileTaskName("groovy"); GroovyCompile compile = project.getTasks().create(compileTaskName, GroovyCompile.class); javaBasePlugin.configureForSourceSet(sourceSet, compile); compile.dependsOn(sourceSet.getCompileJavaTaskName()); compile.setDescription(String.format("Compiles the %s Groovy source.", sourceSet.getName())); compile.setSource(groovySourceSet.getGroovy()); project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName); } }); }
Example 9
Source Project: pushfish-android Source File: JavaBasePlugin.java License: BSD 2-Clause "Simplified" License | 6 votes |
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 convention.getTestResultsDir(); } }); htmlReport.getConventionMapping().map("destination", new Callable<Object>() { public Object call() throws Exception { return convention.getTestReportDir(); } }); test.getConventionMapping().map("binResultsDir", new Callable<Object>() { public Object call() throws Exception { return new File(convention.getTestResultsDir(), String.format("binary/%s", test.getName())); } }); test.workingDir(project.getProjectDir()); }
Example 10
Source Project: javaide Source File: JavaBasePlugin.java License: GNU General Public License v3.0 | 6 votes |
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()); }
Example 11
Source Project: gradle-plugins Source File: LombokPlugin.java License: MIT License | 6 votes |
private void configureForSpotbugs(JavaPluginConvention javaPluginConvention) { lombokBasePlugin.getLombokExtension().getConfig().put("lombok.extern.findbugs.addSuppressFBWarnings", "true"); project.afterEvaluate(p -> { Object spotbugsExtension = project.getExtensions().getByName("spotbugs"); String toolVersion; if (spotbugsExtension instanceof CodeQualityExtension) { toolVersion = ((CodeQualityExtension) spotbugsExtension).getToolVersion(); } else { Property<String> toolVersionProperty = (Property<String>) new DslObject(spotbugsExtension).getAsDynamicObject().getProperty("toolVersion"); toolVersion = toolVersionProperty.get(); } javaPluginConvention.getSourceSets().all(sourceSet -> project.getDependencies().add( sourceSet.getCompileOnlyConfigurationName(), "com.github.spotbugs:spotbugs-annotations:" + toolVersion )); }); }
Example 12
Source Project: gradle-plugins Source File: AspectJPlugin.java License: MIT License | 6 votes |
@Override public void apply(Project project) { this.project = project; project.getPlugins().apply(AspectJBasePlugin.class); project.getPlugins().apply(JavaBasePlugin.class); JavaPluginConvention plugin = project.getConvention().getPlugin(JavaPluginConvention.class); plugin.getSourceSets().all(this::configureSourceSet); project.getPlugins().withType(JavaPlugin.class, javaPlugin -> { SourceSet main = plugin.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); SourceSet test = plugin.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME); DefaultAspectjSourceSet mainAj = new DslObject(main).getConvention().getPlugin(DefaultAspectjSourceSet.class); DefaultAspectjSourceSet testAj = new DslObject(test).getConvention().getPlugin(DefaultAspectjSourceSet.class); Configuration aspectpath = project.getConfigurations().getByName(mainAj.getAspectConfigurationName()); Configuration testAspectpath = project.getConfigurations().getByName(testAj.getAspectConfigurationName()); testAspectpath.extendsFrom(aspectpath); testAj.setAspectPath(project.getObjects().fileCollection().from(main.getOutput(), testAspectpath)); }); }
Example 13
Source Project: gradle-plugins Source File: LombokPlugin.java License: MIT License | 6 votes |
private void configureForSpotbugs(JavaPluginConvention javaPluginConvention) { lombokBasePlugin.getLombokExtension().getConfig().put("lombok.extern.findbugs.addSuppressFBWarnings", "true"); project.afterEvaluate(p -> { Object spotbugsExtension = project.getExtensions().getByName("spotbugs"); String toolVersion; if (spotbugsExtension instanceof CodeQualityExtension) { toolVersion = ((CodeQualityExtension) spotbugsExtension).getToolVersion(); } else { Property<String> toolVersionProperty = (Property<String>) new DslObject(spotbugsExtension).getAsDynamicObject().getProperty("toolVersion"); toolVersion = toolVersionProperty.get(); } javaPluginConvention.getSourceSets().all(sourceSet -> project.getDependencies().add( sourceSet.getCompileOnlyConfigurationName(), "com.github.spotbugs:spotbugs-annotations:" + toolVersion )); }); }
Example 14
Source Project: gradle-plugins Source File: AspectJPlugin.java License: MIT License | 6 votes |
@Override public void apply(Project project) { this.project = project; project.getPlugins().apply(AspectJBasePlugin.class); project.getPlugins().apply(JavaBasePlugin.class); JavaPluginConvention plugin = project.getConvention().getPlugin(JavaPluginConvention.class); plugin.getSourceSets().all(this::configureSourceSet); project.getPlugins().withType(JavaPlugin.class, javaPlugin -> { SourceSet main = plugin.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); SourceSet test = plugin.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME); DefaultAspectjSourceSet mainAj = new DslObject(main).getConvention().getPlugin(DefaultAspectjSourceSet.class); DefaultAspectjSourceSet testAj = new DslObject(test).getConvention().getPlugin(DefaultAspectjSourceSet.class); Configuration aspectpath = project.getConfigurations().getByName(mainAj.getAspectConfigurationName()); Configuration testAspectpath = project.getConfigurations().getByName(testAj.getAspectConfigurationName()); testAspectpath.extendsFrom(aspectpath); testAj.setAspectPath(project.getObjects().fileCollection().from(main.getOutput(), testAspectpath)); }); }
Example 15
Source Project: Pushjet-Android Source File: MavenPublishPlugin.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void createGeneratePomTask(CollectionBuilder<Task> tasks, final MavenPublicationInternal publication, String publicationName) { String descriptorTaskName = String.format("generatePomFileFor%sPublication", capitalize(publicationName)); tasks.create(descriptorTaskName, GenerateMavenPom.class, new Action<GenerateMavenPom>() { public void execute(final GenerateMavenPom generatePomTask) { generatePomTask.setDescription(String.format("Generates the Maven POM file for publication '%s'.", publication.getName())); generatePomTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); generatePomTask.setPom(publication.getPom()); ConventionMapping descriptorTaskConventionMapping = new DslObject(generatePomTask).getConventionMapping(); descriptorTaskConventionMapping.map("destination", new Callable<Object>() { public Object call() throws Exception { return new File(generatePomTask.getProject().getBuildDir(), "publications/" + publication.getName() + "/pom-default.xml"); } }); // Wire the generated pom into the publication. publication.setPomFile(generatePomTask.getOutputs().getFiles()); } }); }
Example 16
Source Project: Pushjet-Android Source File: ProjectPropertySettingBuildLoader.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void addPropertiesToProject(Project project) { Properties projectProperties = new Properties(); File projectPropertiesFile = new File(project.getProjectDir(), Project.GRADLE_PROPERTIES); LOGGER.debug("Looking for project properties from: {}", projectPropertiesFile); if (projectPropertiesFile.isFile()) { projectProperties = GUtil.loadProperties(projectPropertiesFile); LOGGER.debug("Adding project properties (if not overwritten by user properties): {}", projectProperties.keySet()); } else { LOGGER.debug("project property file does not exists. We continue!"); } Map<String, String> mergedProperties = propertiesLoader.mergeProperties(new HashMap(projectProperties)); ExtraPropertiesExtension extraProperties = new DslObject(project).getExtensions().getExtraProperties(); for (Map.Entry<String, String> entry: mergedProperties.entrySet()) { try { project.setProperty(entry.getKey(), entry.getValue()); } catch (MissingPropertyException e) { if (!entry.getKey().equals(e.getProperty())) { throw e; } // Ignore and define as an extra property extraProperties.set(entry.getKey(), entry.getValue()); } } }
Example 17
Source Project: Pushjet-Android Source File: GroovyBasePlugin.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) { project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() { public void execute(SourceSet sourceSet) { final DefaultGroovySourceSet groovySourceSet = new DefaultGroovySourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), fileResolver); new DslObject(sourceSet).getConvention().getPlugins().put("groovy", groovySourceSet); groovySourceSet.getGroovy().srcDir(String.format("src/%s/groovy", sourceSet.getName())); sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() { public boolean isSatisfiedBy(FileTreeElement element) { return groovySourceSet.getGroovy().contains(element.getFile()); } }); sourceSet.getAllJava().source(groovySourceSet.getGroovy()); sourceSet.getAllSource().source(groovySourceSet.getGroovy()); String compileTaskName = sourceSet.getCompileTaskName("groovy"); GroovyCompile compile = project.getTasks().create(compileTaskName, GroovyCompile.class); javaBasePlugin.configureForSourceSet(sourceSet, compile); compile.dependsOn(sourceSet.getCompileJavaTaskName()); compile.setDescription(String.format("Compiles the %s Groovy source.", sourceSet.getName())); compile.setSource(groovySourceSet.getGroovy()); project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName); } }); }
Example 18
Source Project: Pushjet-Android Source File: LegacyJavaComponentPlugin.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void createProcessResourcesTaskForBinary(final ClassDirectoryBinarySpecInternal binary, final Project target) { final BinaryNamingScheme namingScheme = binary.getNamingScheme(); binary.getSource().withType(JvmResourceSet.class).all(new Action<JvmResourceSet>() { public void execute(JvmResourceSet resourceSet) { Copy resourcesTask = target.getTasks().create(namingScheme.getTaskName("process", "resources"), ProcessResources.class); resourcesTask.setDescription(String.format("Processes %s.", resourceSet)); new DslObject(resourcesTask).getConventionMapping().map("destinationDir", new Callable<File>() { public File call() throws Exception { return binary.getResourcesDir(); } }); binary.getTasks().add(resourcesTask); binary.builtBy(resourcesTask); resourcesTask.from(resourceSet.getSource()); } }); }
Example 19
Source Project: Pushjet-Android Source File: JavaBasePlugin.java License: BSD 2-Clause "Simplified" License | 6 votes |
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 convention.getTestResultsDir(); } }); htmlReport.getConventionMapping().map("destination", new Callable<Object>() { public Object call() throws Exception { return convention.getTestReportDir(); } }); test.getConventionMapping().map("binResultsDir", new Callable<Object>() { public Object call() throws Exception { return new File(convention.getTestResultsDir(), String.format("binary/%s", test.getName())); } }); test.workingDir(project.getProjectDir()); }
Example 20
Source Project: Pushjet-Android Source File: MavenPublishTaskModelRule.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void createGeneratePomTask(final MavenPublicationInternal publication, String publicationName) { String descriptorTaskName = String.format("generatePomFileFor%sPublication", capitalize(publicationName)); GenerateMavenPom generatePomTask = project.getTasks().create(descriptorTaskName, GenerateMavenPom.class); generatePomTask.setDescription(String.format("Generates the Maven POM file for publication '%s'.", publication.getName())); generatePomTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); generatePomTask.setPom(publication.getPom()); ConventionMapping descriptorTaskConventionMapping = new DslObject(generatePomTask).getConventionMapping(); descriptorTaskConventionMapping.map("destination", new Callable<Object>() { public Object call() throws Exception { return new File(project.getBuildDir(), "publications/" + publication.getName() + "/pom-default.xml"); } }); // Wire the generated pom into the publication. publication.setPomFile(generatePomTask.getOutputs().getFiles()); }
Example 21
Source Project: Pushjet-Android Source File: ProjectPropertySettingBuildLoader.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void addPropertiesToProject(Project project) { Properties projectProperties = new Properties(); File projectPropertiesFile = new File(project.getProjectDir(), Project.GRADLE_PROPERTIES); LOGGER.debug("Looking for project properties from: {}", projectPropertiesFile); if (projectPropertiesFile.isFile()) { projectProperties = GUtil.loadProperties(projectPropertiesFile); LOGGER.debug("Adding project properties (if not overwritten by user properties): {}", projectProperties.keySet()); } else { LOGGER.debug("project property file does not exists. We continue!"); } Map<String, String> mergedProperties = propertiesLoader.mergeProperties(new HashMap(projectProperties)); ExtraPropertiesExtension extraProperties = new DslObject(project).getExtensions().getExtraProperties(); for (Map.Entry<String, String> entry: mergedProperties.entrySet()) { if (project.hasProperty(entry.getKey())) { project.setProperty(entry.getKey(), entry.getValue()); } else { extraProperties.set(entry.getKey(), entry.getValue()); } } }
Example 22
Source Project: Pushjet-Android Source File: GroovyBasePlugin.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) { project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() { public void execute(SourceSet sourceSet) { final DefaultGroovySourceSet groovySourceSet = new DefaultGroovySourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), fileResolver); new DslObject(sourceSet).getConvention().getPlugins().put("groovy", groovySourceSet); groovySourceSet.getGroovy().srcDir(String.format("src/%s/groovy", sourceSet.getName())); sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() { public boolean isSatisfiedBy(FileTreeElement element) { return groovySourceSet.getGroovy().contains(element.getFile()); } }); sourceSet.getAllJava().source(groovySourceSet.getGroovy()); sourceSet.getAllSource().source(groovySourceSet.getGroovy()); String compileTaskName = sourceSet.getCompileTaskName("groovy"); GroovyCompile compile = project.getTasks().create(compileTaskName, GroovyCompile.class); javaBasePlugin.configureForSourceSet(sourceSet, compile); compile.dependsOn(sourceSet.getCompileJavaTaskName()); compile.setDescription(String.format("Compiles the %s Groovy source.", sourceSet.getName())); compile.setSource(groovySourceSet.getGroovy()); project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName); } }); }
Example 23
Source Project: Pushjet-Android Source File: JavaBasePlugin.java License: BSD 2-Clause "Simplified" License | 6 votes |
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 convention.getTestResultsDir(); } }); htmlReport.getConventionMapping().map("destination", new Callable<Object>() { public Object call() throws Exception { return convention.getTestReportDir(); } }); test.getConventionMapping().map("binResultsDir", new Callable<Object>() { public Object call() throws Exception { return new File(convention.getTestResultsDir(), String.format("binary/%s", test.getName())); } }); test.workingDir(project.getProjectDir()); }
Example 24
Source Project: pushfish-android Source File: BuildDashboardPlugin.java License: BSD 2-Clause "Simplified" License | 5 votes |
public void apply(final ProjectInternal project) { project.getPlugins().apply(ReportingBasePlugin.class); final GenerateBuildDashboard buildDashboardTask = project.getTasks().create(BUILD_DASHBOARD_TASK_NAME, GenerateBuildDashboard.class); buildDashboardTask.setDescription("Generates a dashboard of all the reports produced by this build."); buildDashboardTask.setGroup("reporting"); DirectoryReport htmlReport = buildDashboardTask.getReports().getHtml(); ConventionMapping htmlReportConventionMapping = new DslObject(htmlReport).getConventionMapping(); htmlReportConventionMapping.map("destination", new Callable<Object>() { public Object call() throws Exception { return project.getExtensions().getByType(ReportingExtension.class).file("buildDashboard"); } }); Action<Task> captureReportingTasks = new Action<Task>() { public void execute(Task task) { if (!(task instanceof Reporting)) { return; } Reporting reporting = (Reporting) task; buildDashboardTask.aggregate(reporting); if (!task.equals(buildDashboardTask)) { task.finalizedBy(buildDashboardTask); } } }; for (Project aProject : project.getAllprojects()) { aProject.getTasks().all(captureReportingTasks); } }
Example 25
Source Project: pushfish-android Source File: MavenPlugin.java License: BSD 2-Clause "Simplified" License | 5 votes |
private void configureUploadTasks(final DefaultDeployerFactory deployerFactory) { project.getTasks().withType(Upload.class, new Action<Upload>() { public void execute(Upload upload) { RepositoryHandler repositories = upload.getRepositories(); DefaultRepositoryHandler handler = (DefaultRepositoryHandler) repositories; DefaultMavenRepositoryHandlerConvention repositoryConvention = new DefaultMavenRepositoryHandlerConvention(handler, deployerFactory); new DslObject(repositories).getConvention().getPlugins().put("maven", repositoryConvention); } }); }
Example 26
Source Project: pushfish-android Source File: MavenPlugin.java License: BSD 2-Clause "Simplified" License | 5 votes |
private void configureInstall(Project project) { Upload installUpload = project.getTasks().create(INSTALL_TASK_NAME, Upload.class); Configuration configuration = project.getConfigurations().getByName(Dependency.ARCHIVES_CONFIGURATION); installUpload.setConfiguration(configuration); MavenRepositoryHandlerConvention repositories = new DslObject(installUpload.getRepositories()).getConvention().getPlugin(MavenRepositoryHandlerConvention.class); repositories.mavenInstaller(); installUpload.setDescription("Installs the 'archives' artifacts into the local Maven repository."); }
Example 27
Source Project: pushfish-android Source File: TaskDetailPrinter.java License: BSD 2-Clause "Simplified" License | 5 votes |
private Class getDeclaredTaskType(Task original) { Class clazz = new DslObject(original).getDeclaredType(); if (clazz.equals(DefaultTask.class)) { return org.gradle.api.Task.class; } else { return clazz; } }
Example 28
Source Project: pushfish-android Source File: IvyArtifactNotationParserFactory.java License: BSD 2-Clause "Simplified" License | 5 votes |
private DefaultIvyArtifact createDefaultIvyArtifact(File file, String extension, String type, String classifier) { DefaultIvyArtifact ivyArtifact = instantiator.newInstance( DefaultIvyArtifact.class, file, null, extension, type, classifier ); new DslObject(ivyArtifact).getConventionMapping().map("name", new Callable<String>() { public String call() throws Exception { return publicationIdentity.getModule(); } }); return ivyArtifact; }
Example 29
Source Project: pushfish-android Source File: TestNGTestFramework.java License: BSD 2-Clause "Simplified" License | 5 votes |
private static void conventionMapOutputDirectory(TestNGOptions options, final DirectoryReport html) { new DslObject(options).getConventionMapping().map("outputDirectory", new Callable<File>() { public File call() { return html.getDestination(); } }); }
Example 30
Source Project: pushfish-android Source File: GroovyPlugin.java License: BSD 2-Clause "Simplified" License | 5 votes |
private void configureGroovydoc(final Project project) { Groovydoc groovyDoc = project.getTasks().create(GROOVYDOC_TASK_NAME, Groovydoc.class); groovyDoc.setDescription("Generates Groovydoc API documentation for the main source code."); groovyDoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP); JavaPluginConvention convention = project.getConvention().getPlugin(JavaPluginConvention.class); SourceSet sourceSet = convention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); groovyDoc.setClasspath(sourceSet.getOutput().plus(sourceSet.getCompileClasspath())); GroovySourceSet groovySourceSet = new DslObject(sourceSet).getConvention().getPlugin(GroovySourceSet.class); groovyDoc.setSource(groovySourceSet.getGroovy()); }