diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index d820e04..e2caeef 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,9 @@ # RELEASE NOTES +- 1.8 + + - Enabled use of the newer gradle "plugin id" syntax + - 1.7.0 - Upgrade to gradle 7 diff --git a/build.gradle b/build.gradle index 403d060..32e1fa5 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,9 @@ -// .\gradlew clean build publishToSonatype closeAndReleaseSonatypeStagingRepository -// use publishToMavenLocal to install to the local repo for testing +// RELEASNG ... +// place gradle.properties dir in c:\users\johnl\gradlerelease\ +// .\gradlew -g c:\users\johnl\gradlerelease clean build publishToSonatype closeAndReleaseSonatypeStagingRepository + +// TESTING LOCALLY - to install to the local repo for testing +// .\gradlew publishToMavenLocal // to see staged builds login and go to https://oss.sonatype.org/#stagingRepositories @@ -7,15 +11,16 @@ plugins { id("io.github.gradle-nexus.publish-plugin").version("1.0.0") id 'java-library' + id 'java-gradle-plugin' + id 'groovy' } -apply plugin: 'groovy' apply plugin: 'maven-publish' apply plugin: 'signing' group 'com.portingle' archivesBaseName = "classpath-hell" -version '1.7.0' +version '1.8' repositories { mavenCentral() @@ -83,7 +88,40 @@ task createPluginClasspath { } } +task runDemoPass(type: Exec) { + dependsOn(["publishToMavenLocal"]) + + workingDir 'demo/shouldPass' + commandLine 'cmd', '/c', '..\\..\\gradlew', 'clean', 'build', '-i' + doFirst { + println("EXEC PASSING DEMO") + } + doLast { + println("\nEXEC END") + } +} +task runDemoFail(type: Exec) { + dependsOn(["publishToMavenLocal"]) + + workingDir 'demo/shouldFail' + commandLine 'cmd', '/c', '..\\..\\gradlew', 'clean', 'build', '-i' + + ignoreExitValue true + + doFirst { + println("EXEC FAILING DEMO") + } + doLast { + if(executionResult.get().exitValue == 0) { + System.err.println("\nEXEC END - DID NOT GET THE EXPECTED FAILURE!!!") + throw new GradleException("demo at '" + workingDir + "' should have failed but did not fail !!!!!!!") + } + println("\nEXEC END - WITH EXPECTED FAILURE OF SCAN") + } +} + test.dependsOn(['createPluginClasspath']) +test.finalizedBy(['runDemoPass','runDemoFail']) // consider using the Gradle Nexus Staging Maven as this avoids need to use the NExus gui to close and release the stage artifact. // if the sonatypeUsername is provided by the gradle properties then a release is enabled @@ -101,8 +139,10 @@ if (project.properties.containsKey("sonatypeUsername")) { publishing { publications { - mavenJava(MavenPublication) { - from components.java + // Ues pluginMaven - https://github.com/gradle/gradle/issues/10384 + // To address... + // Multiple publications with coordinates 'com.portingle:classpath-hell:1.8' are published to repository 'mavenLocal'. The publications will overwrite each other! + pluginMaven(MavenPublication) { pom { name = 'classpath-hell' @@ -182,5 +222,16 @@ sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 +gradlePlugin { + // Define the plugin + plugins { + classpathHell { + id = 'com.portingle.classpath-hell' + implementationClass = 'classpathHell.ClasspathHellPlugin' + } + } +} + + diff --git a/demo/shouldFail/README.md b/demo/shouldFail/README.md index 939608a..f1408e3 100644 --- a/demo/shouldFail/README.md +++ b/demo/shouldFail/README.md @@ -1,5 +1,5 @@ -1. First do a `gradle install` of the main project to put the plugin jar into the local maven repo. +1. First do a `.\gradlew publishToMavenLocal` of the main project to put the plugin jar into the local maven repo. -2. Then run `gradle build` here. +2. Then run `..\..\gradlew clean build -i` here. The build should fail due to duplicate licence files and manifests only, as the build.gradle suppresses checks on classes and directories. \ No newline at end of file diff --git a/demo/shouldFail/build.gradle b/demo/shouldFail/build.gradle index 8e917d8..31c0fca 100644 --- a/demo/shouldFail/build.gradle +++ b/demo/shouldFail/build.gradle @@ -1,3 +1,4 @@ +// ADDITIONALLY THIS DEMO USES THE OLD STYLE GRADLE DEP apply plugin // expect failure from this build script because hamcrest-all contains hamcrest-core // so there are lots of dupe'd resources @@ -15,7 +16,7 @@ buildscript { } dependencies { - classpath "com.portingle:classpath-hell:1.7.0" + classpath "com.portingle:classpath-hell:1.8" } } diff --git a/demo/shouldPass/README.md b/demo/shouldPass/README.md new file mode 100644 index 0000000..0b87781 --- /dev/null +++ b/demo/shouldPass/README.md @@ -0,0 +1,5 @@ +1. First do a `.\gradlew publishToMavenLocal` of the main project to put the plugin jar into the local maven repo. + +2. Then run `..\..\gradlew clean build -i` here. + +The build should pass. \ No newline at end of file diff --git a/demo/shouldPass/build.gradle b/demo/shouldPass/build.gradle index e338f84..da8abc3 100644 --- a/demo/shouldPass/build.gradle +++ b/demo/shouldPass/build.gradle @@ -1,21 +1,31 @@ +// ADDITIONALLY THIS DEMO USES THE NEW STYLE GRADLE DEP plugin id + buildscript { - dependencies { - classpath 'com.portingle:classpath-hell:1.7.0' - } +// OLD STYLE DEP +// dependencies { +// classpath 'com.portingle:classpath-hell:1.8' +// } repositories { mavenLocal() - mavenCentral() + mavenCentral() } } +plugins { + // NEW STYLE DEP + id('com.portingle.classpath-hell').version("1.8") +} + repositories { - mavenCentral() + mavenCentral() } -apply plugin: 'com.portingle.classpathHell' apply plugin: 'java' +// OLD STYLE DEP +//apply plugin: 'com.portingle.classpathHell' + dependencies { implementation group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3' @@ -28,10 +38,10 @@ classpathHell { trace = true // only scan one configuration as this makes the test's verification easier - configurationsToScan = [ configurations.runtimeClasspath ] + configurationsToScan = [configurations.runtimeClasspath] // suppress a genuine dupe - one that is not an exact dupe - resourceExclusions = [ "META-INF/MANIFEST.MF" ] + resourceExclusions = ["META-INF/MANIFEST.MF"] // configure automatic resolution of "benign" dupes suppressExactDupes = true diff --git a/demo/shouldPass/settings.gradle b/demo/shouldPass/settings.gradle index edf3c82..0425b66 100644 --- a/demo/shouldPass/settings.gradle +++ b/demo/shouldPass/settings.gradle @@ -1,2 +1,8 @@ -rootProject.name = 'classpathHell-sample' +pluginManagement { + repositories { + mavenLocal() // allows picking local maven versions of classpath-hell + gradlePluginPortal() + } +} +rootProject.name = 'classpathHell-sample'