diff --git a/build.gradle b/build.gradle index d44fd94..2749c74 100644 --- a/build.gradle +++ b/build.gradle @@ -1,23 +1,22 @@ -import com.bancvue.gradle.maven.DefaultPublishFilter -import org.apache.ivy.core.module.descriptor.Artifact -import org.gradle.api.publication.maven.internal.PomFilter - buildscript { repositories { - mavenCentral() - maven { url "https://oss.sonatype.org/content/groups/public"} + jcenter() } dependencies { classpath 'com.github.townsfolk:gradle-release:1.2' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:0.5' } } + apply plugin: 'release' -apply plugin: "bancvue-oss" -apply plugin: "integration-test" +apply plugin: "com.bancvue.core-oss" +apply plugin: "com.bancvue.integration-test" +apply plugin: "com.bancvue.maven-publish-ext" +apply plugin: 'com.jfrog.bintray' repositories { - mavenCentral() + jcenter() } dependencies { @@ -27,7 +26,7 @@ dependencies { exclude group: 'com.google.guava' } - mainTestCompile('org.spockframework:spock-core:0.7-groovy-1.8') { + mainTestCompile('org.spockframework:spock-core:0.7-groovy-2.0') { exclude group: 'org.codehaus.groovy' } mainTestCompile 'cglib:cglib-nodep:2.2.2' @@ -47,55 +46,31 @@ license { [licenseMainTest, licenseFormatMainTest]*.exclude "org/gradle/testkit/**" - -/**********************************************************************************************************************/ -// Everything below is POC - -artifacts { - archives jarMainTest - archives sourcesJarMainTest -} - -uploadArchives { - repositories.mavenDeployer { - - pom.project { - packaging "jar" - url "https://github.com/BancVue/GradlePluginsCore" - developers { - developer { - id "bancvue_oss" - name "BancVue Open Source Development" - email "opensource@bancvue.com" - } - } - scm { - url "https://github.com/BancVue/GradlePluginsCore.git" - connection "scm:git:git@github.com:BancVue/GradlePluginsCore.git" - developerConnection "scm:git:git@github.com:BancVue/GradlePluginsCore.git" - } - } - } -} - -uploadArchives { - repositories.mavenDeployer { - addFilter("test") { Artifact artifact, file -> - (artifact.name =~ /.*-test$/).matches() - } - addFilter("default", new DefaultPublishFilter(it)) - - getActivePomFilters().each { PomFilter pomFilter -> - pomFilter.setPomTemplate(pom.effectivePom) - } - } +publishing_ext { + publication("mainTest") } -install { - repositories.mavenInstaller { - addFilter("test") { Artifact artifact, file -> - (artifact.name =~ /.*-test$/).matches() +bintray { + user = 'bancvue' + key = '--changeme--' + + publications = ['gradleCore', 'gradleCoreTest'] + dryRun = false + publish = false + pkg { + repo = 'maven' + userOrg = 'bancvue' + name = project.ext['artifactId'] + desc = project.description + websiteUrl = 'https://github.com/BancVue/gradle-core' + issueTrackerUrl = 'https://github.com/BancVue/gradle-core/issues' + vcsUrl = 'https://github.com/BancVue/gradle-core.git' + licenses = ['Apache-2.0'] + labels = ['gradle'] + publicDownloadNumbers = true + version { + vcsTag = project.version + attributes = ['gradle-plugin': 'com.bancvue.core-oss:com.bancvue:gradle-core'] } - addFilter("default", new DefaultPublishFilter(it)) } } diff --git a/gradle.properties b/gradle.properties index 6fb43e3..41d4e59 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ +group=com.bancvue artifactId=gradle-core version=0.20-SNAPSHOT description=Gradle plugins for general project development diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 23feeca..fb18b06 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-bin.zip +distributionUrl=http\://services.gradle.org/distributions/gradle-2.0-bin.zip diff --git a/src/integrationTest/groovy/com/bancvue/gradle/IdeExtPluginIntegrationSpecification.groovy b/src/integrationTest/groovy/com/bancvue/gradle/IdeExtPluginIntegrationSpecification.groovy index bf21c0c..a92213b 100644 --- a/src/integrationTest/groovy/com/bancvue/gradle/IdeExtPluginIntegrationSpecification.groovy +++ b/src/integrationTest/groovy/com/bancvue/gradle/IdeExtPluginIntegrationSpecification.groovy @@ -25,8 +25,8 @@ class IdeExtPluginIntegrationSpecification extends AbstractPluginIntegrationSpec given: buildFile << """ apply plugin: 'groovy' -apply plugin: 'ide-ext' -apply plugin: 'integration-test' +apply plugin: 'com.bancvue.ide-ext' +apply plugin: 'com.bancvue.integration-test' repositories { mavenCentral() @@ -96,8 +96,8 @@ dependencies { given: buildFile << """ apply plugin: 'groovy' -apply plugin: 'ide-ext' -apply plugin: 'component-test' +apply plugin: 'com.bancvue.ide-ext' +apply plugin: 'com.bancvue.component-test' repositories { mavenCentral() @@ -151,8 +151,8 @@ dependencies { given: buildFile << """ apply plugin: 'groovy' -apply plugin: 'ide-ext' -apply plugin: 'integration-test' +apply plugin: 'com.bancvue.ide-ext' +apply plugin: 'com.bancvue.integration-test' """ mkdir("src/main/resources") mkdir("src/test/resources") diff --git a/src/integrationTest/groovy/com/bancvue/gradle/custom/CustomGradlePluginIntegrationSpecification.groovy b/src/integrationTest/groovy/com/bancvue/gradle/custom/CustomGradlePluginIntegrationSpecification.groovy index ac6b23b..25e3d67 100644 --- a/src/integrationTest/groovy/com/bancvue/gradle/custom/CustomGradlePluginIntegrationSpecification.groovy +++ b/src/integrationTest/groovy/com/bancvue/gradle/custom/CustomGradlePluginIntegrationSpecification.groovy @@ -45,7 +45,7 @@ ext { repositoryReleaseUrl='${mavenRepo.toURI()}' } -apply plugin: 'custom-gradle' +apply plugin: 'com.bancvue.custom-gradle' // fake out the download and replace it with an empty zip task createDownloadArchive(type: Zip) { diff --git a/src/integrationTest/groovy/com/bancvue/gradle/license/LicenseExtPluginIntegrationSpecification.groovy b/src/integrationTest/groovy/com/bancvue/gradle/license/LicenseExtPluginIntegrationSpecification.groovy index 8a30849..553d026 100644 --- a/src/integrationTest/groovy/com/bancvue/gradle/license/LicenseExtPluginIntegrationSpecification.groovy +++ b/src/integrationTest/groovy/com/bancvue/gradle/license/LicenseExtPluginIntegrationSpecification.groovy @@ -37,8 +37,8 @@ ext { licenseName='BancVue' } -apply plugin: 'test-ext' -apply plugin: 'license-ext' +apply plugin: 'com.bancvue.test-ext' +apply plugin: 'com.bancvue.license-ext' """ when: @@ -58,7 +58,7 @@ apply plugin: 'license-ext' File srcFile = emptyClassFile('src/main/java/Class.java') buildFile << """ apply plugin: 'java' -apply plugin: 'license-ext' +apply plugin: 'com.bancvue.license-ext' license { ext.year='1975' @@ -85,7 +85,7 @@ ext { } apply plugin: 'java' -apply plugin: 'license-ext' +apply plugin: 'com.bancvue.license-ext' """ when: @@ -101,7 +101,7 @@ apply plugin: 'license-ext' File srcFile = emptyClassFile('src/main/java/Class.java') buildFile << """ apply plugin: 'java' -apply plugin: 'license-ext' +apply plugin: 'com.bancvue.license-ext' license { ignoreFailures true @@ -120,8 +120,8 @@ license { File srcFile = emptyClassFile('src/mainTest/java/Class.java') buildFile << """ apply plugin: 'java' -apply plugin: 'license-ext' -apply plugin: 'test-ext' +apply plugin: 'com.bancvue.license-ext' +apply plugin: 'com.bancvue.test-ext' license { ignoreFailures true diff --git a/src/integrationTest/groovy/com/bancvue/gradle/maven/MavenExtPluginIntegrationSpecification.groovy b/src/integrationTest/groovy/com/bancvue/gradle/maven/MavenExtPluginIntegrationSpecification.groovy index f917b1f..f3bb857 100644 --- a/src/integrationTest/groovy/com/bancvue/gradle/maven/MavenExtPluginIntegrationSpecification.groovy +++ b/src/integrationTest/groovy/com/bancvue/gradle/maven/MavenExtPluginIntegrationSpecification.groovy @@ -38,8 +38,8 @@ version = '1.0' given: emptyClassFile("src/main/java/Class.java") buildFile << """ -apply plugin: 'project-defaults' -apply plugin: 'maven-ext' +apply plugin: 'com.bancvue.project-defaults' +apply plugin: 'com.bancvue.maven-ext' """ when: @@ -55,7 +55,7 @@ apply plugin: 'maven-ext' def "should supportdeployer customizations in build file"() { given: buildFile << """ -apply plugin: 'maven-ext' +apply plugin: 'com.bancvue.maven-ext' project.uploadArchives { repositories.mavenDeployer { diff --git a/src/integrationTest/groovy/com/bancvue/gradle/maven/publish/MavenPublishExtPluginIntegrationSpecification.groovy b/src/integrationTest/groovy/com/bancvue/gradle/maven/publish/MavenPublishExtPluginIntegrationSpecification.groovy index 0e10744..78a87c0 100644 --- a/src/integrationTest/groovy/com/bancvue/gradle/maven/publish/MavenPublishExtPluginIntegrationSpecification.groovy +++ b/src/integrationTest/groovy/com/bancvue/gradle/maven/publish/MavenPublishExtPluginIntegrationSpecification.groovy @@ -33,8 +33,8 @@ class MavenPublishExtPluginIntegrationSpecification extends AbstractPluginIntegr ext.repositoryReleaseUrl='${mavenRepo.toURI()}' ext.artifactId='artifact' -apply plugin: 'maven-publish-ext' -apply plugin: 'project-defaults' // set jar baseName to artifactId +apply plugin: 'com.bancvue.maven-publish-ext' +apply plugin: 'com.bancvue.project-defaults' // set jar baseName to artifactId group = 'group' version = '1.0' @@ -84,7 +84,7 @@ version = '1.0' given: emptyClassFile("src/other/java/MainClass.java") buildFile << """ -apply plugin: 'maven-publish-ext' +apply plugin: 'com.bancvue.maven-publish-ext' publishing_ext { publication("main") { @@ -258,7 +258,7 @@ dependencies { emptyClassFile("src/mainTest/java/MainTestClass.java") setupLocalMavenRepoAndApplyPlugin() buildFile << """ -apply plugin: 'test-ext' +apply plugin: 'com.bancvue.test-ext' repositories { mavenCentral() diff --git a/src/integrationTest/groovy/com/bancvue/gradle/maven/publish/MavenPublishExtPluginMultiModuleIntegrationSpecification.groovy b/src/integrationTest/groovy/com/bancvue/gradle/maven/publish/MavenPublishExtPluginMultiModuleIntegrationSpecification.groovy index 69b677c..afa4775 100644 --- a/src/integrationTest/groovy/com/bancvue/gradle/maven/publish/MavenPublishExtPluginMultiModuleIntegrationSpecification.groovy +++ b/src/integrationTest/groovy/com/bancvue/gradle/maven/publish/MavenPublishExtPluginMultiModuleIntegrationSpecification.groovy @@ -33,7 +33,7 @@ class MavenPublishExtPluginMultiModuleIntegrationSpecification extends AbstractP private TestFile initMultiModuleBuildFile() { buildFile << """ -apply plugin: 'maven-publish-ext' +apply plugin: 'com.bancvue.maven-publish-ext' ext.artifactId='artifact' @@ -42,7 +42,7 @@ repositories { } allprojects { - apply plugin: 'project-defaults' // set jar baseName to artifactId + apply plugin: 'com.bancvue.project-defaults' // set jar baseName to artifactId ext.repositoryReleaseUrl='${mavenRepo.toURI()}' group = 'group' @@ -69,7 +69,7 @@ dependencies { } """ file("publishedDependency/build.gradle") << """ -apply plugin: 'maven-publish-ext' +apply plugin: 'com.bancvue.maven-publish-ext' """ when: @@ -89,7 +89,7 @@ apply plugin: 'maven-publish-ext' file("settings.gradle") << "include 'subModule', 'subModulePublishedDependency', 'subModuleLocalDependency'" initMultiModuleBuildFile() file("subModule/build.gradle") << """ -apply plugin: 'maven-publish-ext' +apply plugin: 'com.bancvue.maven-publish-ext' dependencies { compile project(":subModulePublishedDependency") @@ -97,7 +97,7 @@ dependencies { } """ file("subModulePublishedDependency/build.gradle") << """ -apply plugin: 'maven-publish-ext' +apply plugin: 'com.bancvue.maven-publish-ext' """ when: @@ -122,8 +122,8 @@ dependencies { } """ file("publishedDependency/build.gradle") << """ -apply plugin: 'test-ext' -apply plugin: 'maven-publish-ext' +apply plugin: 'com.bancvue.test-ext' +apply plugin: 'com.bancvue.maven-publish-ext' publishing_ext { publication("mainTest") diff --git a/src/integrationTest/groovy/com/bancvue/gradle/pmd/CpdPluginIntegrationSpecification.groovy b/src/integrationTest/groovy/com/bancvue/gradle/pmd/CpdPluginIntegrationSpecification.groovy index c19c76a..0f8582c 100644 --- a/src/integrationTest/groovy/com/bancvue/gradle/pmd/CpdPluginIntegrationSpecification.groovy +++ b/src/integrationTest/groovy/com/bancvue/gradle/pmd/CpdPluginIntegrationSpecification.groovy @@ -25,7 +25,7 @@ class CpdPluginIntegrationSpecification extends AbstractCpdPluginIntegrationSpec def setup() { buildFile << """ apply plugin: 'java' -apply plugin: 'cpd' +apply plugin: 'com.bancvue.cpd' repositories { mavenCentral() @@ -50,14 +50,14 @@ cpd { file("build/reports/cpd/all.html").exists() } - def "should enable sourceSet-specific tasks if createUnifiedReport set to false"() { + def "should enable sourceSet-specific tasks if createAllReport set to false"() { emptyClassFile("src/main/java/bv/SomeClass.java") classFileWithDuplicateTokens("src/mainTest/java/bv/MainTestClass.java", minTokenCount) buildFile << """ -apply plugin: 'test-ext' +apply plugin: 'com.bancvue.test-ext' cpd { - createUnifiedReport false + createAllReport false } """ @@ -70,10 +70,10 @@ cpd { file("build/reports/cpd/mainTest.html").exists() } - def "should not create unified report task if createUnifiedReport set to false"() { + def "should not create all report task if createAllReport set to false"() { buildFile << """ cpd { - createUnifiedReport false + createAllReport false } """ @@ -90,7 +90,7 @@ cpd { int halfMinTokenCount = (minTokenCount / 2) as int classFileWithDuplicateTokens("src/main/java/bv/SomeClass.java", halfMinTokenCount) buildFile << """ -apply plugin: 'test-ext' +apply plugin: 'com.bancvue.test-ext' """ when: diff --git a/src/integrationTest/groovy/com/bancvue/gradle/pmd/CpdPluginMultiProjectIntegrationSpecification.groovy b/src/integrationTest/groovy/com/bancvue/gradle/pmd/CpdPluginMultiProjectIntegrationSpecification.groovy index 8ca8553..13b6965 100644 --- a/src/integrationTest/groovy/com/bancvue/gradle/pmd/CpdPluginMultiProjectIntegrationSpecification.groovy +++ b/src/integrationTest/groovy/com/bancvue/gradle/pmd/CpdPluginMultiProjectIntegrationSpecification.groovy @@ -40,14 +40,14 @@ allprojects { emptyClassFile("src/main/java/bv/SomeClass.java") classFileWithDuplicateTokens("module/src/main/java/bv/ModuleClass.java", minTokenCount) buildFile << """ -apply plugin: 'cpd' +apply plugin: 'com.bancvue.cpd' cpd { minimumTokenCount ${minTokenCount} } allprojects { - apply plugin: 'cpd' + apply plugin: 'com.bancvue.cpd' } """ @@ -62,7 +62,7 @@ allprojects { def "should not fail if a project contains cpd violation but cpd plugin is not applied"() { given: buildFile << """ -apply plugin: 'cpd' +apply plugin: 'com.bancvue.cpd' cpd { minimumTokenCount ${minTokenCount} @@ -84,14 +84,14 @@ cpd { given: int halfMinTokenCount = (minTokenCount / 2) as int buildFile << """ -apply plugin: 'cpd' +apply plugin: 'com.bancvue.cpd' cpd { minimumTokenCount ${minTokenCount} } allprojects { - apply plugin: 'cpd' + apply plugin: 'com.bancvue.cpd' } """ @@ -117,15 +117,15 @@ allprojects { given: classFileWithDuplicateTokens("module/src/mainTest/java/bv/ModuleClass.java", minTokenCount) buildFile << """ -apply plugin: 'cpd' +apply plugin: 'com.bancvue.cpd' cpd { minimumTokenCount ${minTokenCount} } subprojects { - apply plugin: 'cpd' - apply plugin: 'test-ext' // creates the 'mainTest' source set + apply plugin: 'com.bancvue.cpd' + apply plugin: 'com.bancvue.test-ext' // creates the 'mainTest' source set } """ diff --git a/src/integrationTest/groovy/com/bancvue/gradle/test/ComponentTestPluginIntegrationSpecification.groovy b/src/integrationTest/groovy/com/bancvue/gradle/test/ComponentTestPluginIntegrationSpecification.groovy index 63c57be..37edf8c 100644 --- a/src/integrationTest/groovy/com/bancvue/gradle/test/ComponentTestPluginIntegrationSpecification.groovy +++ b/src/integrationTest/groovy/com/bancvue/gradle/test/ComponentTestPluginIntegrationSpecification.groovy @@ -35,7 +35,7 @@ class SomeTest { """ buildFile << """ apply plugin: 'groovy' -apply plugin: 'component-test' +apply plugin: 'com.bancvue.component-test' repositories { mavenCentral() diff --git a/src/integrationTest/groovy/com/bancvue/gradle/test/JacocoExtPluginIntegrationSpecification.groovy b/src/integrationTest/groovy/com/bancvue/gradle/test/JacocoExtPluginIntegrationSpecification.groovy index 46b1f89..b4995af 100644 --- a/src/integrationTest/groovy/com/bancvue/gradle/test/JacocoExtPluginIntegrationSpecification.groovy +++ b/src/integrationTest/groovy/com/bancvue/gradle/test/JacocoExtPluginIntegrationSpecification.groovy @@ -94,8 +94,8 @@ public class ${testName} { createSrcAndTestFiles(mainSrcFile, componentTestDir) buildFile << """ // NOTE: jacoco-ext is intentionally applied first to verify behavior when the build is modified after the plugin is applied -apply plugin: 'jacoco-ext' -apply plugin: 'component-test' +apply plugin: 'com.bancvue.jacoco-ext' +apply plugin: 'com.bancvue.component-test' """ when: @@ -117,9 +117,9 @@ apply plugin: 'component-test' createSrcAndTestFiles(mainSrcFile, testDir) createSrcAndTestFiles(mainTestSrcFile, componentTestDir) buildFile << """ -apply plugin: 'jacoco-ext' -apply plugin: 'test-ext' -apply plugin: 'component-test' +apply plugin: 'com.bancvue.jacoco-ext' +apply plugin: 'com.bancvue.test-ext' +apply plugin: 'com.bancvue.component-test' jacocoComponentTestReport { sourceSets sourceSets.main @@ -146,7 +146,7 @@ jacocoComponentTestReport { given: createSrcAndTestFiles(mainSrcFile, testDir) buildFile << """ -apply plugin: 'jacoco-ext' +apply plugin: 'com.bancvue.jacoco-ext' """ when: diff --git a/src/integrationTest/groovy/com/bancvue/gradle/test/JacocoExtPluginMultiModuleIntegrationSpecification.groovy b/src/integrationTest/groovy/com/bancvue/gradle/test/JacocoExtPluginMultiModuleIntegrationSpecification.groovy index d82e125..fb42004 100644 --- a/src/integrationTest/groovy/com/bancvue/gradle/test/JacocoExtPluginMultiModuleIntegrationSpecification.groovy +++ b/src/integrationTest/groovy/com/bancvue/gradle/test/JacocoExtPluginMultiModuleIntegrationSpecification.groovy @@ -21,7 +21,7 @@ class JacocoExtPluginMultiModuleIntegrationSpecification extends AbstractPluginI buildFile << """ allprojects { apply plugin: 'groovy' - apply plugin: 'jacoco-ext' + apply plugin: 'com.bancvue.jacoco-ext' repositories { mavenCentral() diff --git a/src/integrationTest/groovy/com/bancvue/gradle/test/TestExtPluginIntegrationSpecification.groovy b/src/integrationTest/groovy/com/bancvue/gradle/test/TestExtPluginIntegrationSpecification.groovy index a5d1e18..f96bb61 100644 --- a/src/integrationTest/groovy/com/bancvue/gradle/test/TestExtPluginIntegrationSpecification.groovy +++ b/src/integrationTest/groovy/com/bancvue/gradle/test/TestExtPluginIntegrationSpecification.groovy @@ -16,7 +16,7 @@ package com.bancvue.gradle.test import com.bancvue.zip.ZipArchive -import org.junit.Test +import org.gradle.testkit.functional.ExecutionResult class TestExtPluginIntegrationSpecification extends AbstractPluginIntegrationSpecification { @@ -25,7 +25,7 @@ class TestExtPluginIntegrationSpecification extends AbstractPluginIntegrationSpe emptyClassFile("src/mainTest/java/Class.java") buildFile << """ apply plugin: 'java' -apply plugin: 'test-ext' +apply plugin: 'com.bancvue.test-ext' jarMainTest.archiveName='mainTest.jar' """ @@ -50,7 +50,7 @@ public class Class {} """ buildFile << """ apply plugin: 'java' -apply plugin: 'test-ext' +apply plugin: 'com.bancvue.test-ext' javadocJarMainTest.archiveName='mainTestJavadoc.jar' """ @@ -65,4 +65,34 @@ javadocJarMainTest.archiveName='mainTestJavadoc.jar' mainTestJavadocJar.acquireContentForEntryWithNameLike("Class.html") } + def "styledTestOutput should print test progress"() { + given: + buildFile << """ +apply plugin: 'groovy' +apply plugin: 'com.bancvue.test-ext' + +repositories { + mavenCentral() +} + +dependencies { + testCompile 'org.spockframework:spock-core:0.7-groovy-2.0' +} +""" + file("src/test/groovy/SomeTest.groovy") << """ +class SomeTest extends spock.lang.Specification { + + def "styled test output test"() { + expect: + true + } +} +""" + when: + ExecutionResult result = run("test", "styledTestOutput") + + then: + result.standardOutput =~ /styled test output test/ + } + } diff --git a/src/main/groovy/com/bancvue/gradle/BancvueOssPlugin.groovy b/src/main/groovy/com/bancvue/gradle/CoreOssPlugin.groovy similarity index 86% rename from src/main/groovy/com/bancvue/gradle/BancvueOssPlugin.groovy rename to src/main/groovy/com/bancvue/gradle/CoreOssPlugin.groovy index c4e0044..660e781 100644 --- a/src/main/groovy/com/bancvue/gradle/BancvueOssPlugin.groovy +++ b/src/main/groovy/com/bancvue/gradle/CoreOssPlugin.groovy @@ -16,29 +16,25 @@ package com.bancvue.gradle import com.bancvue.gradle.license.LicenseExtPlugin -import com.bancvue.gradle.maven.MavenExtPlugin import com.bancvue.gradle.support.ProjectSupportPlugin import com.bancvue.gradle.test.ComponentTestPlugin import com.bancvue.gradle.test.JacocoExtPlugin import com.bancvue.gradle.test.TestExtPlugin -import org.gradle.api.GradleException import org.gradle.api.Plugin import org.gradle.api.Project -class BancvueOssPlugin implements Plugin { +class CoreOssPlugin implements Plugin { - static final String PLUGIN_NAME = 'bancvue-oss' + static final String PLUGIN_NAME = 'com.bancvue.core-oss' private Project project public void apply(Project project) { this.project = project - project.group = 'com.bancvue' applyJavaExtPlugin() applyGroovyPlugin() applyProjectDefaultsPlugin() applyLicenseExtPlugin() - applyMavenExtPlugin() applyTestExtPlugin() applyComponentTestPlugin() applyJacocoExtPlugin() @@ -62,10 +58,6 @@ class BancvueOssPlugin implements Plugin { project.apply(plugin: LicenseExtPlugin.PLUGIN_NAME) } - private void applyMavenExtPlugin() { - project.apply(plugin: MavenExtPlugin.PLUGIN_NAME) - } - private void applyTestExtPlugin() { project.apply(plugin: TestExtPlugin.PLUGIN_NAME) } diff --git a/src/main/groovy/com/bancvue/gradle/IdeExtPlugin.groovy b/src/main/groovy/com/bancvue/gradle/IdeExtPlugin.groovy index 7022587..ba84285 100644 --- a/src/main/groovy/com/bancvue/gradle/IdeExtPlugin.groovy +++ b/src/main/groovy/com/bancvue/gradle/IdeExtPlugin.groovy @@ -23,7 +23,7 @@ import org.gradle.api.tasks.SourceSet class IdeExtPlugin implements Plugin { - static final String PLUGIN_NAME = 'ide-ext' + static final String PLUGIN_NAME = 'com.bancvue.ide-ext' private static final String IDE_GROUP_NAME = 'IDE' diff --git a/src/main/groovy/com/bancvue/gradle/JavaExtPlugin.groovy b/src/main/groovy/com/bancvue/gradle/JavaExtPlugin.groovy index da2c222..6773c80 100644 --- a/src/main/groovy/com/bancvue/gradle/JavaExtPlugin.groovy +++ b/src/main/groovy/com/bancvue/gradle/JavaExtPlugin.groovy @@ -22,7 +22,7 @@ import org.gradle.api.tasks.javadoc.Javadoc public class JavaExtPlugin implements Plugin { - static final String PLUGIN_NAME = 'java-ext' + static final String PLUGIN_NAME = 'com.bancvue.java-ext' private Project project diff --git a/src/main/groovy/com/bancvue/gradle/ProjectDefaultsPlugin.groovy b/src/main/groovy/com/bancvue/gradle/ProjectDefaultsPlugin.groovy index 2429f55..913cbde 100644 --- a/src/main/groovy/com/bancvue/gradle/ProjectDefaultsPlugin.groovy +++ b/src/main/groovy/com/bancvue/gradle/ProjectDefaultsPlugin.groovy @@ -16,6 +16,8 @@ package com.bancvue.gradle import com.bancvue.gradle.categories.ProjectCategory +import java.text.DateFormat +import java.text.SimpleDateFormat import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.tasks.bundling.Jar @@ -26,7 +28,7 @@ import org.gradle.api.tasks.testing.Test class ProjectDefaultsPlugin implements Plugin { - static final String PLUGIN_NAME = 'project-defaults' + static final String PLUGIN_NAME = 'com.bancvue.project-defaults' private Project project private ProjectDefaultsProperties defaultsProperties @@ -99,11 +101,16 @@ class ProjectDefaultsPlugin implements Plugin { private void addBuildDateAndJdkToJarManifest() { project.tasks.withType(Jar) { Jar jar -> manifest { + attributes 'Build-Date': getDateAsString() attributes 'Build-Jdk': System.getProperty('java.version') } } } + private String getDateAsString() { + return DateFormat.getDateInstance(DateFormat.MEDIUM).format(new Date()) + } + private void setDefaultBaseNameForJarTasks() { project.tasks.withType(Jar) { Jar jar -> jar.conventionMapping.baseName = { getDefaultBaseNameForTask(jar) } diff --git a/src/main/groovy/com/bancvue/gradle/custom/CustomGradlePlugin.groovy b/src/main/groovy/com/bancvue/gradle/custom/CustomGradlePlugin.groovy index d6683ef..192b7d0 100644 --- a/src/main/groovy/com/bancvue/gradle/custom/CustomGradlePlugin.groovy +++ b/src/main/groovy/com/bancvue/gradle/custom/CustomGradlePlugin.groovy @@ -27,7 +27,7 @@ import org.gradle.api.tasks.wrapper.Wrapper class CustomGradlePlugin implements Plugin { - static final String PLUGIN_NAME = 'custom-gradle' + static final String PLUGIN_NAME = 'com.bancvue.custom-gradle' private Project project private CustomGradleProperties gradleProperties diff --git a/src/main/groovy/com/bancvue/gradle/license/LicenseExtPlugin.groovy b/src/main/groovy/com/bancvue/gradle/license/LicenseExtPlugin.groovy index 264a951..bfd953d 100644 --- a/src/main/groovy/com/bancvue/gradle/license/LicenseExtPlugin.groovy +++ b/src/main/groovy/com/bancvue/gradle/license/LicenseExtPlugin.groovy @@ -22,7 +22,7 @@ import org.gradle.api.Task class LicenseExtPlugin implements Plugin { - static final String PLUGIN_NAME = 'license-ext' + static final String PLUGIN_NAME = 'com.bancvue.license-ext' private static final String GROUP_NAME = 'License' private Project project diff --git a/src/main/groovy/com/bancvue/gradle/maven/MavenExtPlugin.groovy b/src/main/groovy/com/bancvue/gradle/maven/MavenExtPlugin.groovy index 69c9013..419df52 100644 --- a/src/main/groovy/com/bancvue/gradle/maven/MavenExtPlugin.groovy +++ b/src/main/groovy/com/bancvue/gradle/maven/MavenExtPlugin.groovy @@ -29,7 +29,7 @@ import org.gradle.api.plugins.BasePlugin @Slf4j class MavenExtPlugin implements Plugin { - static final String PLUGIN_NAME = 'maven-ext' + static final String PLUGIN_NAME = 'com.bancvue.maven-ext' private Project project private MavenRepositoryProperties repositoryProperties @@ -77,6 +77,7 @@ class MavenExtPlugin implements Plugin { private void addMavenLocalAndOrganizationArtifactRepository() { project.repositories.mavenLocal() + project.repositories { maven { name repositoryProperties.name diff --git a/src/main/groovy/com/bancvue/gradle/maven/MavenRepositoryProperties.groovy b/src/main/groovy/com/bancvue/gradle/maven/MavenRepositoryProperties.groovy index b904eb3..90eb589 100644 --- a/src/main/groovy/com/bancvue/gradle/maven/MavenRepositoryProperties.groovy +++ b/src/main/groovy/com/bancvue/gradle/maven/MavenRepositoryProperties.groovy @@ -23,7 +23,7 @@ class MavenRepositoryProperties extends DefaultProjectPropertyContainer { public static final String NAME = "repository" private static final String getDefaultUrlPropertyValue(String propertyName) { - "changeme:set-project-property-repository${propertyName.capitalize()}" + "http://set_project_property/repository${propertyName.capitalize()}" } private static class Props { diff --git a/src/main/groovy/com/bancvue/gradle/maven/publish/MavenPublishExtPlugin.groovy b/src/main/groovy/com/bancvue/gradle/maven/publish/MavenPublishExtPlugin.groovy index 99b93b1..994acc3 100644 --- a/src/main/groovy/com/bancvue/gradle/maven/publish/MavenPublishExtPlugin.groovy +++ b/src/main/groovy/com/bancvue/gradle/maven/publish/MavenPublishExtPlugin.groovy @@ -27,7 +27,7 @@ import org.gradle.api.Task @Mixin(GradlePluginMixin) class MavenPublishExtPlugin implements Plugin { - static final String PLUGIN_NAME = 'maven-publish-ext' + static final String PLUGIN_NAME = 'com.bancvue.maven-publish-ext' private Project project private MavenRepositoryProperties repositoryProperties diff --git a/src/main/groovy/com/bancvue/gradle/pmd/CpdExtension.groovy b/src/main/groovy/com/bancvue/gradle/pmd/CpdExtension.groovy index 3d4c8e1..8071fd9 100644 --- a/src/main/groovy/com/bancvue/gradle/pmd/CpdExtension.groovy +++ b/src/main/groovy/com/bancvue/gradle/pmd/CpdExtension.groovy @@ -34,8 +34,8 @@ class CpdExtension extends CodeQualityExtension { * other CPD tasks will be disabled. This task will operate on all java sources across any project * which applies the 'cpd' plugin. * NOTE: though the CPD plugin can be defined on any project within a multi-project build, this - * particular setting will only be recognized whne defined on the root project. + * particular setting will only be recognized when defined on the root project. */ - boolean createUnifiedReport = true + boolean createAllReport = true } \ No newline at end of file diff --git a/src/main/groovy/com/bancvue/gradle/pmd/CpdPlugin.groovy b/src/main/groovy/com/bancvue/gradle/pmd/CpdPlugin.groovy index 038cce5..db1b4f0 100644 --- a/src/main/groovy/com/bancvue/gradle/pmd/CpdPlugin.groovy +++ b/src/main/groovy/com/bancvue/gradle/pmd/CpdPlugin.groovy @@ -27,7 +27,7 @@ import org.gradle.api.tasks.SourceSet class CpdPlugin extends AbstractCodeQualityPlugin { - static final String PLUGIN_NAME = 'cpd' + static final String PLUGIN_NAME = 'com.bancvue.cpd' static final String UNIFIED_REPORT_TASK_NAME = "cpdAll" @@ -87,6 +87,10 @@ class CpdPlugin extends AbstractCodeQualityPlugin { cpdExtension } + private CpdExtension getCpdExtension() { + extension as CpdExtension + } + protected void createConfigurations() { super.createConfigurations() @@ -109,11 +113,11 @@ class CpdPlugin extends AbstractCodeQualityPlugin { protected void configureTaskDefaults(Cpd task, String baseName) { task.conventionMapping.with { cpdClasspath = { project.configurations['cpd'] } - cpdXsltPath = { extension.cpdXsltPath } - minimumTokenCount = { extension.minimumTokenCount } - ignoreLiterals = { extension.ignoreLiterals } - ignoreIdentifiers = { extension.ignoreIdentifiers } - ignoreFailures = { extension.ignoreFailures } + cpdXsltPath = { cpdExtension.cpdXsltPath } + minimumTokenCount = { cpdExtension.minimumTokenCount } + ignoreLiterals = { cpdExtension.ignoreLiterals } + ignoreIdentifiers = { cpdExtension.ignoreIdentifiers } + ignoreFailures = { cpdExtension.ignoreFailures } } task.reports.all { report -> @@ -137,7 +141,7 @@ class CpdPlugin extends AbstractCodeQualityPlugin { private boolean shouldCreateUnifiedReport() { CpdExtension extension = project.rootProject.extensions.getByName(CpdExtension.NAME) - extension.createUnifiedReport + extension.createAllReport } } diff --git a/src/main/groovy/com/bancvue/gradle/support/ClearArtifactCache.groovy b/src/main/groovy/com/bancvue/gradle/support/ClearArtifactCache.groovy index 81a7a3b..f12524e 100644 --- a/src/main/groovy/com/bancvue/gradle/support/ClearArtifactCache.groovy +++ b/src/main/groovy/com/bancvue/gradle/support/ClearArtifactCache.groovy @@ -77,9 +77,12 @@ class ClearArtifactCache extends DefaultTask { private static List collectGradleCacheArtifactDirs(File gradleUserHomeDir) { List dirs = [] - new File(gradleUserHomeDir, "caches").eachDir { File dir -> - appendCacheDirsFromArtifactsDir(dir, dirs) - appendCacheDirsFromModulesDir(dir, dirs) + File cachesDir = new File(gradleUserHomeDir, "caches") + if (cachesDir.exists()) { + cachesDir.eachDir { File dir -> + appendCacheDirsFromArtifactsDir(dir, dirs) + appendCacheDirsFromModulesDir(dir, dirs) + } } dirs } diff --git a/src/main/groovy/com/bancvue/gradle/support/ProjectSupportPlugin.groovy b/src/main/groovy/com/bancvue/gradle/support/ProjectSupportPlugin.groovy index 8bb4a0f..cb0fd6c 100644 --- a/src/main/groovy/com/bancvue/gradle/support/ProjectSupportPlugin.groovy +++ b/src/main/groovy/com/bancvue/gradle/support/ProjectSupportPlugin.groovy @@ -21,7 +21,7 @@ import org.gradle.api.Task class ProjectSupportPlugin implements Plugin { - static final String PLUGIN_NAME = 'project-support' + static final String PLUGIN_NAME = 'com.bancvue.project-support' private static final String TASK_GROUP_NAME = 'Utilities' diff --git a/src/main/groovy/com/bancvue/gradle/test/ComponentTestPlugin.groovy b/src/main/groovy/com/bancvue/gradle/test/ComponentTestPlugin.groovy index afd010b..3786e3d 100644 --- a/src/main/groovy/com/bancvue/gradle/test/ComponentTestPlugin.groovy +++ b/src/main/groovy/com/bancvue/gradle/test/ComponentTestPlugin.groovy @@ -19,7 +19,7 @@ import org.gradle.api.Task class ComponentTestPlugin extends NamedTestConfigurationPlugin { - static final String PLUGIN_NAME = 'component-test' + static final String PLUGIN_NAME = 'com.bancvue.component-test' public ComponentTestPlugin() { super('componentTest') diff --git a/src/main/groovy/com/bancvue/gradle/test/IntegrationTestPlugin.groovy b/src/main/groovy/com/bancvue/gradle/test/IntegrationTestPlugin.groovy index 0e99ed9..c729493 100644 --- a/src/main/groovy/com/bancvue/gradle/test/IntegrationTestPlugin.groovy +++ b/src/main/groovy/com/bancvue/gradle/test/IntegrationTestPlugin.groovy @@ -17,7 +17,7 @@ package com.bancvue.gradle.test class IntegrationTestPlugin extends NamedTestConfigurationPlugin { - static final String PLUGIN_NAME = 'integration-test' + static final String PLUGIN_NAME = 'com.bancvue.integration-test' IntegrationTestPlugin() { super('integrationTest') diff --git a/src/main/groovy/com/bancvue/gradle/test/JacocoExtPlugin.groovy b/src/main/groovy/com/bancvue/gradle/test/JacocoExtPlugin.groovy index 7a15905..b3169b2 100644 --- a/src/main/groovy/com/bancvue/gradle/test/JacocoExtPlugin.groovy +++ b/src/main/groovy/com/bancvue/gradle/test/JacocoExtPlugin.groovy @@ -26,7 +26,7 @@ import org.gradle.testing.jacoco.tasks.JacocoReport class JacocoExtPlugin implements Plugin { - static final String PLUGIN_NAME = "jacoco-ext" + static final String PLUGIN_NAME = "com.bancvue.jacoco-ext" private Project project diff --git a/src/main/groovy/com/bancvue/gradle/test/JacocoReportExt.groovy b/src/main/groovy/com/bancvue/gradle/test/JacocoReportExt.groovy index 638d61f..df75cd4 100644 --- a/src/main/groovy/com/bancvue/gradle/test/JacocoReportExt.groovy +++ b/src/main/groovy/com/bancvue/gradle/test/JacocoReportExt.groovy @@ -20,12 +20,9 @@ import org.gradle.api.Project import org.gradle.api.file.FileCollection import org.gradle.api.reporting.Report import org.gradle.api.tasks.SourceSet -import org.gradle.internal.reflect.Instantiator import org.gradle.testing.jacoco.plugins.JacocoPluginExtension import org.gradle.testing.jacoco.tasks.JacocoReport -import javax.inject.Inject - @Slf4j class JacocoReportExt extends JacocoReport { @@ -88,10 +85,7 @@ class JacocoReportExt extends JacocoReport { Set internalSourceSets = [] boolean includeSubProjects = false - @Inject - JacocoReportExt(Instantiator instantiator) { - super(instantiator) - + JacocoReportExt() { group = TestExtPlugin.VERIFICATION_GROUP_NAME getProject().afterEvaluate { ReportDirectoryCollector collector = new ReportDirectoryCollector(this) @@ -121,7 +115,7 @@ class JacocoReportExt extends JacocoReport { report.enabled = true report.conventionMapping.with { destination = { - getReportDestinationFile(jacocoReportsDir, report, reportCategory) + JacocoReportExt.getReportDestinationFile(jacocoReportsDir, report, reportCategory) } } } diff --git a/src/main/groovy/com/bancvue/gradle/test/StyledTestOutput.groovy b/src/main/groovy/com/bancvue/gradle/test/StyledTestOutput.groovy index 0a1a6e8..9571997 100644 --- a/src/main/groovy/com/bancvue/gradle/test/StyledTestOutput.groovy +++ b/src/main/groovy/com/bancvue/gradle/test/StyledTestOutput.groovy @@ -45,14 +45,14 @@ class StyledTestOutput extends DefaultTask { } test.afterTest { TestDescriptor descriptor, TestResult result -> - StyledTextOutput.Style style = getStyleForResult(result) + Style style = StyledTestOutput.getStyleForResult(result) out.withStyle(style).println(" ${descriptor.name}") } } } - private StyledTextOutput.Style getStyleForResult(TestResult result) { - StyledTextOutput.Style style = Style.Identifier + private static Style getStyleForResult(TestResult result) { + Style style = Style.Identifier if (result.failedTestCount > 0) { style = Style.Failure diff --git a/src/main/groovy/com/bancvue/gradle/test/TestExtPlugin.groovy b/src/main/groovy/com/bancvue/gradle/test/TestExtPlugin.groovy index 995cbb9..56161b3 100644 --- a/src/main/groovy/com/bancvue/gradle/test/TestExtPlugin.groovy +++ b/src/main/groovy/com/bancvue/gradle/test/TestExtPlugin.groovy @@ -28,7 +28,7 @@ import org.gradle.api.tasks.testing.Test @Mixin(GradlePluginMixin) class TestExtPlugin implements Plugin { - static final String PLUGIN_NAME = "test-ext" + static final String PLUGIN_NAME = "com.bancvue.test-ext" static final String VERIFICATION_GROUP_NAME = "Verification" diff --git a/src/main/resources/META-INF/gradle-plugins/bancvue-oss.properties b/src/main/resources/META-INF/gradle-plugins/bancvue-oss.properties deleted file mode 100644 index b448bb2..0000000 --- a/src/main/resources/META-INF/gradle-plugins/bancvue-oss.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=com.bancvue.gradle.BancvueOssPlugin \ No newline at end of file diff --git a/src/main/resources/META-INF/gradle-plugins/component-test.properties b/src/main/resources/META-INF/gradle-plugins/com.bancvue.component-test.properties similarity index 100% rename from src/main/resources/META-INF/gradle-plugins/component-test.properties rename to src/main/resources/META-INF/gradle-plugins/com.bancvue.component-test.properties diff --git a/src/main/resources/META-INF/gradle-plugins/com.bancvue.core-oss.properties b/src/main/resources/META-INF/gradle-plugins/com.bancvue.core-oss.properties new file mode 100644 index 0000000..ace37ab --- /dev/null +++ b/src/main/resources/META-INF/gradle-plugins/com.bancvue.core-oss.properties @@ -0,0 +1 @@ +implementation-class=com.bancvue.gradle.CoreOssPlugin \ No newline at end of file diff --git a/src/main/resources/META-INF/gradle-plugins/cpd.properties b/src/main/resources/META-INF/gradle-plugins/com.bancvue.cpd.properties similarity index 100% rename from src/main/resources/META-INF/gradle-plugins/cpd.properties rename to src/main/resources/META-INF/gradle-plugins/com.bancvue.cpd.properties diff --git a/src/main/resources/META-INF/gradle-plugins/custom-gradle.properties b/src/main/resources/META-INF/gradle-plugins/com.bancvue.custom-gradle.properties similarity index 100% rename from src/main/resources/META-INF/gradle-plugins/custom-gradle.properties rename to src/main/resources/META-INF/gradle-plugins/com.bancvue.custom-gradle.properties diff --git a/src/main/resources/META-INF/gradle-plugins/ide-ext.properties b/src/main/resources/META-INF/gradle-plugins/com.bancvue.ide-ext.properties similarity index 100% rename from src/main/resources/META-INF/gradle-plugins/ide-ext.properties rename to src/main/resources/META-INF/gradle-plugins/com.bancvue.ide-ext.properties diff --git a/src/main/resources/META-INF/gradle-plugins/integration-test.properties b/src/main/resources/META-INF/gradle-plugins/com.bancvue.integration-test.properties similarity index 100% rename from src/main/resources/META-INF/gradle-plugins/integration-test.properties rename to src/main/resources/META-INF/gradle-plugins/com.bancvue.integration-test.properties diff --git a/src/main/resources/META-INF/gradle-plugins/jacoco-ext.properties b/src/main/resources/META-INF/gradle-plugins/com.bancvue.jacoco-ext.properties similarity index 100% rename from src/main/resources/META-INF/gradle-plugins/jacoco-ext.properties rename to src/main/resources/META-INF/gradle-plugins/com.bancvue.jacoco-ext.properties diff --git a/src/main/resources/META-INF/gradle-plugins/java-ext.properties b/src/main/resources/META-INF/gradle-plugins/com.bancvue.java-ext.properties similarity index 100% rename from src/main/resources/META-INF/gradle-plugins/java-ext.properties rename to src/main/resources/META-INF/gradle-plugins/com.bancvue.java-ext.properties diff --git a/src/main/resources/META-INF/gradle-plugins/license-ext.properties b/src/main/resources/META-INF/gradle-plugins/com.bancvue.license-ext.properties similarity index 100% rename from src/main/resources/META-INF/gradle-plugins/license-ext.properties rename to src/main/resources/META-INF/gradle-plugins/com.bancvue.license-ext.properties diff --git a/src/main/resources/META-INF/gradle-plugins/maven-ext.properties b/src/main/resources/META-INF/gradle-plugins/com.bancvue.maven-ext.properties similarity index 100% rename from src/main/resources/META-INF/gradle-plugins/maven-ext.properties rename to src/main/resources/META-INF/gradle-plugins/com.bancvue.maven-ext.properties diff --git a/src/main/resources/META-INF/gradle-plugins/maven-publish-ext.properties b/src/main/resources/META-INF/gradle-plugins/com.bancvue.maven-publish-ext.properties similarity index 100% rename from src/main/resources/META-INF/gradle-plugins/maven-publish-ext.properties rename to src/main/resources/META-INF/gradle-plugins/com.bancvue.maven-publish-ext.properties diff --git a/src/main/resources/META-INF/gradle-plugins/project-defaults.properties b/src/main/resources/META-INF/gradle-plugins/com.bancvue.project-defaults.properties similarity index 100% rename from src/main/resources/META-INF/gradle-plugins/project-defaults.properties rename to src/main/resources/META-INF/gradle-plugins/com.bancvue.project-defaults.properties diff --git a/src/main/resources/META-INF/gradle-plugins/project-support.properties b/src/main/resources/META-INF/gradle-plugins/com.bancvue.project-support.properties similarity index 100% rename from src/main/resources/META-INF/gradle-plugins/project-support.properties rename to src/main/resources/META-INF/gradle-plugins/com.bancvue.project-support.properties diff --git a/src/main/resources/META-INF/gradle-plugins/test-ext.properties b/src/main/resources/META-INF/gradle-plugins/com.bancvue.test-ext.properties similarity index 100% rename from src/main/resources/META-INF/gradle-plugins/test-ext.properties rename to src/main/resources/META-INF/gradle-plugins/com.bancvue.test-ext.properties diff --git a/src/main/resources/pmd/cpdhtml.xslt b/src/main/resources/pmd/cpdhtml.xslt index c4638d7..a8d5785 100644 --- a/src/main/resources/pmd/cpdhtml.xslt +++ b/src/main/resources/pmd/cpdhtml.xslt @@ -1,4 +1,5 @@ +