org.gradle.api.internal.plugins.DslObject Java Examples
The following examples show how to use
org.gradle.api.internal.plugins.DslObject.
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 File: AspectJPlugin.java From gradle-plugins with MIT License | 7 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 #2
Source File: GroovyBasePlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 7 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 #3
Source File: JavaBasePlugin.java From Pushjet-Android with 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 #4
Source File: JavaBasePlugin.java From pushfish-android with 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 #5
Source File: MavenPublishTaskModelRule.java From pushfish-android with 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 #6
Source File: ProjectPropertySettingBuildLoader.java From pushfish-android with 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 #7
Source File: LegacyJavaComponentPlugin.java From pushfish-android with 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 #8
Source File: MavenPublishPlugin.java From pushfish-android with 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 #9
Source File: ProjectPropertySettingBuildLoader.java From pushfish-android with 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 #10
Source File: GroovyBasePlugin.java From pushfish-android with 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 #11
Source File: JavaBasePlugin.java From pushfish-android with 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 #12
Source File: JavaBasePlugin.java From javaide with 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 #13
Source File: AspectJPlugin.java From gradle-plugins with 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 #14
Source File: MavenPublishPlugin.java From Pushjet-Android with 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 #15
Source File: LombokPlugin.java From gradle-plugins with 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 #16
Source File: GroovyBasePlugin.java From Pushjet-Android with 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 #17
Source File: ProjectPropertySettingBuildLoader.java From Pushjet-Android with 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 #18
Source File: MavenPublishTaskModelRule.java From Pushjet-Android with 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 #19
Source File: JavaBasePlugin.java From Pushjet-Android with 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 File: LegacyJavaComponentPlugin.java From Pushjet-Android with 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 #21
Source File: GroovyBasePlugin.java From Pushjet-Android with 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 #22
Source File: ProjectPropertySettingBuildLoader.java From Pushjet-Android with 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 #23
Source File: LombokPlugin.java From gradle-plugins with 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 #24
Source File: IvyArtifactNotationParserFactory.java From pushfish-android with 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 #25
Source File: AspectJPlugin.java From gradle-plugins with MIT License | 5 votes |
private void configureSourceSet(SourceSet sourceSet) { DefaultAspectjSourceSet aspectjSourceSet = new DefaultAspectjSourceSet(project.getObjects(), sourceSet); new DslObject(sourceSet).getConvention().getPlugins().put("aspectj", aspectjSourceSet); aspectjSourceSet.getAspectj().srcDir("src/" + sourceSet.getName() + "/aspectj"); sourceSet.getResources().getFilter().exclude(element -> aspectjSourceSet.getAspectj().contains(element.getFile())); sourceSet.getAllJava().source(aspectjSourceSet.getAspectj()); sourceSet.getAllSource().source(aspectjSourceSet.getAspectj()); Configuration aspect = project.getConfigurations().create(aspectjSourceSet.getAspectConfigurationName()); aspectjSourceSet.setAspectPath(aspect); Configuration inpath = project.getConfigurations().create(aspectjSourceSet.getInpathConfigurationName()); aspectjSourceSet.setInPath(inpath); project.getConfigurations().getByName(sourceSet.getImplementationConfigurationName()).extendsFrom(aspect); project.getConfigurations().getByName(sourceSet.getCompileOnlyConfigurationName()).extendsFrom(inpath); final Provider<AspectjCompile> compileTask = project.getTasks().register(sourceSet.getCompileTaskName("aspectj"), AspectjCompile.class, compile -> { JvmPluginsHelper.configureForSourceSet(sourceSet, aspectjSourceSet.getAspectj(), compile, compile.getOptions(), project); compile.dependsOn(sourceSet.getCompileJavaTaskName()); compile.setDescription("Compiles the " + sourceSet.getName() + " AspectJ source."); compile.setSource(aspectjSourceSet.getAspectj()); compile.getAjcOptions().getAspectpath().from(aspectjSourceSet.getAspectPath()); compile.getAjcOptions().getInpath().from(aspectjSourceSet.getInPath()); }); JvmPluginsHelper.configureOutputDirectoryForSourceSet(sourceSet, aspectjSourceSet.getAspectj(), project, compileTask, compileTask.map(AspectjCompile::getOptions)); project.getTasks().named(sourceSet.getClassesTaskName(), task -> task.dependsOn(compileTask)); }
Example #26
Source File: GroovyPlugin.java From Pushjet-Android with 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()); }
Example #27
Source File: TestNGTestFramework.java From Pushjet-Android with 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 #28
Source File: IvyArtifactNotationParserFactory.java From Pushjet-Android with 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 File: JSassExtension.java From gradle-plugins with MIT License | 5 votes |
@Inject public JSassExtension(ObjectFactory objectFactory) { indent = objectFactory.property(String.class); indent.convention(" "); linefeed = objectFactory.property(String.class); linefeed.convention(System.lineSeparator()); omitSourceMapUrl = objectFactory.property(Boolean.class); omitSourceMapUrl.convention(false); outputStyle = objectFactory.property(OutputStyle.class); outputStyle.convention(OutputStyle.NESTED); precision = objectFactory.property(Integer.class); precision.convention(8); sourceComments = objectFactory.property(Boolean.class); sourceComments.convention(false); sourceMapContents = objectFactory.property(Boolean.class); sourceMapContents.convention(false); sourceMapEmbed = objectFactory.property(Boolean.class); sourceMapEmbed.convention(false); sourceMapEnabled = objectFactory.property(Boolean.class); sourceMapEnabled.convention(true); ExtraPropertiesExtension extraProperties = new DslObject(this).getExtensions().getExtraProperties(); for (OutputStyle value : OutputStyle.values()) { extraProperties.set(value.name(), value); } }
Example #30
Source File: MavenPlugin.java From pushfish-android with 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); } }); }