From 5a9ff8942bc2ac7c70d5d88895b7d4bc3cc9639e Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Wed, 18 Dec 2024 15:32:54 -0500 Subject: [PATCH 01/14] Add test projects for functional testing of the grails publish plugin --- .../build.gradle | 42 +++++++++++++++++ .../gradle.properties | 2 + .../settings.gradle | 5 ++ .../org/grails/example/SubProject1.groovy | 7 +++ .../org/grails/example/SubProject2.groovy | 7 +++ .../build.gradle | 46 +++++++++++++++++++ .../gradle.properties | 2 + .../settings.gradle | 4 ++ .../org/grails/example/SubProject1.groovy | 7 +++ .../org.grails.example/SubProject2.groovy | 7 +++ .../build.gradle | 33 +++++++++++++ .../gradle.properties | 2 + .../settings.gradle | 3 ++ .../org/grails/example/SubProject1.groovy | 7 +++ .../subproject2/build.gradle | 16 +++++++ .../org.grails.example/SubProject2.groovy | 7 +++ .../build.gradle | 40 ++++++++++++++++ .../gradle.properties | 2 + .../settings.gradle | 3 ++ .../org/grails/example/SubProject1.groovy | 7 +++ .../subproject2/build.gradle | 3 ++ .../org.grails.example/SubProject2.groovy | 7 +++ .../build.gradle | 26 +++++++++++ .../gradle.properties | 2 + .../settings.gradle | 4 ++ .../subproject1/build.gradle | 5 ++ .../org/grails/example/SubProject1.groovy | 7 +++ .../subproject2/build.gradle | 16 +++++++ .../org.grails.example/SubProject2.groovy | 7 +++ .../build.gradle | 32 +++++++++++++ .../gradle.properties | 2 + .../settings.gradle | 3 ++ .../org/grails/example/SubProject1.groovy | 7 +++ .../subproject2/build.gradle | 21 +++++++++ .../org.grails.example/SubProject2.groovy | 7 +++ .../build.gradle | 43 +++++++++++++++++ .../gradle.properties | 2 + .../settings.gradle | 3 ++ .../org/grails/example/SubProject1.groovy | 7 +++ .../subproject2/build.gradle | 8 ++++ .../org.grails.example/SubProject2.groovy | 7 +++ .../build.gradle | 23 ++++++++++ .../gradle.properties | 2 + .../settings.gradle | 4 ++ .../subproject1/build.gradle | 10 ++++ .../org/grails/example/SubProject1.groovy | 7 +++ .../subproject2/build.gradle | 21 +++++++++ .../org.grails.example/SubProject2.groovy | 7 +++ 48 files changed, 542 insertions(+) create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/build.gradle create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/gradle.properties create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/settings.gradle create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/subproject2/src/main/groovy/org/grails/example/SubProject2.groovy create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/build.gradle create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/gradle.properties create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/settings.gradle create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/build.gradle create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/gradle.properties create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/settings.gradle create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/src/main/groovy/org/grails/example/SubProject1.groovy create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/subproject2/build.gradle create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/build.gradle create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/gradle.properties create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/settings.gradle create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/src/main/groovy/org/grails/example/SubProject1.groovy create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/subproject2/build.gradle create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/build.gradle create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/gradle.properties create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/settings.gradle create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject1/build.gradle create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject2/build.gradle create mode 100644 src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy create mode 100644 src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/build.gradle create mode 100644 src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/gradle.properties create mode 100644 src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/settings.gradle create mode 100644 src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/src/main/groovy/org/grails/example/SubProject1.groovy create mode 100644 src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/subproject2/build.gradle create mode 100644 src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy create mode 100644 src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/build.gradle create mode 100644 src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/gradle.properties create mode 100644 src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/settings.gradle create mode 100644 src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/src/main/groovy/org/grails/example/SubProject1.groovy create mode 100644 src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/subproject2/build.gradle create mode 100644 src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy create mode 100644 src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/build.gradle create mode 100644 src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/gradle.properties create mode 100644 src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/settings.gradle create mode 100644 src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject1/build.gradle create mode 100644 src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy create mode 100644 src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject2/build.gradle create mode 100644 src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/build.gradle b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/build.gradle new file mode 100644 index 00000000..64862b53 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/build.gradle @@ -0,0 +1,42 @@ +buildscript { + repositories { + maven { url "${System.getenv('LOCAL_MAVEN_PATH')}" } + maven { url = 'https://repo.grails.org/grails/core' } + } + dependencies { + classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" + } +} + +version "${projectVersion}" +group "org.grails.example" + +subprojects { project -> + version "${projectVersion}" + group "org.grails.example" + + apply plugin: 'java-library' + apply plugin: 'groovy' + + repositories { + maven { url = 'https://repo.grails.org/grails/core' } + } + + dependencies { + implementation 'org.apache.groovy:groovy-all:4.0.24' + } + + apply plugin: 'org.grails.grails-publish' + grailsPublish { + githubSlug = 'grails/grails-gradle-plugin' + license { + name = 'Apache-2.0' + } + title = 'Grails Gradle Plugin - Example Project' + desc = 'A testing project for the grails gradle plugin' + developers = [ + jdaugherty: 'James Daugherty', + ] + } +} + diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/gradle.properties b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/gradle.properties new file mode 100644 index 00000000..1fe1bde7 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/gradle.properties @@ -0,0 +1,2 @@ +projectVersion=0.0.1-SNAPSHOT +grailsGradlePluginVersion=7.0.0-SNAPSHOT \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/settings.gradle b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/settings.gradle new file mode 100644 index 00000000..bab4066a --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/settings.gradle @@ -0,0 +1,5 @@ +rootProject.name = 'multi-project-no-subproject-build-gradle-root' + +include 'subproject1' +include 'subproject2' + diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy new file mode 100644 index 00000000..54df8e20 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject1 { + def sayHello() { + println "Hello from SubProject1" + } +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/subproject2/src/main/groovy/org/grails/example/SubProject2.groovy b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/subproject2/src/main/groovy/org/grails/example/SubProject2.groovy new file mode 100644 index 00000000..56750d0a --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/subproject2/src/main/groovy/org/grails/example/SubProject2.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject2 { + def sayHello() { + println "Hello from SubProject2" + } +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/build.gradle b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/build.gradle new file mode 100644 index 00000000..f2591427 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/build.gradle @@ -0,0 +1,46 @@ +buildscript { + repositories { + maven { url "${System.getenv('LOCAL_MAVEN_PATH')}" } + maven { url = 'https://repo.grails.org/grails/core' } + } + dependencies { + classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" + } +} + +version "${projectVersion}" +group "org.grails.example" + +subprojects { project -> + version "${projectVersion}" + group "org.grails.example" + + apply plugin: 'java-library' + apply plugin: 'groovy' + + repositories { + maven { url = 'https://repo.grails.org/grails/core' } + } + + dependencies { + implementation 'org.apache.groovy:groovy-all:4.0.24' + } + + if(project.name == "subproject1") { + apply plugin: 'org.grails.grails-publish' + grailsPublish { + githubSlug = 'grails/grails-gradle-plugin' + license { + name = 'Apache-2.0' + } + title = 'Grails Gradle Plugin - Example Project' + desc = 'A testing project for the grails gradle plugin' + developers = [ + jdaugherty: 'James Daugherty', + ] + } + } + else { + logger.lifecycle("Not applying grails-publish plugin to project `${project.name}`") + } +} diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/gradle.properties b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/gradle.properties new file mode 100644 index 00000000..1fe1bde7 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/gradle.properties @@ -0,0 +1,2 @@ +projectVersion=0.0.1-SNAPSHOT +grailsGradlePluginVersion=7.0.0-SNAPSHOT \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/settings.gradle b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/settings.gradle new file mode 100644 index 00000000..b63f52a9 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/settings.gradle @@ -0,0 +1,4 @@ +rootProject.name = 'multi-project-no-subproject-build-gradle-root' + +include 'subproject1' +include 'subproject2' \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy new file mode 100644 index 00000000..54df8e20 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject1 { + def sayHello() { + println "Hello from SubProject1" + } +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy new file mode 100644 index 00000000..56750d0a --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject2 { + def sayHello() { + println "Hello from SubProject2" + } +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/build.gradle b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/build.gradle new file mode 100644 index 00000000..6eb2a839 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/build.gradle @@ -0,0 +1,33 @@ +buildscript { + repositories { + maven { url "${System.getenv('LOCAL_MAVEN_PATH')}" } + maven { url = 'https://repo.grails.org/grails/core' } + } + dependencies { + classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" + } +} + +allprojects { + repositories { + maven { url = 'https://repo.grails.org/grails/core' } + } +} + +version "${projectVersion}" +group "org.grails.example" + +apply plugin: 'java-library' +apply plugin: 'groovy' + +dependencies { + implementation 'org.apache.groovy:groovy-all:4.0.24' +} + +subprojects { project -> + version "${projectVersion}" + group "org.grails.example" + + apply plugin: 'java-library' + apply plugin: 'groovy' +} diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/gradle.properties b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/gradle.properties new file mode 100644 index 00000000..1fe1bde7 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/gradle.properties @@ -0,0 +1,2 @@ +projectVersion=0.0.1-SNAPSHOT +grailsGradlePluginVersion=7.0.0-SNAPSHOT \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/settings.gradle b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/settings.gradle new file mode 100644 index 00000000..1dba1309 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/settings.gradle @@ -0,0 +1,3 @@ +rootProject.name = 'subproject1' + +include 'subproject2' \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/src/main/groovy/org/grails/example/SubProject1.groovy b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/src/main/groovy/org/grails/example/SubProject1.groovy new file mode 100644 index 00000000..54df8e20 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/src/main/groovy/org/grails/example/SubProject1.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject1 { + def sayHello() { + println "Hello from SubProject1" + } +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/subproject2/build.gradle b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/subproject2/build.gradle new file mode 100644 index 00000000..2c83d130 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/subproject2/build.gradle @@ -0,0 +1,16 @@ +dependencies { + implementation 'org.apache.groovy:groovy-all:4.0.24' +} + +apply plugin: 'org.grails.grails-publish' +grailsPublish { + githubSlug = 'grails/grails-gradle-plugin' + license { + name = 'Apache-2.0' + } + title = 'Grails Gradle Plugin - Example Project' + desc = 'A testing project for the grails gradle plugin' + developers = [ + jdaugherty: 'James Daugherty', + ] +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy new file mode 100644 index 00000000..56750d0a --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject2 { + def sayHello() { + println "Hello from SubProject2" + } +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/build.gradle b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/build.gradle new file mode 100644 index 00000000..8e1e318e --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/build.gradle @@ -0,0 +1,40 @@ +buildscript { + repositories { + maven { url "${System.getenv('LOCAL_MAVEN_PATH')}" } + maven { url = 'https://repo.grails.org/grails/core' } + } + dependencies { + classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" + } +} + +allprojects { + repositories { + maven { url = 'https://repo.grails.org/grails/core' } + } + + version "${projectVersion}" + group "org.grails.example" + + apply plugin: 'java-library' + apply plugin: 'groovy' + + dependencies { + implementation 'org.apache.groovy:groovy-all:4.0.24' + } +} + + + +apply plugin: 'org.grails.grails-publish' +grailsPublish { + githubSlug = 'grails/grails-gradle-plugin' + license { + name = 'Apache-2.0' + } + title = 'Grails Gradle Plugin - Example Project' + desc = 'A testing project for the grails gradle plugin' + developers = [ + jdaugherty: 'James Daugherty', + ] +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/gradle.properties b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/gradle.properties new file mode 100644 index 00000000..1fe1bde7 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/gradle.properties @@ -0,0 +1,2 @@ +projectVersion=0.0.1-SNAPSHOT +grailsGradlePluginVersion=7.0.0-SNAPSHOT \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/settings.gradle b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/settings.gradle new file mode 100644 index 00000000..1dba1309 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/settings.gradle @@ -0,0 +1,3 @@ +rootProject.name = 'subproject1' + +include 'subproject2' \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/src/main/groovy/org/grails/example/SubProject1.groovy b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/src/main/groovy/org/grails/example/SubProject1.groovy new file mode 100644 index 00000000..54df8e20 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/src/main/groovy/org/grails/example/SubProject1.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject1 { + def sayHello() { + println "Hello from SubProject1" + } +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/subproject2/build.gradle b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/subproject2/build.gradle new file mode 100644 index 00000000..f8fec106 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/subproject2/build.gradle @@ -0,0 +1,3 @@ +dependencies { + implementation 'org.apache.groovy:groovy-all:4.0.24' +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy new file mode 100644 index 00000000..56750d0a --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject2 { + def sayHello() { + println "Hello from SubProject2" + } +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/build.gradle b/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/build.gradle new file mode 100644 index 00000000..5e88b447 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/build.gradle @@ -0,0 +1,26 @@ +buildscript { + repositories { + maven { url "${System.getenv('LOCAL_MAVEN_PATH')}" } + maven { url = 'https://repo.grails.org/grails/core' } + } + dependencies { + classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" + } +} + +allprojects { + repositories { + maven { url = 'https://repo.grails.org/grails/core' } + } +} + +version "${projectVersion}" +group "org.grails.example" + +subprojects { project -> + apply plugin: 'java-library' + apply plugin: 'groovy' + + version "${projectVersion}" + group "org.grails.example" +} diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/gradle.properties b/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/gradle.properties new file mode 100644 index 00000000..1fe1bde7 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/gradle.properties @@ -0,0 +1,2 @@ +projectVersion=0.0.1-SNAPSHOT +grailsGradlePluginVersion=7.0.0-SNAPSHOT \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/settings.gradle b/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/settings.gradle new file mode 100644 index 00000000..b63f52a9 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/settings.gradle @@ -0,0 +1,4 @@ +rootProject.name = 'multi-project-no-subproject-build-gradle-root' + +include 'subproject1' +include 'subproject2' \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject1/build.gradle b/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject1/build.gradle new file mode 100644 index 00000000..999c2ec5 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject1/build.gradle @@ -0,0 +1,5 @@ +dependencies { + implementation 'org.apache.groovy:groovy-all:4.0.24' +} + +logger.lifecycle("Not applying grails-publish plugin to project `${project.name}`") \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy b/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy new file mode 100644 index 00000000..54df8e20 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject1 { + def sayHello() { + println "Hello from SubProject1" + } +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject2/build.gradle b/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject2/build.gradle new file mode 100644 index 00000000..2c83d130 --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject2/build.gradle @@ -0,0 +1,16 @@ +dependencies { + implementation 'org.apache.groovy:groovy-all:4.0.24' +} + +apply plugin: 'org.grails.grails-publish' +grailsPublish { + githubSlug = 'grails/grails-gradle-plugin' + license { + name = 'Apache-2.0' + } + title = 'Grails Gradle Plugin - Example Project' + desc = 'A testing project for the grails gradle plugin' + developers = [ + jdaugherty: 'James Daugherty', + ] +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy b/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy new file mode 100644 index 00000000..56750d0a --- /dev/null +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject2 { + def sayHello() { + println "Hello from SubProject2" + } +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/build.gradle b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/build.gradle new file mode 100644 index 00000000..f915a48a --- /dev/null +++ b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/build.gradle @@ -0,0 +1,32 @@ +buildscript { + repositories { + maven { url "${System.getenv('LOCAL_MAVEN_PATH')}" } + maven { url = 'https://repo.grails.org/grails/core' } + } + dependencies { + classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" + } +} + +plugins { + id 'java-library' + id 'groovy' +} + +allprojects { + repositories { + maven { url = 'https://repo.grails.org/grails/core' } + } +} + +version "${projectVersion}" +group "org.grails.example" + +dependencies { + implementation 'org.apache.groovy:groovy-all:4.0.24' +} + +subprojects { project -> + version "${projectVersion}" + group "org.grails.example" +} diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/gradle.properties b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/gradle.properties new file mode 100644 index 00000000..1fe1bde7 --- /dev/null +++ b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/gradle.properties @@ -0,0 +1,2 @@ +projectVersion=0.0.1-SNAPSHOT +grailsGradlePluginVersion=7.0.0-SNAPSHOT \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/settings.gradle b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/settings.gradle new file mode 100644 index 00000000..1dba1309 --- /dev/null +++ b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/settings.gradle @@ -0,0 +1,3 @@ +rootProject.name = 'subproject1' + +include 'subproject2' \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/src/main/groovy/org/grails/example/SubProject1.groovy b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/src/main/groovy/org/grails/example/SubProject1.groovy new file mode 100644 index 00000000..54df8e20 --- /dev/null +++ b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/src/main/groovy/org/grails/example/SubProject1.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject1 { + def sayHello() { + println "Hello from SubProject1" + } +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/subproject2/build.gradle b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/subproject2/build.gradle new file mode 100644 index 00000000..2d5d780e --- /dev/null +++ b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/subproject2/build.gradle @@ -0,0 +1,21 @@ +plugins { + id 'java-library' + id 'groovy' + id 'org.grails.grails-publish' +} + +dependencies { + implementation 'org.apache.groovy:groovy-all:4.0.24' +} + +grailsPublish { + githubSlug = 'grails/grails-gradle-plugin' + license { + name = 'Apache-2.0' + } + title = 'Grails Gradle Plugin - Example Project' + desc = 'A testing project for the grails gradle plugin' + developers = [ + jdaugherty: 'James Daugherty', + ] +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy new file mode 100644 index 00000000..56750d0a --- /dev/null +++ b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject2 { + def sayHello() { + println "Hello from SubProject2" + } +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/build.gradle b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/build.gradle new file mode 100644 index 00000000..49cfb861 --- /dev/null +++ b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/build.gradle @@ -0,0 +1,43 @@ +buildscript { + repositories { + maven { url "${System.getenv('LOCAL_MAVEN_PATH')}" } + maven { url = 'https://repo.grails.org/grails/core' } + } + dependencies { + classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" + } +} + +plugins { + id 'java-library' + id 'groovy' + id 'org.grails.grails-publish' +} + +version "${projectVersion}" +group "org.grails.example" + +dependencies { + implementation 'org.apache.groovy:groovy-all:4.0.24' +} + +allprojects { + repositories { + maven { url = 'https://repo.grails.org/grails/core' } + } + + version "${projectVersion}" + group "org.grails.example" +} + +grailsPublish { + githubSlug = 'grails/grails-gradle-plugin' + license { + name = 'Apache-2.0' + } + title = 'Grails Gradle Plugin - Example Project' + desc = 'A testing project for the grails gradle plugin' + developers = [ + jdaugherty: 'James Daugherty', + ] +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/gradle.properties b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/gradle.properties new file mode 100644 index 00000000..1fe1bde7 --- /dev/null +++ b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/gradle.properties @@ -0,0 +1,2 @@ +projectVersion=0.0.1-SNAPSHOT +grailsGradlePluginVersion=7.0.0-SNAPSHOT \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/settings.gradle b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/settings.gradle new file mode 100644 index 00000000..1dba1309 --- /dev/null +++ b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/settings.gradle @@ -0,0 +1,3 @@ +rootProject.name = 'subproject1' + +include 'subproject2' \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/src/main/groovy/org/grails/example/SubProject1.groovy b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/src/main/groovy/org/grails/example/SubProject1.groovy new file mode 100644 index 00000000..54df8e20 --- /dev/null +++ b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/src/main/groovy/org/grails/example/SubProject1.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject1 { + def sayHello() { + println "Hello from SubProject1" + } +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/subproject2/build.gradle b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/subproject2/build.gradle new file mode 100644 index 00000000..1ed36ebf --- /dev/null +++ b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/subproject2/build.gradle @@ -0,0 +1,8 @@ +plugins { + id 'java-library' + id 'groovy' +} + +dependencies { + implementation 'org.apache.groovy:groovy-all:4.0.24' +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy new file mode 100644 index 00000000..56750d0a --- /dev/null +++ b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject2 { + def sayHello() { + println "Hello from SubProject2" + } +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/build.gradle b/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/build.gradle new file mode 100644 index 00000000..1dc73396 --- /dev/null +++ b/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/build.gradle @@ -0,0 +1,23 @@ +buildscript { + repositories { + maven { url "${System.getenv('LOCAL_MAVEN_PATH')}" } + maven { url = 'https://repo.grails.org/grails/core' } + } + dependencies { + classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" + } +} + +allprojects { + repositories { + maven { url = 'https://repo.grails.org/grails/core' } + } +} + +version "${projectVersion}" +group "org.grails.example" + +subprojects { project -> + version "${projectVersion}" + group "org.grails.example" +} diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/gradle.properties b/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/gradle.properties new file mode 100644 index 00000000..1fe1bde7 --- /dev/null +++ b/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/gradle.properties @@ -0,0 +1,2 @@ +projectVersion=0.0.1-SNAPSHOT +grailsGradlePluginVersion=7.0.0-SNAPSHOT \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/settings.gradle b/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/settings.gradle new file mode 100644 index 00000000..b63f52a9 --- /dev/null +++ b/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/settings.gradle @@ -0,0 +1,4 @@ +rootProject.name = 'multi-project-no-subproject-build-gradle-root' + +include 'subproject1' +include 'subproject2' \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject1/build.gradle b/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject1/build.gradle new file mode 100644 index 00000000..4b863ed6 --- /dev/null +++ b/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject1/build.gradle @@ -0,0 +1,10 @@ +plugins { + id 'java-library' + id 'groovy' +} + +dependencies { + implementation 'org.apache.groovy:groovy-all:4.0.24' +} + +logger.lifecycle("Not applying grails-publish plugin to project `${project.name}`") \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy b/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy new file mode 100644 index 00000000..54df8e20 --- /dev/null +++ b/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject1 { + def sayHello() { + println "Hello from SubProject1" + } +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject2/build.gradle b/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject2/build.gradle new file mode 100644 index 00000000..2d5d780e --- /dev/null +++ b/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject2/build.gradle @@ -0,0 +1,21 @@ +plugins { + id 'java-library' + id 'groovy' + id 'org.grails.grails-publish' +} + +dependencies { + implementation 'org.apache.groovy:groovy-all:4.0.24' +} + +grailsPublish { + githubSlug = 'grails/grails-gradle-plugin' + license { + name = 'Apache-2.0' + } + title = 'Grails Gradle Plugin - Example Project' + desc = 'A testing project for the grails gradle plugin' + developers = [ + jdaugherty: 'James Daugherty', + ] +} \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy b/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy new file mode 100644 index 00000000..56750d0a --- /dev/null +++ b/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject2 { + def sayHello() { + println "Hello from SubProject2" + } +} \ No newline at end of file From b0b2db0e8b1285eecf8c208f66acd8cad645cef7 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Wed, 18 Dec 2024 16:29:41 -0500 Subject: [PATCH 02/14] Enable tests for grails-gradle-plugin project --- build.gradle | 44 ++- gradle.properties | 2 + .../gradle/test/GradleSpecification.groovy | 106 ++++++++ .../test/GrailsPublishPluginSpec.groovy | 251 ++++++++++++++++++ 4 files changed, 397 insertions(+), 6 deletions(-) create mode 100644 src/test/groovy/org/grails/gradle/test/GradleSpecification.groovy create mode 100644 src/test/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy diff --git a/build.gradle b/build.gradle index 0f2cdccf..def7e96d 100644 --- a/build.gradle +++ b/build.gradle @@ -78,24 +78,48 @@ dependencies { // compile grails-gradle-plugin with the Groovy version provided by Gradle // to ensure build compatibility with Gradle, currently Groovy 3.0.x // see: https://docs.gradle.org/current/userguide/compatibility.html#groovy - compileOnly "org.codehaus.groovy:groovy:$GroovySystem.version" + compileOnly "org.codehaus.groovy:groovy:$GroovySystem.version" compileOnly "org.grails:grails-bootstrap:$grailsVersion", { exclude group: 'org.apache.groovy' + exclude group: 'org.spockframework' } compileOnly "org.grails:grails-shell:$grailsShellVersion", { exclude group: 'org.apache.groovy' + exclude group: 'org.spockframework' } - runtimeOnly "org.grails:grails-bootstrap:$grailsVersion" - runtimeOnly "org.grails:grails-shell:$grailsShellVersion" + runtimeOnly "org.grails:grails-bootstrap:$grailsVersion", { + exclude group: 'org.apache.groovy' + exclude group: 'org.spockframework' + } + runtimeOnly "org.grails:grails-shell:$grailsShellVersion", { + exclude group: 'org.apache.groovy' + exclude group: 'org.spockframework' + } + + implementation "org.grails:grails-gradle-model:$grailsVersion", { + exclude group: 'org.apache.groovy' + exclude group: 'org.spockframework' + } - implementation "org.grails:grails-gradle-model:$grailsVersion" - implementation "io.github.gradle-nexus:publish-plugin:$gradleNexusPublishPluginVersion" implementation "com.bmuschko:gradle-nexus-plugin:$gradleNexusPluginVersion" implementation "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion" implementation "org.springframework.boot:spring-boot-loader-tools:$springBootVersion" implementation "io.spring.gradle:dependency-management-plugin:$springGradleDependencyManagementVersion" + + // Note: must use a groovy 3 compatible version of Spock + testImplementation "org.spockframework:spock-core:${project['spock.version']}", { + exclude group: 'org.apache.groovy' + } + testImplementation 'commons-io:commons-io:2.18.0' + testImplementation gradleTestKit() + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' +} + +tasks.withType(Test).configureEach { + useJUnitPlatform() + systemProperty("localMavenPath", rootProject.layout.buildDirectory.dir('local-maven').get().asFile.absolutePath) } gradlePlugin { @@ -238,6 +262,14 @@ publishing { } } + // publishAllPublicationsToTestCaseMavenRepoRepository + repositories { + maven { + name = "TestCaseMavenRepo" + url = layout.buildDirectory.dir('local-maven') + } + } + publications { pluginMaven(MavenPublication) { pom { @@ -280,7 +312,7 @@ publishing { } project.afterEvaluate { - project.publishing.publications.each { MavenPublication publication-> + project.publishing.publications.each { MavenPublication publication -> if (publication.name != "pluginMaven") { publication.pom.withXml { def xml = asNode() diff --git a/gradle.properties b/gradle.properties index b9d34aa7..1d175e39 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,6 +5,8 @@ grailsVersion=7.0.0-SNAPSHOT grailsShellVersion=7.0.0-SNAPSHOT springBootVersion=3.4.0 springGradleDependencyManagementVersion=1.1.6 +# Since we're pulling in spring's dependency management, we need to override this to support the groovy version of gradle +spock.version=2.3-groovy-3.0 org.gradle.caching=true org.gradle.daemon=true org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1536M -XX:MaxMetaspaceSize=512M diff --git a/src/test/groovy/org/grails/gradle/test/GradleSpecification.groovy b/src/test/groovy/org/grails/gradle/test/GradleSpecification.groovy new file mode 100644 index 00000000..1be297fc --- /dev/null +++ b/src/test/groovy/org/grails/gradle/test/GradleSpecification.groovy @@ -0,0 +1,106 @@ +package org.grails.gradle.test + +import org.apache.commons.io.FileUtils +import org.gradle.testkit.runner.BuildResult +import org.gradle.testkit.runner.BuildTask +import org.gradle.testkit.runner.GradleRunner +import org.gradle.testkit.runner.TaskOutcome +import spock.lang.Specification + +import java.nio.file.Files +import java.nio.file.Path + +abstract class GradleSpecification extends Specification { + private static Path basePath + + private static GradleRunner gradleRunner + + void setupSpec() { + basePath = Files.createTempDirectory("gradle-projects") + Path testKitDirectory = Files.createDirectories(basePath.resolve('.gradle')) + gradleRunner = GradleRunner.create() + .withPluginClasspath() + .withTestKitDir(testKitDirectory.toFile()) + + gradleRunner = addEnvironmentVariable("LOCAL_MAVEN_PATH", System.getProperty("localMavenPath"), gradleRunner) + } + + GradleRunner addEnvironmentVariable(String key, String value, GradleRunner runner) { + Map environment = runner.environment + if(environment) { + environment.put(key, value) + + return runner + } + else { + return runner.withEnvironment([(key): value]) + } + } + + void setGradleProperty(String key, String value, GradleRunner runner) { + addEnvironmentVariable("ORG_GRADLE_PROJECT_${key}", value, runner) + } + + void cleanup() { + basePath.toFile().listFiles().each { + // Reuse the gradle cache from previous tests + if(it.name == ".gradle") { + return + } + + FileUtils.deleteQuietly(it) + } + } + + void cleanupSpec() { + FileUtils.deleteQuietly(basePath.toFile()) + } + + protected GradleRunner setupProject(String type, String projectName) { + Objects.requireNonNull(projectName, "projectName must not be null") + + Path destinationDir = basePath.resolve(type) + Files.createDirectories(destinationDir) + + Path sourceProjectDir = Path.of("src/test/resources/publish-projects/$type/$projectName") + FileUtils.copyDirectoryToDirectory(sourceProjectDir.toFile(), destinationDir.toFile()) + + gradleRunner + .withProjectDir(destinationDir.resolve(projectName).toFile()) + } + + protected BuildResult executeTask(String taskName, GradleRunner gradleRunner) { + gradleRunner.withArguments(taskName, "--stacktrace").forwardOutput().build() + } + + protected void assertTaskSuccess(String taskName, BuildResult result) { + def tasks = result.tasks.find { it.path.endsWith(":${taskName}") } + if (!tasks) { + throw new IllegalStateException("No tasks were found for `${taskName}`") + } + + tasks.each { BuildTask task -> + if (task.outcome != TaskOutcome.SUCCESS) { + throw new IllegalStateException("Task $taskName failed with outcome $task.outcome") + } + } + } + + protected void assertBuildSuccess(BuildResult result, List ignoreTaskNames = []) { + def results = result.tasks.groupBy { it.outcome } + + for (String ignoredTaskName : ignoreTaskNames) { + for (BuildTask ignoredTask : result.tasks.findAll { it.path.endsWith("${ignoredTaskName}") }) { + def taskOutComeTasks = results.get(ignoredTask.outcome) + taskOutComeTasks.remove(ignoredTask) + if(!taskOutComeTasks) { + results.remove(ignoredTask.outcome) + } + } + } + + if (results.keySet().size() != 1) { + throw new IllegalStateException("Unexpected Task failures: ${results.findAll { it.key != TaskOutcome.SUCCESS }}") + } + } +} diff --git a/src/test/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy b/src/test/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy new file mode 100644 index 00000000..f64d7c65 --- /dev/null +++ b/src/test/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy @@ -0,0 +1,251 @@ +package org.grails.gradle.test + +import org.gradle.testkit.runner.GradleRunner +import spock.lang.PendingFeature + +class GrailsPublishPluginSpec extends GradleSpecification { + def "gradle config works when not publishing - snapshot - maven publish - legacy-apply - multi-project-no-subproject-build-gradle-publish-all"() { + given: + GradleRunner runner = setupProject('legacy-apply', 'multi-project-no-subproject-build-gradle-publish-all') + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + } + + def "gradle config works when not publishing - snapshot - maven publish - legacy-apply - multi-project-no-subproject-build-gradle-publish-per-project"() { + given: + GradleRunner runner = setupProject('legacy-apply', 'multi-project-no-subproject-build-gradle-publish-per-project') + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + } + + def "gradle config works when not publishing - snapshot - maven publish - legacy-apply - multi-project-parent-child-setup-per-project-parent-published"() { + given: + GradleRunner runner = setupProject('legacy-apply', 'multi-project-parent-child-setup-per-project-parent-published') + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + } + + def "gradle config works when not publishing - snapshot - maven publish - legacy-apply - multi-project-parent-child-setup-per-project-child-published"() { + given: + GradleRunner runner = setupProject('legacy-apply', 'multi-project-parent-child-setup-per-project-child-published') + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + } + + def "gradle config works when not publishing - snapshot - maven publish - legacy-apply - multi-project-with-subproject-gradle"() { + given: + GradleRunner runner = setupProject('legacy-apply', 'multi-project-with-subproject-gradle') + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + } + + def "gradle config works when not publishing - snapshot - maven publish - plugins-block - multi-project-parent-child-setup-per-project-parent-published"() { + given: + GradleRunner runner = setupProject('plugins-block', 'multi-project-parent-child-setup-per-project-parent-published') + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + } + + def "gradle config works when not publishing - snapshot - maven publish - plugins-block - multi-project-parent-child-setup-per-project-child-published"() { + given: + GradleRunner runner = setupProject('plugins-block', 'multi-project-parent-child-setup-per-project-child-published') + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + } + + def "gradle config works when not publishing - snapshot - maven publish - plugins-block - multi-project-with-subproject-gradle"() { + given: + GradleRunner runner = setupProject('plugins-block', 'multi-project-with-subproject-gradle') + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + } + + + def "gradle config works when not publishing - milestone - maven publish - legacy-apply - multi-project-no-subproject-build-gradle-publish-all"() { + given: + GradleRunner runner = setupProject('legacy-apply', 'multi-project-no-subproject-build-gradle-publish-all') + + setGradleProperty( + "projectVersion", + "0.0.1-M1", + runner + ) + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + } + + def "gradle config works when not publishing - milestone - maven publish - legacy-apply - multi-project-no-subproject-build-gradle-publish-per-project"() { + given: + GradleRunner runner = setupProject('legacy-apply', 'multi-project-no-subproject-build-gradle-publish-per-project') + + setGradleProperty( + "projectVersion", + "0.0.1-M1", + runner + ) + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + } + + def "gradle config works when not publishing - milestone - maven publish - legacy-apply - multi-project-parent-child-setup-per-project-parent-published"() { + given: + GradleRunner runner = setupProject('legacy-apply', 'multi-project-parent-child-setup-per-project-parent-published') + + setGradleProperty( + "projectVersion", + "0.0.1-M1", + runner + ) + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + } + + @PendingFeature(reason = "Failed to apply plugin class 'io.github.gradlenexus.publishplugin.NexusPublishPlugin'") + def "gradle config works when not publishing - milestone - maven publish - legacy-apply - multi-project-parent-child-setup-per-project-child-published"() { + given: + GradleRunner runner = setupProject('legacy-apply', 'multi-project-parent-child-setup-per-project-child-published') + + setGradleProperty( + "projectVersion", + "0.0.1-M1", + runner + ) + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + } + + @PendingFeature(reason = "Failed to apply plugin class 'io.github.gradlenexus.publishplugin.NexusPublishPlugin'") + def "gradle config works when not publishing - milestone - maven publish - legacy-apply - multi-project-with-subproject-gradle"() { + given: + GradleRunner runner = setupProject('legacy-apply', 'multi-project-with-subproject-gradle') + + setGradleProperty( + "projectVersion", + "0.0.1-M1", + runner + ) + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + } + + def "gradle config works when not publishing - milestone - maven publish - plugins-block - multi-project-parent-child-setup-per-project-parent-published"() { + given: + GradleRunner runner = setupProject('plugins-block', 'multi-project-parent-child-setup-per-project-parent-published') + + setGradleProperty( + "projectVersion", + "0.0.1-M1", + runner + ) + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + } + + @PendingFeature(reason = "Failed to apply plugin class 'io.github.gradlenexus.publishplugin.NexusPublishPlugin'") + def "gradle config works when not publishing - milestone - maven publish - plugins-block - multi-project-parent-child-setup-per-project-child-published"() { + given: + GradleRunner runner = setupProject('plugins-block', 'multi-project-parent-child-setup-per-project-child-published') + + setGradleProperty( + "projectVersion", + "0.0.1-M1", + runner + ) + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + } + + @PendingFeature(reason = "Failed to apply plugin class 'io.github.gradlenexus.publishplugin.NexusPublishPlugin'") + def "gradle config works when not publishing - milestone - maven publish - plugins-block - multi-project-with-subproject-gradle"() { + given: + GradleRunner runner = setupProject('plugins-block', 'multi-project-with-subproject-gradle') + + setGradleProperty( + "projectVersion", + "0.0.1-M1", + runner + ) + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + } +} From 945371380be1da85f39611c85a7292d25d902bcc Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Wed, 18 Dec 2024 17:04:57 -0500 Subject: [PATCH 03/14] Add warning when projectVersion is used instead of project.version --- .../GrailsPublishGradlePlugin.groovy | 3 ++ .../test/GrailsPublishPluginSpec.groovy | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy index dc224a69..b254e46c 100644 --- a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy @@ -127,6 +127,9 @@ Note: if project properties are used, the properties must be defined prior to ap if (detectedVersion == Project.DEFAULT_VERSION) { throw new IllegalStateException("Project `${project.name}` has an unspecified version (neither `version` or the property `projectVersion` is defined). Release state cannot be determined.") } + if(project.version == Project.DEFAULT_VERSION) { + project.rootProject.logger.warn("Project `${project.name}` does not have a version defined. Using the gradle property `projectVersion` to assume version is ${detectedVersion}.") + } project.rootProject.logger.info("Version $detectedVersion detected for project ${project.name}") boolean isSnapshot = detectedVersion.endsWith('SNAPSHOT') diff --git a/src/test/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy b/src/test/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy index f64d7c65..612890e5 100644 --- a/src/test/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy +++ b/src/test/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy @@ -14,6 +14,8 @@ class GrailsPublishPluginSpec extends GradleSpecification { then: assertTaskSuccess("assemble", result) assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") } def "gradle config works when not publishing - snapshot - maven publish - legacy-apply - multi-project-no-subproject-build-gradle-publish-per-project"() { @@ -26,6 +28,8 @@ class GrailsPublishPluginSpec extends GradleSpecification { then: assertTaskSuccess("assemble", result) assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") } def "gradle config works when not publishing - snapshot - maven publish - legacy-apply - multi-project-parent-child-setup-per-project-parent-published"() { @@ -38,6 +42,8 @@ class GrailsPublishPluginSpec extends GradleSpecification { then: assertTaskSuccess("assemble", result) assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") } def "gradle config works when not publishing - snapshot - maven publish - legacy-apply - multi-project-parent-child-setup-per-project-child-published"() { @@ -50,6 +56,8 @@ class GrailsPublishPluginSpec extends GradleSpecification { then: assertTaskSuccess("assemble", result) assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") } def "gradle config works when not publishing - snapshot - maven publish - legacy-apply - multi-project-with-subproject-gradle"() { @@ -62,6 +70,8 @@ class GrailsPublishPluginSpec extends GradleSpecification { then: assertTaskSuccess("assemble", result) assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") } def "gradle config works when not publishing - snapshot - maven publish - plugins-block - multi-project-parent-child-setup-per-project-parent-published"() { @@ -74,6 +84,9 @@ class GrailsPublishPluginSpec extends GradleSpecification { then: assertTaskSuccess("assemble", result) assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("Project `subproject2` does not have a version defined. Using the gradle property `projectVersion` to assume version is 0.0.1-SNAPSHOT.") + result.output.contains("Project `subproject1` does not have a version defined. Using the gradle property `projectVersion` to assume version is 0.0.1-SNAPSHOT.") } def "gradle config works when not publishing - snapshot - maven publish - plugins-block - multi-project-parent-child-setup-per-project-child-published"() { @@ -86,6 +99,8 @@ class GrailsPublishPluginSpec extends GradleSpecification { then: assertTaskSuccess("assemble", result) assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") } def "gradle config works when not publishing - snapshot - maven publish - plugins-block - multi-project-with-subproject-gradle"() { @@ -98,6 +113,8 @@ class GrailsPublishPluginSpec extends GradleSpecification { then: assertTaskSuccess("assemble", result) assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") } @@ -117,6 +134,8 @@ class GrailsPublishPluginSpec extends GradleSpecification { then: assertTaskSuccess("assemble", result) assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") } def "gradle config works when not publishing - milestone - maven publish - legacy-apply - multi-project-no-subproject-build-gradle-publish-per-project"() { @@ -135,6 +154,8 @@ class GrailsPublishPluginSpec extends GradleSpecification { then: assertTaskSuccess("assemble", result) assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") } def "gradle config works when not publishing - milestone - maven publish - legacy-apply - multi-project-parent-child-setup-per-project-parent-published"() { @@ -153,6 +174,8 @@ class GrailsPublishPluginSpec extends GradleSpecification { then: assertTaskSuccess("assemble", result) assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") } @PendingFeature(reason = "Failed to apply plugin class 'io.github.gradlenexus.publishplugin.NexusPublishPlugin'") @@ -172,6 +195,8 @@ class GrailsPublishPluginSpec extends GradleSpecification { then: assertTaskSuccess("assemble", result) assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") } @PendingFeature(reason = "Failed to apply plugin class 'io.github.gradlenexus.publishplugin.NexusPublishPlugin'") @@ -191,6 +216,8 @@ class GrailsPublishPluginSpec extends GradleSpecification { then: assertTaskSuccess("assemble", result) assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") } def "gradle config works when not publishing - milestone - maven publish - plugins-block - multi-project-parent-child-setup-per-project-parent-published"() { @@ -209,6 +236,8 @@ class GrailsPublishPluginSpec extends GradleSpecification { then: assertTaskSuccess("assemble", result) assertBuildSuccess(result, ["compileJava", "processResources"]) + + result.output.contains("Project `subproject1` does not have a version defined. Using the gradle property `projectVersion` to assume version is 0.0.1-M1.") } @PendingFeature(reason = "Failed to apply plugin class 'io.github.gradlenexus.publishplugin.NexusPublishPlugin'") @@ -228,6 +257,8 @@ class GrailsPublishPluginSpec extends GradleSpecification { then: assertTaskSuccess("assemble", result) assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") } @PendingFeature(reason = "Failed to apply plugin class 'io.github.gradlenexus.publishplugin.NexusPublishPlugin'") @@ -247,5 +278,7 @@ class GrailsPublishPluginSpec extends GradleSpecification { then: assertTaskSuccess("assemble", result) assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") } } From 581a18037c565c570a9c901174751223d0ffe215 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Wed, 18 Dec 2024 17:50:46 -0500 Subject: [PATCH 04/14] Pass through project.version to tests --- build.gradle | 1 + .../grails/gradle/test/GradleSpecification.groovy | 14 ++++++++++++-- .../gradle.properties | 3 +-- .../gradle.properties | 3 +-- .../gradle.properties | 3 +-- .../gradle.properties | 3 +-- .../gradle.properties | 3 +-- .../gradle.properties | 3 +-- .../gradle.properties | 3 +-- .../gradle.properties | 3 +-- 10 files changed, 21 insertions(+), 18 deletions(-) diff --git a/build.gradle b/build.gradle index def7e96d..79941875 100644 --- a/build.gradle +++ b/build.gradle @@ -120,6 +120,7 @@ dependencies { tasks.withType(Test).configureEach { useJUnitPlatform() systemProperty("localMavenPath", rootProject.layout.buildDirectory.dir('local-maven').get().asFile.absolutePath) + systemProperty("grailsGradlePluginVersion", rootProject.version) } gradlePlugin { diff --git a/src/test/groovy/org/grails/gradle/test/GradleSpecification.groovy b/src/test/groovy/org/grails/gradle/test/GradleSpecification.groovy index 1be297fc..05b7e1f9 100644 --- a/src/test/groovy/org/grails/gradle/test/GradleSpecification.groovy +++ b/src/test/groovy/org/grails/gradle/test/GradleSpecification.groovy @@ -22,7 +22,17 @@ abstract class GradleSpecification extends Specification { .withPluginClasspath() .withTestKitDir(testKitDirectory.toFile()) - gradleRunner = addEnvironmentVariable("LOCAL_MAVEN_PATH", System.getProperty("localMavenPath"), gradleRunner) + gradleRunner = addEnvironmentVariable( + "LOCAL_MAVEN_PATH", + System.getProperty("localMavenPath"), + gradleRunner + ) + + gradleRunner = setGradleProperty( + "grailsGradlePluginVersion", + System.getProperty("grailsGradlePluginVersion"), + gradleRunner + ) } GradleRunner addEnvironmentVariable(String key, String value, GradleRunner runner) { @@ -37,7 +47,7 @@ abstract class GradleSpecification extends Specification { } } - void setGradleProperty(String key, String value, GradleRunner runner) { + GradleRunner setGradleProperty(String key, String value, GradleRunner runner) { addEnvironmentVariable("ORG_GRADLE_PROJECT_${key}", value, runner) } diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/gradle.properties b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/gradle.properties index 1fe1bde7..e0f33cc2 100644 --- a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/gradle.properties +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/gradle.properties @@ -1,2 +1 @@ -projectVersion=0.0.1-SNAPSHOT -grailsGradlePluginVersion=7.0.0-SNAPSHOT \ No newline at end of file +projectVersion=0.0.1-SNAPSHOT \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/gradle.properties b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/gradle.properties index 1fe1bde7..e0f33cc2 100644 --- a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/gradle.properties +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/gradle.properties @@ -1,2 +1 @@ -projectVersion=0.0.1-SNAPSHOT -grailsGradlePluginVersion=7.0.0-SNAPSHOT \ No newline at end of file +projectVersion=0.0.1-SNAPSHOT \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/gradle.properties b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/gradle.properties index 1fe1bde7..e0f33cc2 100644 --- a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/gradle.properties +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/gradle.properties @@ -1,2 +1 @@ -projectVersion=0.0.1-SNAPSHOT -grailsGradlePluginVersion=7.0.0-SNAPSHOT \ No newline at end of file +projectVersion=0.0.1-SNAPSHOT \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/gradle.properties b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/gradle.properties index 1fe1bde7..e0f33cc2 100644 --- a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/gradle.properties +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/gradle.properties @@ -1,2 +1 @@ -projectVersion=0.0.1-SNAPSHOT -grailsGradlePluginVersion=7.0.0-SNAPSHOT \ No newline at end of file +projectVersion=0.0.1-SNAPSHOT \ No newline at end of file diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/gradle.properties b/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/gradle.properties index 1fe1bde7..e0f33cc2 100644 --- a/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/gradle.properties +++ b/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/gradle.properties @@ -1,2 +1 @@ -projectVersion=0.0.1-SNAPSHOT -grailsGradlePluginVersion=7.0.0-SNAPSHOT \ No newline at end of file +projectVersion=0.0.1-SNAPSHOT \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/gradle.properties b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/gradle.properties index 1fe1bde7..e0f33cc2 100644 --- a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/gradle.properties +++ b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/gradle.properties @@ -1,2 +1 @@ -projectVersion=0.0.1-SNAPSHOT -grailsGradlePluginVersion=7.0.0-SNAPSHOT \ No newline at end of file +projectVersion=0.0.1-SNAPSHOT \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/gradle.properties b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/gradle.properties index 1fe1bde7..e0f33cc2 100644 --- a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/gradle.properties +++ b/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/gradle.properties @@ -1,2 +1 @@ -projectVersion=0.0.1-SNAPSHOT -grailsGradlePluginVersion=7.0.0-SNAPSHOT \ No newline at end of file +projectVersion=0.0.1-SNAPSHOT \ No newline at end of file diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/gradle.properties b/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/gradle.properties index 1fe1bde7..e0f33cc2 100644 --- a/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/gradle.properties +++ b/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/gradle.properties @@ -1,2 +1 @@ -projectVersion=0.0.1-SNAPSHOT -grailsGradlePluginVersion=7.0.0-SNAPSHOT \ No newline at end of file +projectVersion=0.0.1-SNAPSHOT \ No newline at end of file From a2cb0128cac79662ea69628b1be5787feaddb6e9 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Wed, 18 Dec 2024 17:59:11 -0500 Subject: [PATCH 05/14] Add error when sources do not exist and grails publish is applied --- .../GrailsPublishGradlePlugin.groovy | 19 ++--- .../gradle/test/GradleSpecification.groovy | 18 ++++- .../test/GrailsPublishPluginSpec.groovy | 75 ++++++++++++++----- 3 files changed, 81 insertions(+), 31 deletions(-) diff --git a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy index b254e46c..c3adb6f3 100644 --- a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy @@ -125,10 +125,10 @@ Note: if project properties are used, the properties must be defined prior to ap String detectedVersion = (project.version == Project.DEFAULT_VERSION ? (project.findProperty('projectVersion') ?: Project.DEFAULT_VERSION) : project.version) as String if (detectedVersion == Project.DEFAULT_VERSION) { - throw new IllegalStateException("Project `${project.name}` has an unspecified version (neither `version` or the property `projectVersion` is defined). Release state cannot be determined.") + throw new IllegalStateException("Project ${project.name} has an unspecified version (neither `version` or the property `projectVersion` is defined). Release state cannot be determined.") } if(project.version == Project.DEFAULT_VERSION) { - project.rootProject.logger.warn("Project `${project.name}` does not have a version defined. Using the gradle property `projectVersion` to assume version is ${detectedVersion}.") + project.rootProject.logger.warn("Project ${project.name} does not have a version defined. Using the gradle property `projectVersion` to assume version is ${detectedVersion}.") } project.rootProject.logger.info("Version $detectedVersion detected for project ${project.name}") @@ -138,7 +138,7 @@ Note: if project properties are used, the properties must be defined prior to ap } boolean isRelease = !isSnapshot if (isRelease) { - project.rootProject.logger.info("Release detected for Project `${project.name}`") + project.rootProject.logger.info("Release detected for Project ${project.name}") } boolean useMavenPublish = (isSnapshot && snapshotPublishType == PublishType.MAVEN_PUBLISH) || (isRelease && releasePublishType == PublishType.MAVEN_PUBLISH) @@ -196,6 +196,7 @@ Note: if project properties are used, the properties must be defined prior to ap } project.afterEvaluate { + validateProjectState(project) project.publishing { if (useMavenPublish) { System.setProperty('org.gradle.internal.publish.checksums.insecure', true as String) @@ -205,12 +206,6 @@ Note: if project properties are used, the properties must be defined prior to ap username = mavenPublishUsername password = mavenPublishPassword } - - if (!mavenPublishUrl) { - // TODO: Need to only apply this when trying to publish - // throw new RuntimeException('Could not locate a project property of `mavenPublishUrl` or an environment variable of `MAVEN_PUBLISH_URL`. A URL is required for maven publishing.') - } - url = mavenPublishUrl } } @@ -382,5 +377,11 @@ Note: if project properties are used, the properties must be defined prior to ap protected String getDefaultClassifier() { 'plugin' } + + private validateProjectState(Project project) { + if(!project.components) { + throw new RuntimeException("Cannot apply Grails Publish Plugin. Project ${project.name} does not have any components to publish.") + } + } } diff --git a/src/test/groovy/org/grails/gradle/test/GradleSpecification.groovy b/src/test/groovy/org/grails/gradle/test/GradleSpecification.groovy index 05b7e1f9..bdf95d71 100644 --- a/src/test/groovy/org/grails/gradle/test/GradleSpecification.groovy +++ b/src/test/groovy/org/grails/gradle/test/GradleSpecification.groovy @@ -66,7 +66,7 @@ abstract class GradleSpecification extends Specification { FileUtils.deleteQuietly(basePath.toFile()) } - protected GradleRunner setupProject(String type, String projectName) { + protected GradleRunner setupTestResourceProject(String type, String projectName) { Objects.requireNonNull(projectName, "projectName must not be null") Path destinationDir = basePath.resolve(type) @@ -75,8 +75,20 @@ abstract class GradleSpecification extends Specification { Path sourceProjectDir = Path.of("src/test/resources/publish-projects/$type/$projectName") FileUtils.copyDirectoryToDirectory(sourceProjectDir.toFile(), destinationDir.toFile()) - gradleRunner - .withProjectDir(destinationDir.resolve(projectName).toFile()) + setupProject(destinationDir.resolve(projectName)) + } + + protected GradleRunner setupProject(Path projectDirectory) { + gradleRunner.withProjectDir(projectDirectory.toFile()) + } + + protected Path createProjectDir(String projectName) { + Objects.requireNonNull(projectName, "projectName must not be null") + + Path destinationDir = basePath.resolve(projectName) + Files.createDirectories(destinationDir) + + destinationDir } protected BuildResult executeTask(String taskName, GradleRunner gradleRunner) { diff --git a/src/test/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy b/src/test/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy index 612890e5..fe262b19 100644 --- a/src/test/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy +++ b/src/test/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy @@ -1,12 +1,15 @@ package org.grails.gradle.test import org.gradle.testkit.runner.GradleRunner +import org.gradle.testkit.runner.UnexpectedBuildFailure import spock.lang.PendingFeature +import java.nio.file.Path + class GrailsPublishPluginSpec extends GradleSpecification { def "gradle config works when not publishing - snapshot - maven publish - legacy-apply - multi-project-no-subproject-build-gradle-publish-all"() { given: - GradleRunner runner = setupProject('legacy-apply', 'multi-project-no-subproject-build-gradle-publish-all') + GradleRunner runner = setupTestResourceProject('legacy-apply', 'multi-project-no-subproject-build-gradle-publish-all') when: def result = executeTask("assemble", runner) @@ -20,7 +23,7 @@ class GrailsPublishPluginSpec extends GradleSpecification { def "gradle config works when not publishing - snapshot - maven publish - legacy-apply - multi-project-no-subproject-build-gradle-publish-per-project"() { given: - GradleRunner runner = setupProject('legacy-apply', 'multi-project-no-subproject-build-gradle-publish-per-project') + GradleRunner runner = setupTestResourceProject('legacy-apply', 'multi-project-no-subproject-build-gradle-publish-per-project') when: def result = executeTask("assemble", runner) @@ -34,7 +37,7 @@ class GrailsPublishPluginSpec extends GradleSpecification { def "gradle config works when not publishing - snapshot - maven publish - legacy-apply - multi-project-parent-child-setup-per-project-parent-published"() { given: - GradleRunner runner = setupProject('legacy-apply', 'multi-project-parent-child-setup-per-project-parent-published') + GradleRunner runner = setupTestResourceProject('legacy-apply', 'multi-project-parent-child-setup-per-project-parent-published') when: def result = executeTask("assemble", runner) @@ -48,7 +51,7 @@ class GrailsPublishPluginSpec extends GradleSpecification { def "gradle config works when not publishing - snapshot - maven publish - legacy-apply - multi-project-parent-child-setup-per-project-child-published"() { given: - GradleRunner runner = setupProject('legacy-apply', 'multi-project-parent-child-setup-per-project-child-published') + GradleRunner runner = setupTestResourceProject('legacy-apply', 'multi-project-parent-child-setup-per-project-child-published') when: def result = executeTask("assemble", runner) @@ -62,7 +65,7 @@ class GrailsPublishPluginSpec extends GradleSpecification { def "gradle config works when not publishing - snapshot - maven publish - legacy-apply - multi-project-with-subproject-gradle"() { given: - GradleRunner runner = setupProject('legacy-apply', 'multi-project-with-subproject-gradle') + GradleRunner runner = setupTestResourceProject('legacy-apply', 'multi-project-with-subproject-gradle') when: def result = executeTask("assemble", runner) @@ -76,7 +79,7 @@ class GrailsPublishPluginSpec extends GradleSpecification { def "gradle config works when not publishing - snapshot - maven publish - plugins-block - multi-project-parent-child-setup-per-project-parent-published"() { given: - GradleRunner runner = setupProject('plugins-block', 'multi-project-parent-child-setup-per-project-parent-published') + GradleRunner runner = setupTestResourceProject('plugins-block', 'multi-project-parent-child-setup-per-project-parent-published') when: def result = executeTask("assemble", runner) @@ -85,13 +88,13 @@ class GrailsPublishPluginSpec extends GradleSpecification { assertTaskSuccess("assemble", result) assertBuildSuccess(result, ["compileJava", "processResources"]) - !result.output.contains("Project `subproject2` does not have a version defined. Using the gradle property `projectVersion` to assume version is 0.0.1-SNAPSHOT.") - result.output.contains("Project `subproject1` does not have a version defined. Using the gradle property `projectVersion` to assume version is 0.0.1-SNAPSHOT.") + !result.output.contains("Project subproject2 does not have a version defined. Using the gradle property `projectVersion` to assume version is 0.0.1-SNAPSHOT.") + result.output.contains("Project subproject1 does not have a version defined. Using the gradle property `projectVersion` to assume version is 0.0.1-SNAPSHOT.") } def "gradle config works when not publishing - snapshot - maven publish - plugins-block - multi-project-parent-child-setup-per-project-child-published"() { given: - GradleRunner runner = setupProject('plugins-block', 'multi-project-parent-child-setup-per-project-child-published') + GradleRunner runner = setupTestResourceProject('plugins-block', 'multi-project-parent-child-setup-per-project-child-published') when: def result = executeTask("assemble", runner) @@ -105,7 +108,7 @@ class GrailsPublishPluginSpec extends GradleSpecification { def "gradle config works when not publishing - snapshot - maven publish - plugins-block - multi-project-with-subproject-gradle"() { given: - GradleRunner runner = setupProject('plugins-block', 'multi-project-with-subproject-gradle') + GradleRunner runner = setupTestResourceProject('plugins-block', 'multi-project-with-subproject-gradle') when: def result = executeTask("assemble", runner) @@ -120,7 +123,7 @@ class GrailsPublishPluginSpec extends GradleSpecification { def "gradle config works when not publishing - milestone - maven publish - legacy-apply - multi-project-no-subproject-build-gradle-publish-all"() { given: - GradleRunner runner = setupProject('legacy-apply', 'multi-project-no-subproject-build-gradle-publish-all') + GradleRunner runner = setupTestResourceProject('legacy-apply', 'multi-project-no-subproject-build-gradle-publish-all') setGradleProperty( "projectVersion", @@ -140,7 +143,7 @@ class GrailsPublishPluginSpec extends GradleSpecification { def "gradle config works when not publishing - milestone - maven publish - legacy-apply - multi-project-no-subproject-build-gradle-publish-per-project"() { given: - GradleRunner runner = setupProject('legacy-apply', 'multi-project-no-subproject-build-gradle-publish-per-project') + GradleRunner runner = setupTestResourceProject('legacy-apply', 'multi-project-no-subproject-build-gradle-publish-per-project') setGradleProperty( "projectVersion", @@ -160,7 +163,7 @@ class GrailsPublishPluginSpec extends GradleSpecification { def "gradle config works when not publishing - milestone - maven publish - legacy-apply - multi-project-parent-child-setup-per-project-parent-published"() { given: - GradleRunner runner = setupProject('legacy-apply', 'multi-project-parent-child-setup-per-project-parent-published') + GradleRunner runner = setupTestResourceProject('legacy-apply', 'multi-project-parent-child-setup-per-project-parent-published') setGradleProperty( "projectVersion", @@ -181,7 +184,7 @@ class GrailsPublishPluginSpec extends GradleSpecification { @PendingFeature(reason = "Failed to apply plugin class 'io.github.gradlenexus.publishplugin.NexusPublishPlugin'") def "gradle config works when not publishing - milestone - maven publish - legacy-apply - multi-project-parent-child-setup-per-project-child-published"() { given: - GradleRunner runner = setupProject('legacy-apply', 'multi-project-parent-child-setup-per-project-child-published') + GradleRunner runner = setupTestResourceProject('legacy-apply', 'multi-project-parent-child-setup-per-project-child-published') setGradleProperty( "projectVersion", @@ -202,7 +205,7 @@ class GrailsPublishPluginSpec extends GradleSpecification { @PendingFeature(reason = "Failed to apply plugin class 'io.github.gradlenexus.publishplugin.NexusPublishPlugin'") def "gradle config works when not publishing - milestone - maven publish - legacy-apply - multi-project-with-subproject-gradle"() { given: - GradleRunner runner = setupProject('legacy-apply', 'multi-project-with-subproject-gradle') + GradleRunner runner = setupTestResourceProject('legacy-apply', 'multi-project-with-subproject-gradle') setGradleProperty( "projectVersion", @@ -222,7 +225,7 @@ class GrailsPublishPluginSpec extends GradleSpecification { def "gradle config works when not publishing - milestone - maven publish - plugins-block - multi-project-parent-child-setup-per-project-parent-published"() { given: - GradleRunner runner = setupProject('plugins-block', 'multi-project-parent-child-setup-per-project-parent-published') + GradleRunner runner = setupTestResourceProject('plugins-block', 'multi-project-parent-child-setup-per-project-parent-published') setGradleProperty( "projectVersion", @@ -237,13 +240,13 @@ class GrailsPublishPluginSpec extends GradleSpecification { assertTaskSuccess("assemble", result) assertBuildSuccess(result, ["compileJava", "processResources"]) - result.output.contains("Project `subproject1` does not have a version defined. Using the gradle property `projectVersion` to assume version is 0.0.1-M1.") + result.output.contains("Project subproject1 does not have a version defined. Using the gradle property `projectVersion` to assume version is 0.0.1-M1.") } @PendingFeature(reason = "Failed to apply plugin class 'io.github.gradlenexus.publishplugin.NexusPublishPlugin'") def "gradle config works when not publishing - milestone - maven publish - plugins-block - multi-project-parent-child-setup-per-project-child-published"() { given: - GradleRunner runner = setupProject('plugins-block', 'multi-project-parent-child-setup-per-project-child-published') + GradleRunner runner = setupTestResourceProject('plugins-block', 'multi-project-parent-child-setup-per-project-child-published') setGradleProperty( "projectVersion", @@ -264,7 +267,7 @@ class GrailsPublishPluginSpec extends GradleSpecification { @PendingFeature(reason = "Failed to apply plugin class 'io.github.gradlenexus.publishplugin.NexusPublishPlugin'") def "gradle config works when not publishing - milestone - maven publish - plugins-block - multi-project-with-subproject-gradle"() { given: - GradleRunner runner = setupProject('plugins-block', 'multi-project-with-subproject-gradle') + GradleRunner runner = setupTestResourceProject('plugins-block', 'multi-project-with-subproject-gradle') setGradleProperty( "projectVersion", @@ -281,4 +284,38 @@ class GrailsPublishPluginSpec extends GradleSpecification { !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") } + + def "project without sources fails grailsPublish apply"() { + given: + Path projectDir = createProjectDir("invalid-sources") + + GradleRunner runner = setupProject(projectDir) + + projectDir.resolve("settings.gradle").toFile().text = """ + rootProject.name = 'invalid-sources' + """ + + projectDir.resolve('build.gradle').toFile().text = """ + buildscript { + repositories { + maven { url "\${System.getenv('LOCAL_MAVEN_PATH')}\" } + maven { url = 'https://repo.grails.org/grails/core' } + } + dependencies { + classpath "org.grails:grails-gradle-plugin:\$grailsGradlePluginVersion" + } + } + + version "0.0.1" + + apply plugin: 'org.grails.grails-publish' + """ + + when: + executeTask("assemble", runner) + + then: + UnexpectedBuildFailure bf = thrown(UnexpectedBuildFailure) + bf.buildResult.output.contains("Cannot apply Grails Publish Plugin. Project invalid-sources does not have any components to publish.") + } } From 2a8534f61415ebca06f420e9e9a776a1dedbd44a Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Wed, 18 Dec 2024 19:02:00 -0500 Subject: [PATCH 06/14] Require a maven url when using grailsPublish with MAVEN_PUBLISH & publishing --- .../GrailsPublishGradlePlugin.groovy | 18 +++++ .../test/GrailsPublishPluginSpec.groovy | 77 ++++++++++++++++++- 2 files changed, 94 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy index c3adb6f3..b37eeeca 100644 --- a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy @@ -27,6 +27,7 @@ import org.gradle.api.plugins.PluginManager import org.gradle.api.publish.maven.MavenPublication import org.gradle.api.publish.maven.plugins.MavenPublishPlugin import org.gradle.api.tasks.TaskContainer +import org.gradle.api.tasks.TaskProvider import org.gradle.plugins.signing.Sign import org.gradle.plugins.signing.SigningExtension import org.gradle.plugins.signing.SigningPlugin @@ -199,6 +200,7 @@ Note: if project properties are used, the properties must be defined prior to ap validateProjectState(project) project.publishing { if (useMavenPublish) { + addMavenPublishValidations(project, mavenPublishUrl) System.setProperty('org.gradle.internal.publish.checksums.insecure', true as String) repositories { maven { @@ -361,6 +363,22 @@ Note: if project properties are used, the properties must be defined prior to ap } } + private void addMavenPublishValidations(Project project, def mavenPublishUrl) { + project.plugins.withId(MAVEN_PUBLISH_PLUGIN_ID) { + TaskProvider publishTask = project.tasks.named("publish") + + TaskProvider validateBeforePublish = project.tasks.register("requireMavenPublishUrl") { + if (!mavenPublishUrl) { + throw new RuntimeException('Could not locate a project property of `mavenPublishUrl` or an environment variable of `MAVEN_PUBLISH_URL`. A URL is required for maven publishing.') + } + } + + publishTask.configure { + it.dependsOn validateBeforePublish + } + } + } + protected void doAddArtefact(Project project, MavenPublication publication) { publication.from project.components.java } diff --git a/src/test/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy b/src/test/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy index fe262b19..821d43b2 100644 --- a/src/test/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy +++ b/src/test/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy @@ -120,7 +120,6 @@ class GrailsPublishPluginSpec extends GradleSpecification { !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") } - def "gradle config works when not publishing - milestone - maven publish - legacy-apply - multi-project-no-subproject-build-gradle-publish-all"() { given: GradleRunner runner = setupTestResourceProject('legacy-apply', 'multi-project-no-subproject-build-gradle-publish-all') @@ -285,6 +284,82 @@ class GrailsPublishPluginSpec extends GradleSpecification { !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") } + def "project fails on maven publish without url"() { + given: + Path projectDir = createProjectDir("invalid-sources") + + GradleRunner runner = setupProject(projectDir) + + projectDir.resolve("settings.gradle").toFile().text = """ + rootProject.name = 'invalid-sources' + """ + + Path sourceDirectory = projectDir.resolve("src").resolve("main").resolve("groovy") + sourceDirectory.toFile().mkdirs() + + sourceDirectory.resolve("Example.groovy").toFile().text = """ + class Example { + String name + } + """ + + projectDir.resolve('build.gradle').toFile().text = """ + buildscript { + repositories { + maven { url "\${System.getenv('LOCAL_MAVEN_PATH')}\" } + maven { url = 'https://repo.grails.org/grails/core' } + } + dependencies { + classpath "org.grails:grails-gradle-plugin:\$grailsGradlePluginVersion" + } + } + + version "0.0.1-SNAPSHOT" + group "org.grails.example" + + apply plugin: 'java-library' + apply plugin: 'groovy' + + repositories { + maven { url = 'https://repo.grails.org/grails/core' } + } + + dependencies { + implementation 'org.apache.groovy:groovy-all:4.0.24' + } + + apply plugin: 'org.grails.grails-publish' + grailsPublish { + githubSlug = 'grails/grails-gradle-plugin' + license { + name = 'Apache-2.0' + } + title = 'Grails Gradle Plugin - Example Project' + desc = 'A testing project for the grails gradle plugin' + developers = [ + jdaugherty: 'James Daugherty', + ] + } + """ + + when: + def assembleResult = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", assembleResult) + assertBuildSuccess(assembleResult, ["compileJava", "processResources"]) + + when: + runner = addEnvironmentVariable("MAVEN_PUBLISH_USERNAME", "publishUser", runner) + runner = addEnvironmentVariable("MAVEN_PUBLISH_PASSWORD", "publishPassword", runner) + + executeTask("publish", runner) + + then: + UnexpectedBuildFailure bf = thrown(UnexpectedBuildFailure) + bf.buildResult.output.contains("Could not locate a project property of `mavenPublishUrl` or an environment variable of `MAVEN_PUBLISH_URL`. A URL is required for maven publishing.") + } + def "project without sources fails grailsPublish apply"() { given: Path projectDir = createProjectDir("invalid-sources") From c9a83142cb358ec23f19c161ceb7d83575942eae Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Wed, 18 Dec 2024 19:03:03 -0500 Subject: [PATCH 07/14] Sign MAVEN_PUBLISH publishes --- .../GrailsPublishGradlePlugin.groovy | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy index b37eeeca..6b3ef8d9 100644 --- a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy @@ -46,6 +46,8 @@ import static com.bmuschko.gradle.nexus.NexusPlugin.getSIGNING_KEYRING class GrailsPublishGradlePlugin implements Plugin { public static String NEXUS_PUBLISH_PLUGIN_ID = 'io.github.gradle-nexus.publish-plugin' + public static String MAVEN_PUBLISH_PLUGIN_ID = 'maven-publish' + public static String SIGNING_PLUGIN_ID = 'signing' String getErrorMessage(String missingSetting) { return """No '$missingSetting' was specified. Please provide a valid publishing configuration. Example: @@ -155,26 +157,33 @@ Note: if project properties are used, the properties must be defined prior to ap final PluginManager projectPluginManager = project.pluginManager projectPluginManager.apply(MavenPublishPlugin) + if (isRelease || useNexusPublish) { + if (project.pluginManager.hasPlugin(SIGNING_PLUGIN_ID)) { + project.logger.debug("Signing Plugin already applied to project ${project.name}") + } else { + projectPluginManager.apply(SigningPlugin) + } + + project.tasks.withType(Sign).configureEach { Sign task -> + task.onlyIf { isRelease } + } + } + if (useNexusPublish) { // The nexus plugin is special since it must always be applied to the root project. // Handle when multiple subprojects exist and grailsPublish is defined in each one instead of at the root. final PluginManager rootProjectPluginManager = project.rootProject.pluginManager boolean hasNexusPublishApplied = rootProjectPluginManager.hasPlugin(NEXUS_PUBLISH_PLUGIN_ID) if (hasNexusPublishApplied) { - project.rootProject.logger.info("Nexus Publish Plugin already applied to root project") - } - else { + project.rootProject.logger.debug("Nexus Publish Plugin already applied to root project") + } else { rootProjectPluginManager.apply(NexusPublishPlugin) } - projectPluginManager.apply(SigningPlugin) - - project.rootProject.tasks.withType(InitializeNexusStagingRepository).configureEach { InitializeNexusStagingRepository task -> - task.shouldRunAfter = project.tasks.withType(Sign) - } - - project.tasks.withType(Sign) { - onlyIf { isRelease } + if(isRelease) { + project.rootProject.tasks.withType(InitializeNexusStagingRepository).configureEach { InitializeNexusStagingRepository task -> + task.shouldRunAfter = project.tasks.withType(Sign) + } } if (!hasNexusPublishApplied) { @@ -337,7 +346,7 @@ Note: if project properties are used, the properties must be defined prior to ap } } - if (useNexusPublish) { + if (isRelease) { extensionContainer.configure(SigningExtension, { it.required = isRelease it.sign project.publishing.publications.maven From a13bea0152c610e80fa007792f5bcd6e53d9d363 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Wed, 18 Dec 2024 19:20:00 -0500 Subject: [PATCH 08/14] Move tests to their own sourceSet & ensure the project version is published to the local repo before running e2e tests --- build.gradle | 15 +--------- gradle/e2eTest.gradle | 29 +++++++++++++++++++ .../gradle/test/GradleSpecification.groovy | 2 +- .../test/GrailsPublishPluginSpec.groovy | 0 .../build.gradle | 0 .../gradle.properties | 0 .../settings.gradle | 0 .../org/grails/example/SubProject1.groovy | 0 .../org/grails/example/SubProject2.groovy | 0 .../build.gradle | 0 .../gradle.properties | 0 .../settings.gradle | 0 .../org/grails/example/SubProject1.groovy | 0 .../org.grails.example/SubProject2.groovy | 0 .../build.gradle | 0 .../gradle.properties | 0 .../settings.gradle | 0 .../org/grails/example/SubProject1.groovy | 0 .../subproject2/build.gradle | 0 .../org.grails.example/SubProject2.groovy | 0 .../build.gradle | 0 .../gradle.properties | 0 .../settings.gradle | 0 .../org/grails/example/SubProject1.groovy | 0 .../subproject2/build.gradle | 0 .../org.grails.example/SubProject2.groovy | 0 .../build.gradle | 0 .../gradle.properties | 0 .../settings.gradle | 0 .../subproject1/build.gradle | 0 .../org/grails/example/SubProject1.groovy | 0 .../subproject2/build.gradle | 0 .../org.grails.example/SubProject2.groovy | 0 .../build.gradle | 0 .../gradle.properties | 0 .../settings.gradle | 0 .../org/grails/example/SubProject1.groovy | 0 .../subproject2/build.gradle | 0 .../org.grails.example/SubProject2.groovy | 0 .../build.gradle | 0 .../gradle.properties | 0 .../settings.gradle | 0 .../org/grails/example/SubProject1.groovy | 0 .../subproject2/build.gradle | 0 .../org.grails.example/SubProject2.groovy | 0 .../build.gradle | 0 .../gradle.properties | 0 .../settings.gradle | 0 .../subproject1/build.gradle | 0 .../org/grails/example/SubProject1.groovy | 0 .../subproject2/build.gradle | 0 .../org.grails.example/SubProject2.groovy | 0 52 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 gradle/e2eTest.gradle rename src/{test => e2eTest}/groovy/org/grails/gradle/test/GradleSpecification.groovy (97%) rename src/{test => e2eTest}/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/build.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/gradle.properties (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/settings.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/subproject2/src/main/groovy/org/grails/example/SubProject2.groovy (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/build.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/gradle.properties (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/settings.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/build.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/gradle.properties (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/settings.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/src/main/groovy/org/grails/example/SubProject1.groovy (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/subproject2/build.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/build.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/gradle.properties (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/settings.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/src/main/groovy/org/grails/example/SubProject1.groovy (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/subproject2/build.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/build.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/gradle.properties (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/settings.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject1/build.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject2/build.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy (100%) rename src/{test => e2eTest}/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/build.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/gradle.properties (100%) rename src/{test => e2eTest}/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/settings.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/src/main/groovy/org/grails/example/SubProject1.groovy (100%) rename src/{test => e2eTest}/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/subproject2/build.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy (100%) rename src/{test => e2eTest}/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/build.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/gradle.properties (100%) rename src/{test => e2eTest}/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/settings.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/src/main/groovy/org/grails/example/SubProject1.groovy (100%) rename src/{test => e2eTest}/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/subproject2/build.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy (100%) rename src/{test => e2eTest}/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/build.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/gradle.properties (100%) rename src/{test => e2eTest}/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/settings.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject1/build.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy (100%) rename src/{test => e2eTest}/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject2/build.gradle (100%) rename src/{test => e2eTest}/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy (100%) diff --git a/build.gradle b/build.gradle index 79941875..a874db2a 100644 --- a/build.gradle +++ b/build.gradle @@ -107,20 +107,6 @@ dependencies { implementation "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion" implementation "org.springframework.boot:spring-boot-loader-tools:$springBootVersion" implementation "io.spring.gradle:dependency-management-plugin:$springGradleDependencyManagementVersion" - - // Note: must use a groovy 3 compatible version of Spock - testImplementation "org.spockframework:spock-core:${project['spock.version']}", { - exclude group: 'org.apache.groovy' - } - testImplementation 'commons-io:commons-io:2.18.0' - testImplementation gradleTestKit() - testRuntimeOnly 'org.junit.platform:junit-platform-launcher' -} - -tasks.withType(Test).configureEach { - useJUnitPlatform() - systemProperty("localMavenPath", rootProject.layout.buildDirectory.dir('local-maven').get().asFile.absolutePath) - systemProperty("grailsGradlePluginVersion", rootProject.version) } gradlePlugin { @@ -327,3 +313,4 @@ tasks.named("build").configure { finalizedBy("groovydoc") } +apply from: rootProject.layout.projectDirectory.file('gradle/e2eTest.gradle') \ No newline at end of file diff --git a/gradle/e2eTest.gradle b/gradle/e2eTest.gradle new file mode 100644 index 00000000..9226c082 --- /dev/null +++ b/gradle/e2eTest.gradle @@ -0,0 +1,29 @@ +def e2eTest = sourceSets.create('e2eTest') +def e2eTestTask = tasks.register('e2eTest', Test) { + group = 'verification' + testClassesDirs = sourceSets.e2eTest.output.classesDirs + classpath = sourceSets.e2eTest.runtimeClasspath + useJUnitPlatform() + systemProperty("localMavenPath", rootProject.layout.buildDirectory.dir('local-maven').get().asFile.absolutePath) + systemProperty("grailsGradlePluginVersion", rootProject.version) + + dependsOn "publishAllPublicationsToTestCaseMavenRepoRepository" +} + +tasks.named("check") { + dependsOn e2eTestTask +} + +gradlePlugin { + testSourceSets e2eTest +} + +dependencies { + // Note: must use a groovy 3 compatible version of Spock + e2eTestImplementation "org.spockframework:spock-core:${project['spock.version']}", { + exclude group: 'org.apache.groovy' + } + e2eTestImplementation 'commons-io:commons-io:2.18.0' + e2eTestImplementation gradleTestKit() + e2eTestRuntimeOnly 'org.junit.platform:junit-platform-launcher' +} \ No newline at end of file diff --git a/src/test/groovy/org/grails/gradle/test/GradleSpecification.groovy b/src/e2eTest/groovy/org/grails/gradle/test/GradleSpecification.groovy similarity index 97% rename from src/test/groovy/org/grails/gradle/test/GradleSpecification.groovy rename to src/e2eTest/groovy/org/grails/gradle/test/GradleSpecification.groovy index bdf95d71..6a44c04e 100644 --- a/src/test/groovy/org/grails/gradle/test/GradleSpecification.groovy +++ b/src/e2eTest/groovy/org/grails/gradle/test/GradleSpecification.groovy @@ -72,7 +72,7 @@ abstract class GradleSpecification extends Specification { Path destinationDir = basePath.resolve(type) Files.createDirectories(destinationDir) - Path sourceProjectDir = Path.of("src/test/resources/publish-projects/$type/$projectName") + Path sourceProjectDir = Path.of("src/e2eTest/resources/publish-projects/$type/$projectName") FileUtils.copyDirectoryToDirectory(sourceProjectDir.toFile(), destinationDir.toFile()) setupProject(destinationDir.resolve(projectName)) diff --git a/src/test/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy b/src/e2eTest/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy similarity index 100% rename from src/test/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy rename to src/e2eTest/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/build.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/build.gradle similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/build.gradle rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/build.gradle diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/gradle.properties b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/gradle.properties similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/gradle.properties rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/gradle.properties diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/settings.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/settings.gradle similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/settings.gradle rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/settings.gradle diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/subproject2/src/main/groovy/org/grails/example/SubProject2.groovy b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/subproject2/src/main/groovy/org/grails/example/SubProject2.groovy similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/subproject2/src/main/groovy/org/grails/example/SubProject2.groovy rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-all/subproject2/src/main/groovy/org/grails/example/SubProject2.groovy diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/build.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/build.gradle similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/build.gradle rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/build.gradle diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/gradle.properties b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/gradle.properties similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/gradle.properties rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/gradle.properties diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/settings.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/settings.gradle similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/settings.gradle rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/settings.gradle diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-no-subproject-build-gradle-publish-per-project/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/build.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/build.gradle similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/build.gradle rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/build.gradle diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/gradle.properties b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/gradle.properties similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/gradle.properties rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/gradle.properties diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/settings.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/settings.gradle similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/settings.gradle rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/settings.gradle diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/src/main/groovy/org/grails/example/SubProject1.groovy b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/src/main/groovy/org/grails/example/SubProject1.groovy similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/src/main/groovy/org/grails/example/SubProject1.groovy rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/src/main/groovy/org/grails/example/SubProject1.groovy diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/subproject2/build.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/subproject2/build.gradle similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/subproject2/build.gradle rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/subproject2/build.gradle diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-child-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/build.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/build.gradle similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/build.gradle rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/build.gradle diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/gradle.properties b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/gradle.properties similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/gradle.properties rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/gradle.properties diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/settings.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/settings.gradle similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/settings.gradle rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/settings.gradle diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/src/main/groovy/org/grails/example/SubProject1.groovy b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/src/main/groovy/org/grails/example/SubProject1.groovy similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/src/main/groovy/org/grails/example/SubProject1.groovy rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/src/main/groovy/org/grails/example/SubProject1.groovy diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/subproject2/build.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/subproject2/build.gradle similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/subproject2/build.gradle rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/subproject2/build.gradle diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-parent-child-setup-per-project-parent-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/build.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/build.gradle similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/build.gradle rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/build.gradle diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/gradle.properties b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/gradle.properties similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/gradle.properties rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/gradle.properties diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/settings.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/settings.gradle similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/settings.gradle rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/settings.gradle diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject1/build.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject1/build.gradle similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject1/build.gradle rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject1/build.gradle diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject2/build.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject2/build.gradle similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject2/build.gradle rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject2/build.gradle diff --git a/src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy b/src/e2eTest/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy similarity index 100% rename from src/test/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy rename to src/e2eTest/resources/publish-projects/legacy-apply/multi-project-with-subproject-gradle/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/build.gradle b/src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/build.gradle similarity index 100% rename from src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/build.gradle rename to src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/build.gradle diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/gradle.properties b/src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/gradle.properties similarity index 100% rename from src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/gradle.properties rename to src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/gradle.properties diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/settings.gradle b/src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/settings.gradle similarity index 100% rename from src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/settings.gradle rename to src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/settings.gradle diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/src/main/groovy/org/grails/example/SubProject1.groovy b/src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/src/main/groovy/org/grails/example/SubProject1.groovy similarity index 100% rename from src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/src/main/groovy/org/grails/example/SubProject1.groovy rename to src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/src/main/groovy/org/grails/example/SubProject1.groovy diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/subproject2/build.gradle b/src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/subproject2/build.gradle similarity index 100% rename from src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/subproject2/build.gradle rename to src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/subproject2/build.gradle diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy b/src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy similarity index 100% rename from src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy rename to src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-child-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/build.gradle b/src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/build.gradle similarity index 100% rename from src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/build.gradle rename to src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/build.gradle diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/gradle.properties b/src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/gradle.properties similarity index 100% rename from src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/gradle.properties rename to src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/gradle.properties diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/settings.gradle b/src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/settings.gradle similarity index 100% rename from src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/settings.gradle rename to src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/settings.gradle diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/src/main/groovy/org/grails/example/SubProject1.groovy b/src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/src/main/groovy/org/grails/example/SubProject1.groovy similarity index 100% rename from src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/src/main/groovy/org/grails/example/SubProject1.groovy rename to src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/src/main/groovy/org/grails/example/SubProject1.groovy diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/subproject2/build.gradle b/src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/subproject2/build.gradle similarity index 100% rename from src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/subproject2/build.gradle rename to src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/subproject2/build.gradle diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy b/src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy similarity index 100% rename from src/test/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy rename to src/e2eTest/resources/publish-projects/plugins-block/multi-project-parent-child-setup-per-project-parent-published/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/build.gradle b/src/e2eTest/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/build.gradle similarity index 100% rename from src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/build.gradle rename to src/e2eTest/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/build.gradle diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/gradle.properties b/src/e2eTest/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/gradle.properties similarity index 100% rename from src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/gradle.properties rename to src/e2eTest/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/gradle.properties diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/settings.gradle b/src/e2eTest/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/settings.gradle similarity index 100% rename from src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/settings.gradle rename to src/e2eTest/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/settings.gradle diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject1/build.gradle b/src/e2eTest/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject1/build.gradle similarity index 100% rename from src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject1/build.gradle rename to src/e2eTest/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject1/build.gradle diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy b/src/e2eTest/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy similarity index 100% rename from src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy rename to src/e2eTest/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject1/src/main/groovy/org/grails/example/SubProject1.groovy diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject2/build.gradle b/src/e2eTest/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject2/build.gradle similarity index 100% rename from src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject2/build.gradle rename to src/e2eTest/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject2/build.gradle diff --git a/src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy b/src/e2eTest/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy similarity index 100% rename from src/test/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy rename to src/e2eTest/resources/publish-projects/plugins-block/multi-project-with-subproject-gradle/subproject2/src/main/groovy/org.grails.example/SubProject2.groovy From 5f0f6898a5f31f624f3bf2831fba63c2eb504e25 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Wed, 18 Dec 2024 19:33:25 -0500 Subject: [PATCH 09/14] Only run tests on forks --- .github/workflows/gradle.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index feb785d6..7f678452 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -32,7 +32,7 @@ jobs: DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} run: ./gradlew build publish: - if: github.event_name == 'push' + if: github.event_name == 'push' && github.repository_owner == 'grails' needs: ['build'] runs-on: ubuntu-latest steps: @@ -59,7 +59,7 @@ jobs: -Dorg.gradle.internal.publish.checksums.insecure=true publish docs: - if: github.event_name == 'push' + if: github.event_name == 'push' && github.repository_owner == 'grails' needs: publish runs-on: ubuntu-latest permissions: From d47f18fbdb59b71a3ed56636f5a911ea43b954eb Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Wed, 18 Dec 2024 19:34:55 -0500 Subject: [PATCH 10/14] Only run release-notes on non-forks & on push (secrets not available) --- .github/workflows/release-notes.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release-notes.yml b/.github/workflows/release-notes.yml index 047a467d..09548650 100644 --- a/.github/workflows/release-notes.yml +++ b/.github/workflows/release-notes.yml @@ -12,6 +12,7 @@ on: workflow_dispatch: jobs: release_notes: + if: github.event_name == 'push' && github.repository_owner == 'grails' permissions: contents: read runs-on: ubuntu-latest From 227bcf9e5726ba6a6a45581b04f89e0cdc534dd4 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Wed, 18 Dec 2024 19:36:34 -0500 Subject: [PATCH 11/14] Add test logging --- gradle/e2eTest.gradle | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gradle/e2eTest.gradle b/gradle/e2eTest.gradle index 9226c082..3081a903 100644 --- a/gradle/e2eTest.gradle +++ b/gradle/e2eTest.gradle @@ -7,6 +7,12 @@ def e2eTestTask = tasks.register('e2eTest', Test) { systemProperty("localMavenPath", rootProject.layout.buildDirectory.dir('local-maven').get().asFile.absolutePath) systemProperty("grailsGradlePluginVersion", rootProject.version) + testLogging { + exceptionFormat = 'full' + events 'passed', 'skipped', 'failed', 'standardOut', 'standardError' + } + beforeTest { descriptor -> logger.quiet " -- $descriptor" } + dependsOn "publishAllPublicationsToTestCaseMavenRepoRepository" } From 142a5e0b5c204780d532918699fb8c2cf78c0b9a Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Wed, 18 Dec 2024 20:27:52 -0500 Subject: [PATCH 12/14] Add nested project that is not included in parent's project --- .../gradle/test/GradleSpecification.groovy | 4 +- .../test/GrailsPublishPluginSpec.groovy | 138 ++++++++++++++++++ .../build.gradle | 36 +++++ .../gradle.properties | 1 + .../otherProject/build.gradle | 14 ++ .../otherProject/gradle.properties | 1 + .../otherProject/settings.gradle | 4 + .../org.grails.example/SubProject2.groovy | 7 + .../settings.gradle | 1 + .../org/grails/example/SubProject1.groovy | 7 + .../build.gradle | 38 +++++ .../gradle.properties | 1 + .../otherProject/build.gradle | 26 ++++ .../otherProject/gradle.properties | 1 + .../otherProject/settings.gradle | 4 + .../org.grails.example/SubProject2.groovy | 7 + .../settings.gradle | 1 + .../org/grails/example/SubProject1.groovy | 7 + 18 files changed, 296 insertions(+), 2 deletions(-) create mode 100644 src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/build.gradle create mode 100644 src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/gradle.properties create mode 100644 src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/build.gradle create mode 100644 src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/gradle.properties create mode 100644 src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/settings.gradle create mode 100644 src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/src/main/groovy/org.grails.example/SubProject2.groovy create mode 100644 src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/settings.gradle create mode 100644 src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/src/main/groovy/org/grails/example/SubProject1.groovy create mode 100644 src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/build.gradle create mode 100644 src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/gradle.properties create mode 100644 src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/build.gradle create mode 100644 src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/gradle.properties create mode 100644 src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/settings.gradle create mode 100644 src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/src/main/groovy/org.grails.example/SubProject2.groovy create mode 100644 src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/settings.gradle create mode 100644 src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/src/main/groovy/org/grails/example/SubProject1.groovy diff --git a/src/e2eTest/groovy/org/grails/gradle/test/GradleSpecification.groovy b/src/e2eTest/groovy/org/grails/gradle/test/GradleSpecification.groovy index 6a44c04e..637fae03 100644 --- a/src/e2eTest/groovy/org/grails/gradle/test/GradleSpecification.groovy +++ b/src/e2eTest/groovy/org/grails/gradle/test/GradleSpecification.groovy @@ -66,7 +66,7 @@ abstract class GradleSpecification extends Specification { FileUtils.deleteQuietly(basePath.toFile()) } - protected GradleRunner setupTestResourceProject(String type, String projectName) { + protected GradleRunner setupTestResourceProject(String type, String projectName, String nestedProject = null) { Objects.requireNonNull(projectName, "projectName must not be null") Path destinationDir = basePath.resolve(type) @@ -75,7 +75,7 @@ abstract class GradleSpecification extends Specification { Path sourceProjectDir = Path.of("src/e2eTest/resources/publish-projects/$type/$projectName") FileUtils.copyDirectoryToDirectory(sourceProjectDir.toFile(), destinationDir.toFile()) - setupProject(destinationDir.resolve(projectName)) + setupProject(destinationDir.resolve(projectName).resolve(nestedProject ?: '.')) } protected GradleRunner setupProject(Path projectDirectory) { diff --git a/src/e2eTest/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy b/src/e2eTest/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy index 821d43b2..083edd2b 100644 --- a/src/e2eTest/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy +++ b/src/e2eTest/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy @@ -49,6 +49,34 @@ class GrailsPublishPluginSpec extends GradleSpecification { !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") } + def "gradle config works when not publishing - snapshot - maven publish - legacy-apply - child-project-with-unrelated-parent - eval parent"() { + given: + GradleRunner runner = setupTestResourceProject('legacy-apply', 'child-project-with-unrelated-parent') + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") + } + + def "gradle config works when not publishing - snapshot - maven publish - legacy-apply - child-project-with-unrelated-parent - eval child"() { + given: + GradleRunner runner = setupTestResourceProject('legacy-apply', 'child-project-with-unrelated-parent', 'otherProject') + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") + } + def "gradle config works when not publishing - snapshot - maven publish - legacy-apply - multi-project-parent-child-setup-per-project-child-published"() { given: GradleRunner runner = setupTestResourceProject('legacy-apply', 'multi-project-parent-child-setup-per-project-child-published') @@ -92,6 +120,36 @@ class GrailsPublishPluginSpec extends GradleSpecification { result.output.contains("Project subproject1 does not have a version defined. Using the gradle property `projectVersion` to assume version is 0.0.1-SNAPSHOT.") } + def "gradle config works when not publishing - snapshot - maven publish - plugins-block - child-project-with-unrelated-parent - eval parent"() { + given: + GradleRunner runner = setupTestResourceProject('plugins-block', 'child-project-with-unrelated-parent') + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("Project subproject2 does not have a version defined. Using the gradle property `projectVersion` to assume version is 0.0.1-SNAPSHOT.") + result.output.contains("Project subproject1 does not have a version defined. Using the gradle property `projectVersion` to assume version is 0.0.1-SNAPSHOT.") + } + + def "gradle config works when not publishing - snapshot - maven publish - plugins-block - child-project-with-unrelated-parent - eval child"() { + given: + GradleRunner runner = setupTestResourceProject('plugins-block', 'child-project-with-unrelated-parent', 'otherProject') + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("Project subproject2 does not have a version defined. Using the gradle property `projectVersion` to assume version is 0.0.1-SNAPSHOT.") + result.output.contains("Project subproject1 does not have a version defined. Using the gradle property `projectVersion` to assume version is 0.0.1-SNAPSHOT.") + } + def "gradle config works when not publishing - snapshot - maven publish - plugins-block - multi-project-parent-child-setup-per-project-child-published"() { given: GradleRunner runner = setupTestResourceProject('plugins-block', 'multi-project-parent-child-setup-per-project-child-published') @@ -180,6 +238,46 @@ class GrailsPublishPluginSpec extends GradleSpecification { !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") } + def "gradle config works when not publishing - milestone - maven publish - legacy-apply - child-project-with-unrelated-parent - eval parent"() { + given: + GradleRunner runner = setupTestResourceProject('legacy-apply', 'child-project-with-unrelated-parent') + + setGradleProperty( + "projectVersion", + "0.0.1-M1", + runner + ) + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") + } + + def "gradle config works when not publishing - milestone - maven publish - legacy-apply - child-project-with-unrelated-parent - eval child"() { + given: + GradleRunner runner = setupTestResourceProject('legacy-apply', 'child-project-with-unrelated-parent', 'otherProject') + + setGradleProperty( + "projectVersion", + "0.0.1-M1", + runner + ) + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") + } + @PendingFeature(reason = "Failed to apply plugin class 'io.github.gradlenexus.publishplugin.NexusPublishPlugin'") def "gradle config works when not publishing - milestone - maven publish - legacy-apply - multi-project-parent-child-setup-per-project-child-published"() { given: @@ -242,6 +340,46 @@ class GrailsPublishPluginSpec extends GradleSpecification { result.output.contains("Project subproject1 does not have a version defined. Using the gradle property `projectVersion` to assume version is 0.0.1-M1.") } + def "gradle config works when not publishing - milestone - maven publish - plugins-block - child-project-with-unrelated-parent - eval parent"() { + given: + GradleRunner runner = setupTestResourceProject('plugins-block', 'child-project-with-unrelated-parent') + + setGradleProperty( + "projectVersion", + "0.0.1-M1", + runner + ) + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + + result.output.contains("Project subproject1 does not have a version defined. Using the gradle property `projectVersion` to assume version is 0.0.1-M1.") + } + + def "gradle config works when not publishing - milestone - maven publish - plugins-block - child-project-with-unrelated-parent - eval child"() { + given: + GradleRunner runner = setupTestResourceProject('plugins-block', 'child-project-with-unrelated-parent', 'otherProject') + + setGradleProperty( + "projectVersion", + "0.0.1-M1", + runner + ) + + when: + def result = executeTask("assemble", runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + + result.output.contains("Project subproject1 does not have a version defined. Using the gradle property `projectVersion` to assume version is 0.0.1-M1.") + } + @PendingFeature(reason = "Failed to apply plugin class 'io.github.gradlenexus.publishplugin.NexusPublishPlugin'") def "gradle config works when not publishing - milestone - maven publish - plugins-block - multi-project-parent-child-setup-per-project-child-published"() { given: diff --git a/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/build.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/build.gradle new file mode 100644 index 00000000..32bc3f53 --- /dev/null +++ b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/build.gradle @@ -0,0 +1,36 @@ +buildscript { + repositories { + maven { url "${System.getenv('LOCAL_MAVEN_PATH')}" } + maven { url = 'https://repo.grails.org/grails/core' } + } + dependencies { + classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" + } +} + +repositories { + maven { url = 'https://repo.grails.org/grails/core' } +} + +version "${projectVersion}" +group "org.grails.example" + +apply plugin: 'java-library' +apply plugin: 'groovy' + +dependencies { + implementation 'org.apache.groovy:groovy-all:4.0.24' +} + +apply plugin: 'org.grails.grails-publish' +grailsPublish { + githubSlug = 'grails/grails-gradle-plugin' + license { + name = 'Apache-2.0' + } + title = 'Grails Gradle Plugin - Example Project' + desc = 'A testing project for the grails gradle plugin' + developers = [ + jdaugherty: 'James Daugherty', + ] +} \ No newline at end of file diff --git a/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/gradle.properties b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/gradle.properties new file mode 100644 index 00000000..e0f33cc2 --- /dev/null +++ b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/gradle.properties @@ -0,0 +1 @@ +projectVersion=0.0.1-SNAPSHOT \ No newline at end of file diff --git a/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/build.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/build.gradle new file mode 100644 index 00000000..0e8599b1 --- /dev/null +++ b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/build.gradle @@ -0,0 +1,14 @@ +repositories { + maven { url = 'https://repo.grails.org/grails/core' } +} + +version "${projectVersion}" +group "org.grails.example" + +apply plugin: 'java-library' +apply plugin: 'groovy' + +dependencies { + implementation 'org.apache.groovy:groovy-all:4.0.24' + implementation project(":subproject1") +} \ No newline at end of file diff --git a/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/gradle.properties b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/gradle.properties new file mode 100644 index 00000000..e0f33cc2 --- /dev/null +++ b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/gradle.properties @@ -0,0 +1 @@ +projectVersion=0.0.1-SNAPSHOT \ No newline at end of file diff --git a/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/settings.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/settings.gradle new file mode 100644 index 00000000..58158278 --- /dev/null +++ b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/settings.gradle @@ -0,0 +1,4 @@ +rootProject.name = 'otherProject' + +include 'subproject1' +project(':subproject1').projectDir = file('..') \ No newline at end of file diff --git a/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/src/main/groovy/org.grails.example/SubProject2.groovy b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/src/main/groovy/org.grails.example/SubProject2.groovy new file mode 100644 index 00000000..56750d0a --- /dev/null +++ b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/src/main/groovy/org.grails.example/SubProject2.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject2 { + def sayHello() { + println "Hello from SubProject2" + } +} \ No newline at end of file diff --git a/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/settings.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/settings.gradle new file mode 100644 index 00000000..3f172a06 --- /dev/null +++ b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'subproject1' \ No newline at end of file diff --git a/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/src/main/groovy/org/grails/example/SubProject1.groovy b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/src/main/groovy/org/grails/example/SubProject1.groovy new file mode 100644 index 00000000..54df8e20 --- /dev/null +++ b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/src/main/groovy/org/grails/example/SubProject1.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject1 { + def sayHello() { + println "Hello from SubProject1" + } +} \ No newline at end of file diff --git a/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/build.gradle b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/build.gradle new file mode 100644 index 00000000..c4992c10 --- /dev/null +++ b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/build.gradle @@ -0,0 +1,38 @@ +buildscript { + repositories { + maven { url "${System.getenv('LOCAL_MAVEN_PATH')}" } + maven { url = 'https://repo.grails.org/grails/core' } + } + dependencies { + classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" + } +} + +plugins { + id 'java-library' + id 'groovy' + id 'org.grails.grails-publish' +} + +repositories { + maven { url = 'https://repo.grails.org/grails/core' } +} + +version "${projectVersion}" +group "org.grails.example" + +dependencies { + implementation 'org.apache.groovy:groovy-all:4.0.24' +} + +grailsPublish { + githubSlug = 'grails/grails-gradle-plugin' + license { + name = 'Apache-2.0' + } + title = 'Grails Gradle Plugin - Example Project' + desc = 'A testing project for the grails gradle plugin' + developers = [ + jdaugherty: 'James Daugherty', + ] +} \ No newline at end of file diff --git a/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/gradle.properties b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/gradle.properties new file mode 100644 index 00000000..e0f33cc2 --- /dev/null +++ b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/gradle.properties @@ -0,0 +1 @@ +projectVersion=0.0.1-SNAPSHOT \ No newline at end of file diff --git a/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/build.gradle b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/build.gradle new file mode 100644 index 00000000..60f196c2 --- /dev/null +++ b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/build.gradle @@ -0,0 +1,26 @@ +buildscript { + repositories { + maven { url "${System.getenv('LOCAL_MAVEN_PATH')}" } + maven { url = 'https://repo.grails.org/grails/core' } + } + dependencies { + classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" + } +} + +plugins { + id 'java-library' + id 'groovy' +} + +repositories { + maven { url = 'https://repo.grails.org/grails/core' } +} + +version "${projectVersion}" +group "org.grails.example" + +dependencies { + implementation 'org.apache.groovy:groovy-all:4.0.24' + implementation project(":subproject1") +} \ No newline at end of file diff --git a/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/gradle.properties b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/gradle.properties new file mode 100644 index 00000000..e0f33cc2 --- /dev/null +++ b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/gradle.properties @@ -0,0 +1 @@ +projectVersion=0.0.1-SNAPSHOT \ No newline at end of file diff --git a/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/settings.gradle b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/settings.gradle new file mode 100644 index 00000000..58158278 --- /dev/null +++ b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/settings.gradle @@ -0,0 +1,4 @@ +rootProject.name = 'otherProject' + +include 'subproject1' +project(':subproject1').projectDir = file('..') \ No newline at end of file diff --git a/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/src/main/groovy/org.grails.example/SubProject2.groovy b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/src/main/groovy/org.grails.example/SubProject2.groovy new file mode 100644 index 00000000..56750d0a --- /dev/null +++ b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/src/main/groovy/org.grails.example/SubProject2.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject2 { + def sayHello() { + println "Hello from SubProject2" + } +} \ No newline at end of file diff --git a/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/settings.gradle b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/settings.gradle new file mode 100644 index 00000000..3f172a06 --- /dev/null +++ b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'subproject1' \ No newline at end of file diff --git a/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/src/main/groovy/org/grails/example/SubProject1.groovy b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/src/main/groovy/org/grails/example/SubProject1.groovy new file mode 100644 index 00000000..54df8e20 --- /dev/null +++ b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/src/main/groovy/org/grails/example/SubProject1.groovy @@ -0,0 +1,7 @@ +package org.grails.example + +class SubProject1 { + def sayHello() { + println "Hello from SubProject1" + } +} \ No newline at end of file From e75a2b74ece52e7f46317af0f3385e6b0fbd54bd Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Wed, 18 Dec 2024 20:36:31 -0500 Subject: [PATCH 13/14] Fix nested project to use includeBuild instead of include to prevent earlier evaluation --- .../otherProject/build.gradle | 2 +- .../otherProject/settings.gradle | 3 +-- .../otherProject/build.gradle | 2 +- .../otherProject/settings.gradle | 3 +-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/build.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/build.gradle index 0e8599b1..4206a367 100644 --- a/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/build.gradle +++ b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/build.gradle @@ -10,5 +10,5 @@ apply plugin: 'groovy' dependencies { implementation 'org.apache.groovy:groovy-all:4.0.24' - implementation project(":subproject1") + implementation 'org.grails.example:subproject1' } \ No newline at end of file diff --git a/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/settings.gradle b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/settings.gradle index 58158278..41051305 100644 --- a/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/settings.gradle +++ b/src/e2eTest/resources/publish-projects/legacy-apply/child-project-with-unrelated-parent/otherProject/settings.gradle @@ -1,4 +1,3 @@ rootProject.name = 'otherProject' -include 'subproject1' -project(':subproject1').projectDir = file('..') \ No newline at end of file +includeBuild("../") \ No newline at end of file diff --git a/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/build.gradle b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/build.gradle index 60f196c2..ddf7e0cd 100644 --- a/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/build.gradle +++ b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/build.gradle @@ -22,5 +22,5 @@ group "org.grails.example" dependencies { implementation 'org.apache.groovy:groovy-all:4.0.24' - implementation project(":subproject1") + implementation 'org.grails.example:subproject1' } \ No newline at end of file diff --git a/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/settings.gradle b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/settings.gradle index 58158278..41051305 100644 --- a/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/settings.gradle +++ b/src/e2eTest/resources/publish-projects/plugins-block/child-project-with-unrelated-parent/otherProject/settings.gradle @@ -1,4 +1,3 @@ rootProject.name = 'otherProject' -include 'subproject1' -project(':subproject1').projectDir = file('..') \ No newline at end of file +includeBuild("../") \ No newline at end of file From 506e3b98dcc42c4c07d9b81002adfd829c1e6ef3 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Thu, 19 Dec 2024 11:03:50 -0500 Subject: [PATCH 14/14] Support determine a project release or snapshot by the environment variable GRAILS_PUBLISH_RELEASE. --- README.md | 2 + .../gradle/test/GradleSpecification.groovy | 18 +++---- .../test/GrailsPublishPluginSpec.groovy | 47 ++++++++++++++++++- .../GrailsPublishGradlePlugin.groovy | 37 ++++++++++----- 4 files changed, 82 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 05534f39..68b39368 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,8 @@ The credentials and connection url must be specified as a project property or an NEXUS_PUBLISH_SNAPSHOT_URL NEXUS_PUBLISH_STAGING_PROFILE_ID +By default, the release or snapshot state is determined by the project.version or projectVersion gradle property. To override this behavior, use the environment variable `GRAILS_PUBLISH_RELEASE` to decide if it's a release or snapshot. + grails-web --------- * Adds web specific extensions diff --git a/src/e2eTest/groovy/org/grails/gradle/test/GradleSpecification.groovy b/src/e2eTest/groovy/org/grails/gradle/test/GradleSpecification.groovy index 637fae03..239a8135 100644 --- a/src/e2eTest/groovy/org/grails/gradle/test/GradleSpecification.groovy +++ b/src/e2eTest/groovy/org/grails/gradle/test/GradleSpecification.groovy @@ -37,12 +37,11 @@ abstract class GradleSpecification extends Specification { GradleRunner addEnvironmentVariable(String key, String value, GradleRunner runner) { Map environment = runner.environment - if(environment) { + if (environment) { environment.put(key, value) return runner - } - else { + } else { return runner.withEnvironment([(key): value]) } } @@ -54,7 +53,7 @@ abstract class GradleSpecification extends Specification { void cleanup() { basePath.toFile().listFiles().each { // Reuse the gradle cache from previous tests - if(it.name == ".gradle") { + if (it.name == ".gradle") { return } @@ -91,8 +90,11 @@ abstract class GradleSpecification extends Specification { destinationDir } - protected BuildResult executeTask(String taskName, GradleRunner gradleRunner) { - gradleRunner.withArguments(taskName, "--stacktrace").forwardOutput().build() + protected BuildResult executeTask(String taskName, List otherArguments = [], GradleRunner gradleRunner) { + List arguments = [taskName, "--stacktrace"] + arguments.addAll(otherArguments) + + gradleRunner.withArguments(arguments).forwardOutput().build() } protected void assertTaskSuccess(String taskName, BuildResult result) { @@ -112,10 +114,10 @@ abstract class GradleSpecification extends Specification { def results = result.tasks.groupBy { it.outcome } for (String ignoredTaskName : ignoreTaskNames) { - for (BuildTask ignoredTask : result.tasks.findAll { it.path.endsWith("${ignoredTaskName}") }) { + for (BuildTask ignoredTask : result.tasks.findAll { it.path.endsWith("${ignoredTaskName}") }) { def taskOutComeTasks = results.get(ignoredTask.outcome) taskOutComeTasks.remove(ignoredTask) - if(!taskOutComeTasks) { + if (!taskOutComeTasks) { results.remove(ignoredTask.outcome) } } diff --git a/src/e2eTest/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy b/src/e2eTest/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy index 083edd2b..9b3d50b9 100644 --- a/src/e2eTest/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy +++ b/src/e2eTest/groovy/org/grails/gradle/test/GrailsPublishPluginSpec.groovy @@ -12,13 +12,18 @@ class GrailsPublishPluginSpec extends GradleSpecification { GradleRunner runner = setupTestResourceProject('legacy-apply', 'multi-project-no-subproject-build-gradle-publish-all') when: - def result = executeTask("assemble", runner) + def result = executeTask("assemble", ["--info"], runner) then: assertTaskSuccess("assemble", result) assertBuildSuccess(result, ["compileJava", "processResources"]) !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") + !result.output.contains("Environment Variable `GRAILS_PUBLISH_RELEASE` detected - using variable instead of project version.") + result.output.contains("Project subproject1 will be a snapshot.") + !result.output.contains("Project subproject1 will be a release.") + result.output.contains("Project subproject2 will be a snapshot.") + !result.output.contains("Project subproject2 will be a release.") } def "gradle config works when not publishing - snapshot - maven publish - legacy-apply - multi-project-no-subproject-build-gradle-publish-per-project"() { @@ -531,4 +536,44 @@ class GrailsPublishPluginSpec extends GradleSpecification { UnexpectedBuildFailure bf = thrown(UnexpectedBuildFailure) bf.buildResult.output.contains("Cannot apply Grails Publish Plugin. Project invalid-sources does not have any components to publish.") } + + def "project with environment variable based snapshot or release detection - is snapshot"() { + given: + GradleRunner runner = setupTestResourceProject('legacy-apply', 'multi-project-no-subproject-build-gradle-publish-all') + + runner = setGradleProperty("projectVersion", "0.0.1-M1", runner) + runner = addEnvironmentVariable("GRAILS_PUBLISH_RELEASE", "false", runner) + + when: + def result = executeTask("assemble", ["--info"], runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") + result.output.contains("Environment Variable `GRAILS_PUBLISH_RELEASE` detected - using variable instead of project version.") + result.output.contains("Project subproject1 will be a snapshot.") + result.output.contains("Project subproject2 will be a snapshot.") + } + + def "project with environment variable based snapshot or release detection - is release"() { + given: + GradleRunner runner = setupTestResourceProject('legacy-apply', 'multi-project-no-subproject-build-gradle-publish-all') + + runner = setGradleProperty("projectVersion", "0.0.1-SNAPSHOT", runner) + runner = addEnvironmentVariable("GRAILS_PUBLISH_RELEASE", "true", runner) + + when: + def result = executeTask("assemble", ["--info"], runner) + + then: + assertTaskSuccess("assemble", result) + assertBuildSuccess(result, ["compileJava", "processResources"]) + + !result.output.contains("does not have a version defined. Using the gradle property `projectVersion` to assume version is ") + result.output.contains("Environment Variable `GRAILS_PUBLISH_RELEASE` detected - using variable instead of project version.") + result.output.contains("Project subproject1 will be a release.") + result.output.contains("Project subproject2 will be a release.") + } } diff --git a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy index 6b3ef8d9..fccf10b6 100644 --- a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy @@ -48,6 +48,7 @@ class GrailsPublishGradlePlugin implements Plugin { public static String NEXUS_PUBLISH_PLUGIN_ID = 'io.github.gradle-nexus.publish-plugin' public static String MAVEN_PUBLISH_PLUGIN_ID = 'maven-publish' public static String SIGNING_PLUGIN_ID = 'signing' + public static String ENVIRONMENT_VARIABLE_BASED_RELEASE = 'GRAILS_PUBLISH_RELEASE' String getErrorMessage(String missingSetting) { return """No '$missingSetting' was specified. Please provide a valid publishing configuration. Example: @@ -126,22 +127,32 @@ Note: if project properties are used, the properties must be defined prior to ap PublishType snapshotPublishType = gpe.snapshotPublishType PublishType releasePublishType = gpe.releasePublishType - String detectedVersion = (project.version == Project.DEFAULT_VERSION ? (project.findProperty('projectVersion') ?: Project.DEFAULT_VERSION) : project.version) as String - if (detectedVersion == Project.DEFAULT_VERSION) { - throw new IllegalStateException("Project ${project.name} has an unspecified version (neither `version` or the property `projectVersion` is defined). Release state cannot be determined.") - } - if(project.version == Project.DEFAULT_VERSION) { - project.rootProject.logger.warn("Project ${project.name} does not have a version defined. Using the gradle property `projectVersion` to assume version is ${detectedVersion}.") + boolean isSnapshot, isRelease + if (System.getenv(ENVIRONMENT_VARIABLE_BASED_RELEASE) != null) { + // Detect release state based on environment variables instead of versions + isRelease = Boolean.parseBoolean(System.getenv(ENVIRONMENT_VARIABLE_BASED_RELEASE)) + isSnapshot = !isRelease + + project.rootProject.logger.lifecycle("Environment Variable `$ENVIRONMENT_VARIABLE_BASED_RELEASE` detected - using variable instead of project version.") + } else { + String detectedVersion = (project.version == Project.DEFAULT_VERSION ? (project.findProperty('projectVersion') ?: Project.DEFAULT_VERSION) : project.version) as String + if (detectedVersion == Project.DEFAULT_VERSION) { + throw new IllegalStateException("Project ${project.name} has an unspecified version (neither `version` or the property `projectVersion` is defined). Release state cannot be determined.") + } + if (project.version == Project.DEFAULT_VERSION) { + project.rootProject.logger.warn("Project ${project.name} does not have a version defined. Using the gradle property `projectVersion` to assume version is ${detectedVersion}.") + } + project.rootProject.logger.info("Version $detectedVersion detected for project ${project.name}") + + isSnapshot = detectedVersion.endsWith('SNAPSHOT') + isRelease = !isSnapshot } - project.rootProject.logger.info("Version $detectedVersion detected for project ${project.name}") - boolean isSnapshot = detectedVersion.endsWith('SNAPSHOT') if (isSnapshot) { - project.rootProject.logger.info("Snapshot version detected for project ${project.name}") + project.rootProject.logger.info("Project ${project.name} will be a snapshot.") } - boolean isRelease = !isSnapshot if (isRelease) { - project.rootProject.logger.info("Release detected for Project ${project.name}") + project.rootProject.logger.info("Project ${project.name} will be a release.") } boolean useMavenPublish = (isSnapshot && snapshotPublishType == PublishType.MAVEN_PUBLISH) || (isRelease && releasePublishType == PublishType.MAVEN_PUBLISH) @@ -180,7 +191,7 @@ Note: if project properties are used, the properties must be defined prior to ap rootProjectPluginManager.apply(NexusPublishPlugin) } - if(isRelease) { + if (isRelease) { project.rootProject.tasks.withType(InitializeNexusStagingRepository).configureEach { InitializeNexusStagingRepository task -> task.shouldRunAfter = project.tasks.withType(Sign) } @@ -406,7 +417,7 @@ Note: if project properties are used, the properties must be defined prior to ap } private validateProjectState(Project project) { - if(!project.components) { + if (!project.components) { throw new RuntimeException("Cannot apply Grails Publish Plugin. Project ${project.name} does not have any components to publish.") } }