From 91a338dc81c96af860f96bbc1b0380bc52690923 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Tue, 19 Nov 2024 22:18:53 -0500 Subject: [PATCH 1/6] Rework publishing plugins so they can be used externally and on multi-project builds --- .github/workflows/gradle.yml | 58 +++++---- .github/workflows/release.yml | 44 ++++--- README.md | 56 ++++++++- build.gradle | 10 +- settings.gradle | 47 ++++--- .../GrailsProfilePublishGradlePlugin.groovy | 22 +--- .../GrailsPublishExtension.groovy | 61 ++------- ...roovy => GrailsPublishGradlePlugin.groovy} | 118 +++++++----------- .../plugin/publishing/RepositoryType.groovy | 6 + ...g.grails.grails-profile-publish.properties | 1 + .../org.grails.grails-publish.properties | 1 + ....internal.grails-plugin-publish.properties | 1 - ...internal.grails-profile-publish.properties | 1 - 13 files changed, 212 insertions(+), 214 deletions(-) rename src/main/groovy/org/grails/gradle/plugin/profiles/{internal => }/GrailsProfilePublishGradlePlugin.groovy (84%) rename src/main/groovy/org/grails/gradle/plugin/publishing/{internal => }/GrailsPublishExtension.groovy (80%) rename src/main/groovy/org/grails/gradle/plugin/publishing/{internal/GrailsCentralPublishGradlePlugin.groovy => GrailsPublishGradlePlugin.groovy} (77%) create mode 100644 src/main/groovy/org/grails/gradle/plugin/publishing/RepositoryType.groovy create mode 100644 src/main/resources/META-INF/gradle-plugins/org.grails.grails-profile-publish.properties create mode 100644 src/main/resources/META-INF/gradle-plugins/org.grails.grails-publish.properties delete mode 100644 src/main/resources/META-INF/gradle-plugins/org.grails.internal.grails-plugin-publish.properties delete mode 100644 src/main/resources/META-INF/gradle-plugins/org.grails.internal.grails-profile-publish.properties diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 33e79b2c..61078129 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -16,41 +16,50 @@ jobs: env: WORKSPACE: ${{ github.workspace }} steps: - - uses: actions/checkout@v4 - - name: Set up JDK + - name: "📥 Checkout repository" + uses: actions/checkout@v4 + - name: "☕️ Setup JDK" uses: actions/setup-java@v4 with: - distribution: temurin + distribution: liberica java-version: ${{ matrix.java }} - - name: Run Build + - name: "🐘 Setup Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + - name: "🔨 Build project" id: build - uses: gradle/gradle-build-action@v3 env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - with: - arguments: build -Dgeb.env=chromeHeadless + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + run: ./gradlew build publish: if: github.event_name == 'push' needs: ['build'] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Set up JDK + - name: "📥 Checkout repository" + uses: actions/checkout@v4 + - name: "☕️ Setup JDK" uses: actions/setup-java@v4 with: - distribution: temurin + distribution: liberica java-version: 17 - - name: Publish Artifacts (repo.grails.org) + - name: "🐘 Setup Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + - name: "📤 Publish Snapshot Artifacts to Artifactory (repo.grails.org/libs-snapshot-local)" id: publish - uses: gradle/gradle-build-action@v3 env: ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - with: - arguments: | - -Dorg.gradle.internal.publish.checksums.insecure=true - publish + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + run: > + ./gradlew + -Dorg.gradle.internal.publish.checksums.insecure=true + publish docs: if: github.event_name == 'push' needs: publish @@ -61,18 +70,23 @@ jobs: GIT_USER_NAME: puneetbehl GIT_USER_EMAIL: behlp@unityfoundation.io steps: - - name: Checkout repository + - name: "📥 Checkout repository" uses: actions/checkout@v4 - - name: Set up JDK + - name: "☕️ Setup JDK" uses: actions/setup-java@v4 with: - distribution: temurin + distribution: liberica java-version: 17 + - name: "🐘 Setup Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - name: Generate Groovydoc id: groovydoc uses: gradle/gradle-build-action@v3 env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} with: arguments: groovydoc - name: Publish to Github Pages diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1db237d7..98f2de0f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,40 +12,43 @@ jobs: release_version: ${{ steps.release_version.outputs.value }} target_branch: ${{ steps.extract_branch.outputs.value }} env: - GIT_USER_NAME: puneetbehl - GIT_USER_EMAIL: behlp@unityfoundation.io + GIT_USER_NAME: 'grails-build' + GIT_USER_EMAIL: 'grails-build@users.noreply.github.com' steps: - - name: Checkout repository + - name: "📥 Checkout repository" uses: actions/checkout@v4 with: token: ${{ secrets.GH_TOKEN }} - - name: Set up JDK + - name: "☕️ Setup JDK" uses: actions/setup-java@v4 with: - distribution: temurin + distribution: liberica java-version: 17 - - name: Extract Target Branch + - name: "🐘 Setup Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + - name: "📝 Store the target branch" id: extract_branch run: | echo "Determining Target Branch" - TARGET_BRANCH=`cat $GITHUB_EVENT_PATH | jq '.release.target_commitish' | sed -e 's/^"\(.*\)"$/\1/g'` + TARGET_BRANCH=${GITHUB_REF#refs/heads/} echo $TARGET_BRANCH echo "value=${TARGET_BRANCH}" >> $GITHUB_OUTPUT - - name: Set the current release version + - name: "📝 Store the current release version" id: release_version run: echo "value=${GITHUB_REF:11}" >> $GITHUB_OUTPUT - - name: Run pre-release + - name: "⚙️ Run pre-release" uses: micronaut-projects/github-actions/pre-release@master with: token: ${{ secrets.GITHUB_TOKEN }} - - name: Run Assemble + - name: "🧩 Run Assemble" if: success() id: assemble - uses: gradle/gradle-build-action@v3 - with: - arguments: assemble env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + run: ./gradlew assemble - name: Upload Distribution if: success() uses: actions/upload-artifact@v4 @@ -67,7 +70,8 @@ jobs: SIGNING_KEY: ${{ secrets.SIGNING_KEY }} SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }} SECRING_FILE: ${{ secrets.SECRING_FILE }} - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} with: arguments: | -Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg @@ -93,7 +97,8 @@ jobs: - name: Nexus Staging Close And Release uses: gradle/gradle-build-action@v3 env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} @@ -114,8 +119,8 @@ jobs: permissions: contents: write env: - GIT_USER_NAME: puneetbehl - GIT_USER_EMAIL: behlp@unityfoundation.io + GIT_USER_NAME: 'grails-build' + GIT_USER_EMAIL: 'grails-build@users.noreply.github.com' steps: - name: Checkout repository uses: actions/checkout@v4 @@ -131,7 +136,8 @@ jobs: id: groovydoc uses: gradle/gradle-build-action@v3 env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} with: arguments: groovydoc - name: Publish to Github Pages diff --git a/README.md b/README.md index 4e66fcc1..38887d58 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,6 @@ grails-gsp --------- * Configure GSP Compiling Task -grails-plugin-publish ---------- -_Todo_: Add the docs - grails-plugin --------- * Configure Ast Sources @@ -41,6 +37,58 @@ grails-profile --------- _Todo_: Add the docs +grails-profile-publish +--------- +_Todo_: Add the docs + +grails-publish +--------- +A Gradle plugin to simplify publishing to either an Artifactory or Maven Central endpoint for snapshots & to Maven Central for releases. + +Example Usage: + + grailsPublish { + websiteUrl = 'http://foo.com/myplugin' + license { + name = 'Apache-2.0' + } + issueTrackerUrl = 'http://github.com/myname/myplugin/issues' + vcsUrl = 'http://github.com/myname/myplugin' + title = "My plugin title" + desc = "My plugin description" + developers = [johndoe:"John Doe"] + } + +or + + grailsPublish { + githubSlug = 'foo/bar' + license { + name = 'Apache-2.0' + } + title = "My plugin title" + desc = "My plugin description" + developers = [johndoe:"John Doe"] + } + +By default this plugin will publish to the specified Artifactory instance for snapshots, and Maven Central for releases. To change the snapshot publish behavior, you can set the `snapshotRepoType` to `RepositoryType.CENTRAL`. + +The credentials and connection url must be specified as a project property or an environment variable. + +Artifactory Environment Variables are: + + ARTIFACTORY_USERNAME + ARTIFACTORY_PASSWORD + ARTIFACTORY_URL + +Sonatype Environment Variables are: + + SONATYPE_NEXUS_URL + SONATYPE_SNAPSHOT_URL + SONATYPE_USERNAME + SONATYPE_PASSWORD + SONATYPE_STAGING_PROFILE_ID + grails-web --------- * Adds web specific extensions diff --git a/build.gradle b/build.gradle index 546d5c31..a30fa47a 100644 --- a/build.gradle +++ b/build.gradle @@ -138,15 +138,15 @@ gradlePlugin { } grailsPluginPublish { displayName = "Grails Publish Gradle Plugin" - description = 'A plugin to setup publishing to Grails central repo' - id = 'org.grails.internal.grails-plugin-publish' - implementationClass = 'org.grails.gradle.plugin.publishing.internal.GrailsCentralPublishGradlePlugin' + description = 'A plugin to assist in publishing Grails related artifacts' + id = 'org.grails.grails-plugin-publish' + implementationClass = 'org.grails.gradle.plugin.publishing.GrailsCentralPublishGradlePlugin' } grailsProfilePublish { displayName = "Grails Profile Publish Plugin" description = 'A plugin for publishing profiles' - id = 'org.grails.internal.grails-profile-publish' - implementationClass = 'org.grails.gradle.plugin.profiles.internal.GrailsProfilePublishGradlePlugin' + id = 'org.grails.grails-profile-publish' + implementationClass = 'org.grails.gradle.plugin.profiles.GrailsProfilePublishGradlePlugin' } } } diff --git a/settings.gradle b/settings.gradle index 52848cca..1dada324 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,27 +1,34 @@ plugins { -// id "com.gradle.enterprise" version "3.17.2" -// id 'com.gradle.common-custom-user-data-gradle-plugin' version '2.0.1' + id 'com.gradle.develocity' version '3.18.1' + id 'com.gradle.common-custom-user-data-gradle-plugin' version '2.0.2' } -//gradleEnterprise { -// server = 'https://ge.grails.org' -// buildScan { -// publishAlwaysIf(System.getenv('CI') == 'true') -// publishIfAuthenticated() -// uploadInBackground = System.getenv("CI") == null -// capture { -// taskInputFiles = true -// } -// } -//} +def isCI = System.getenv('CI') != null +def isLocal = !isCI +def isAuthenticated = System.getenv('DEVELOCITY_ACCESS_KEY') != null +def isBuildCacheAuthenticated = + System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') != null && + System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') != null -//buildCache { -// local { enabled = System.getenv('CI') != 'true' } -// remote(gradleEnterprise.buildCache) { -// def isAuthenticated = System.getenv('GRADLE_ENTERPRISE_ACCESS_KEY') -// push = System.getenv('CI') == 'true' && isAuthenticated -// enabled = true -// }} +develocity { + server = 'https://ge.grails.org' + buildScan { + publishing.onlyIf { isAuthenticated } + uploadInBackground = isLocal + } +} + +buildCache { + local { enabled = isLocal } + remote(develocity.buildCache) { + push = isCI && isBuildCacheAuthenticated + enabled = true + usernameAndPassword( + System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') ?: '', + System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') ?: '' + ) + } +} rootProject.name = "grails-gradle-plugin" \ No newline at end of file diff --git a/src/main/groovy/org/grails/gradle/plugin/profiles/internal/GrailsProfilePublishGradlePlugin.groovy b/src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfilePublishGradlePlugin.groovy similarity index 84% rename from src/main/groovy/org/grails/gradle/plugin/profiles/internal/GrailsProfilePublishGradlePlugin.groovy rename to src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfilePublishGradlePlugin.groovy index 53d544b5..04d55f15 100644 --- a/src/main/groovy/org/grails/gradle/plugin/profiles/internal/GrailsProfilePublishGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfilePublishGradlePlugin.groovy @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.grails.gradle.plugin.profiles.internal +package org.grails.gradle.plugin.profiles import groovy.transform.CompileStatic @@ -25,8 +25,7 @@ import org.gradle.api.artifacts.DependencySet import org.gradle.api.artifacts.SelfResolvingDependency import org.gradle.api.publish.maven.MavenPublication import org.gradle.api.tasks.bundling.Jar -import org.grails.gradle.plugin.profiles.GrailsProfileGradlePlugin -import org.grails.gradle.plugin.publishing.internal.GrailsCentralPublishGradlePlugin +import org.grails.gradle.plugin.publishing.GrailsPublishGradlePlugin import java.nio.file.Files @@ -39,7 +38,7 @@ import static org.gradle.api.plugins.BasePlugin.BUILD_GROUP * @since 3.1 */ @CompileStatic -class GrailsProfilePublishGradlePlugin extends GrailsCentralPublishGradlePlugin { +class GrailsProfilePublishGradlePlugin extends GrailsPublishGradlePlugin { @Override void apply(Project project) { @@ -55,16 +54,6 @@ class GrailsProfilePublishGradlePlugin extends GrailsCentralPublishGradlePlugin }) } - @Override - protected String getDefaultGrailsCentralReleaseRepo() { - "https://repo.grails.org/grails/libs-releases-local" - } - - @Override - protected String getDefaultGrailsCentralSnapshotRepo() { - "https://repo.grails.org/grails/libs-snapshots-local" - } - @Override protected Map getDefaultExtraArtifact(Project project) { [source: "${project.buildDir}/classes/profile/META-INF/grails-profile/profile.yml".toString(), @@ -77,11 +66,6 @@ class GrailsProfilePublishGradlePlugin extends GrailsCentralPublishGradlePlugin 'profile' } - @Override - protected String getDefaultRepo() { - 'profiles' - } - @Override protected void doAddArtefact(Project project, MavenPublication publication) { publication.artifact(project.tasks.findByName("jar")) diff --git a/src/main/groovy/org/grails/gradle/plugin/publishing/internal/GrailsPublishExtension.groovy b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishExtension.groovy similarity index 80% rename from src/main/groovy/org/grails/gradle/plugin/publishing/internal/GrailsPublishExtension.groovy rename to src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishExtension.groovy index 5e3f060b..bb3fde64 100644 --- a/src/main/groovy/org/grails/gradle/plugin/publishing/internal/GrailsPublishExtension.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishExtension.groovy @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.grails.gradle.plugin.publishing.internal +package org.grails.gradle.plugin.publishing import groovy.transform.CompileStatic import org.gradle.util.ConfigureUtil @@ -25,29 +25,23 @@ import org.gradle.util.ConfigureUtil */ @CompileStatic class GrailsPublishExtension { - - /** - * The slug from github - */ - String githubSlug - /** - * The the publishing user + * Determines the snapshot repository to publish to */ - String user + RepositoryType snapshotRepoType = RepositoryType.ARTIFACTORY /** - * The the publishing key + * The slug from github */ - String key + String githubSlug /** - * The website URL of the plugin + * The website URL of the published project */ String websiteUrl /** - * The source control URL of the plugin + * The source control URL of the project */ String vcsUrl @@ -57,12 +51,12 @@ class GrailsPublishExtension { License license = new License() /** - * The developers of the plugin + * The developers of the project */ Map developers = [:] /** - * Title of the plugin, defaults to the project name + * Title of the project, defaults to the project name */ String title @@ -71,48 +65,11 @@ class GrailsPublishExtension { */ String desc - /** - * THe organisation on bintray - */ - String userOrg - - /** - * THe repository on bintray - */ - String repo - /** * The issue tracker URL */ String issueTrackerUrl - /** - * Whether to GPG sign - */ - boolean gpgSign = false - - /** - * The passphrase to sign, only required if `gpgSign == true` - */ - String signingPassphrase - - /** - * Whether to sync to Maven central - */ - boolean mavenCentralSync = false - - /** - * Username for maven central - */ - String sonatypeOssUsername - - /** - * Password for maven central - */ - String sonatypeOssPassword - - String snapshotUrl - License getLicense() { return license } diff --git a/src/main/groovy/org/grails/gradle/plugin/publishing/internal/GrailsCentralPublishGradlePlugin.groovy b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy similarity index 77% rename from src/main/groovy/org/grails/gradle/plugin/publishing/internal/GrailsCentralPublishGradlePlugin.groovy rename to src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy index 7b9c32ff..29fc27a2 100644 --- a/src/main/groovy/org/grails/gradle/plugin/publishing/internal/GrailsCentralPublishGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy @@ -14,7 +14,7 @@ * limitations under the License. */ //file:noinspection DuplicatedCode -package org.grails.gradle.plugin.publishing.internal +package org.grails.gradle.plugin.publishing import grails.util.GrailsNameUtils import io.github.gradlenexus.publishplugin.NexusPublishPlugin @@ -27,7 +27,6 @@ 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.bundling.Jar import org.gradle.plugins.signing.Sign import org.gradle.plugins.signing.SigningExtension import org.gradle.plugins.signing.SigningPlugin @@ -37,23 +36,17 @@ import static com.bmuschko.gradle.nexus.NexusPlugin.getSIGNING_PASSWORD import static com.bmuschko.gradle.nexus.NexusPlugin.getSIGNING_KEYRING /** - * A plugin to setup publishing to Grails central repo + * A plugin to ease publishing Grails related artifacts * * @author Graeme Rocher * @since 3.1 */ -class GrailsCentralPublishGradlePlugin implements Plugin { +class GrailsPublishGradlePlugin implements Plugin { String getErrorMessage(String missingSetting) { return """No '$missingSetting' was specified. Please provide a valid publishing configuration. Example: grailsPublish { - user = 'user' - key = 'key' - userOrg = 'my-company' // optional, otherwise published to personal bintray account - repo = 'plugins' // optional, defaults to 'plugins' - - websiteUrl = 'http://foo.com/myplugin' license { name = 'Apache-2.0' @@ -68,8 +61,6 @@ grailsPublish { or grailsPublish { - user = 'user' - key = 'key' githubSlug = 'foo/bar' license { name = 'Apache-2.0' @@ -79,15 +70,20 @@ grailsPublish { developers = [johndoe:"John Doe"] } -Your publishing user and key can also be placed in PROJECT_HOME/gradle.properties or USER_HOME/gradle.properties. For example: +The credentials and connection url must be specified as a project property or an environment variable: -bintrayUser=user -bintrayKey=key +Artifactory Environment Variables are: + ARTIFACTORY_USERNAME + ARTIFACTORY_PASSWORD + ARTIFACTORY_URL -Or using environment variables: +Sonatype Environment Variables are: + SONATYPE_NEXUS_URL + SONATYPE_SNAPSHOT_URL + SONATYPE_USERNAME + SONATYPE_PASSWORD + SONATYPE_STAGING_PROFILE_ID -BINTRAY_USER=user -BINTRAY_KEY=key """ } @@ -97,13 +93,14 @@ BINTRAY_KEY=key final TaskContainer taskContainer = project.tasks final GrailsPublishExtension gpe = extensionContainer.create("grailsPublish", GrailsPublishExtension) - final String artifactoryUsername = project.hasProperty("artifactoryPublishUsername") ? project.artifactoryPublishUsername : System.getenv("ARTIFACTORY_USERNAME") ?: '' - final String artifactoryPassword = project.hasProperty("artifactoryPublishPassword") ? project.artifactoryPublishPassword : System.getenv("ARTIFACTORY_PASSWORD") ?: '' - final String ossNexusUrl = project.hasProperty("sonatypeNexusUrl") ? project.sonatypeNexusUrl : System.getenv("SONATYPE_NEXUS_URL") ?: '' - final String ossSnapshotUrl = project.hasProperty("sonatypeSnapshotUrl") ? project.sonatypeSnapshotUrl : System.getenv("SONATYPE_SNAPSHOT_URL") ?: '' - final String ossUser = project.hasProperty("sonatypeOssUsername") ? project.sonatypeOssUsername : System.getenv("SONATYPE_USERNAME") ?: '' - final String ossPass = project.hasProperty("sonatypeOssPassword") ? project.sonatypeOssPassword : System.getenv("SONATYPE_PASSWORD") ?: '' - final String ossStagingProfileId = project.hasProperty("sonatypeOssStagingProfileId") ? project.sonatypeOssStagingProfileId : System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: '' + final String artifactoryUsername = project.findProperty("artifactoryPublishUsername") ?: System.getenv("ARTIFACTORY_USERNAME") ?: '' + final String artifactoryPassword = project.findProperty("artifactoryPublishPassword") ?: System.getenv("ARTIFACTORY_PASSWORD") ?: '' + final String artifactoryPublishUrl = project.findProperty("artifactoryPublishUrl") ?: System.getenv("ARTIFACTORY_URL") ?: '' + final String sonatypeNexusUrl = project.findProperty("sonatypeNexusUrl") ?: System.getenv("SONATYPE_NEXUS_URL") ?: '' + final String sonatypeSnapshotUrl = project.findProperty("sonatypeSnapshotUrl") ?: System.getenv("SONATYPE_SNAPSHOT_URL") ?: '' + final String sonatypeUsername = project.findProperty("sonatypeUsername") ?: System.getenv("SONATYPE_USERNAME") ?: '' + final String sonatypePassword = project.findProperty("sonatypePassword") ?: System.getenv("SONATYPE_PASSWORD") ?: '' + final String sonatypeStagingProfileId = project.findProperty("sonatypeStagingProfileId") ?: System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: '' final ExtraPropertiesExtension extraPropertiesExtension = extensionContainer.findByType(ExtraPropertiesExtension) @@ -111,27 +108,28 @@ BINTRAY_KEY=key extraPropertiesExtension.setProperty(SIGNING_PASSWORD, project.hasProperty(SIGNING_PASSWORD) ? project[SIGNING_PASSWORD] : System.getenv("SIGNING_PASSPHRASE") ?: null) extraPropertiesExtension.setProperty(SIGNING_KEYRING, project.hasProperty(SIGNING_KEYRING) ? project[SIGNING_KEYRING] : System.getenv("SIGNING_KEYRING") ?: null) - project.afterEvaluate { + RepositoryType snapshotType = gpe.snapshotRepoType boolean isSnapshot = project.version.endsWith("SNAPSHOT") boolean isRelease = !isSnapshot - final PluginManager pluginManager = project.getPluginManager() - pluginManager.apply(MavenPublishPlugin.class) - - // Remove "plain" archive classifier, unless bootJar or bootWar are enabled - if (!taskContainer.findByName("bootJar")?.enabled && !taskContainer.findByName("bootWar")?.enabled) { - (taskContainer.findByName("jar") as Jar).archiveClassifier.set("") - } + final PluginManager projectPluginManager = project.getPluginManager() + final PluginManager rootProjectPluginManager = project.rootProject.getPluginManager() + projectPluginManager.apply(MavenPublishPlugin.class) project.publishing { - if (isSnapshot) { + if (isSnapshot && snapshotType == RepositoryType.ARTIFACTORY) { + System.setProperty('org.gradle.internal.publish.checksums.insecure', true as String) repositories { maven { credentials { username = artifactoryUsername password = artifactoryPassword } - url gpe.snapshotUrl? gpe.snapshotUrl : getDefaultGrailsCentralSnapshotRepo() + + if(!artifactoryPublishUrl) { + throw new RuntimeException("Could not locate a project property of `artifactoryPublishUrl` or an environment variable of `ARTIFACTORY_URL` for the snapshot url") + } + url artifactoryPublishUrl } } } @@ -157,6 +155,7 @@ BINTRAY_KEY=key pom.withXml { Node pomNode = asNode() + // Prevent multiple dependencyManagement nodes if (pomNode.dependencyManagement) { pomNode.dependencyManagement[0].replaceNode {} } @@ -234,7 +233,6 @@ BINTRAY_KEY=key } if (gpe.developers) { - delegate.developers { for (entry in gpe.developers.entrySet()) { delegate.developer { @@ -264,37 +262,35 @@ BINTRAY_KEY=key } } - if (isRelease) { - pluginManager.apply(NexusPublishPlugin.class) - pluginManager.apply(SigningPlugin.class) + if (isRelease || (isSnapshot && snapshotType == RepositoryType.CENTRAL)) { + rootProjectPluginManager.apply(NexusPublishPlugin.class) + projectPluginManager.apply(SigningPlugin.class) extensionContainer.configure(SigningExtension, { it.required = isRelease it.sign project.publishing.publications.maven }) - project.tasks.withType(io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository).configureEach { - shouldRunAfter(project.tasks.withType(Sign)) + project.rootProject.tasks.withType(io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository).configureEach { io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository task -> + task.setShouldRunAfter(project.tasks.withType(Sign)) } project.tasks.withType(Sign) { onlyIf { isRelease } } - } - if (isRelease) { - project.nexusPublishing { + project.rootProject.nexusPublishing { repositories { sonatype { - if (ossNexusUrl) { - nexusUrl = project.uri(ossNexusUrl) + if (sonatypeNexusUrl) { + nexusUrl = project.uri(sonatypeNexusUrl) } - if (ossSnapshotUrl) { - snapshotRepositoryUrl = project.uri(ossSnapshotUrl) + if (sonatypeSnapshotUrl) { + snapshotRepositoryUrl = project.uri(sonatypeSnapshotUrl) } - username = ossUser - password = ossPass - stagingProfileId = ossStagingProfileId + username = sonatypeUsername + password = sonatypePassword + stagingProfileId = sonatypeStagingProfileId } } } @@ -323,18 +319,6 @@ BINTRAY_KEY=key publication.from project.components.java } - protected String getDefaultArtifactType() { - "grails-$defaultClassifier" - } - - protected String getDefaultGrailsCentralReleaseRepo() { - "https://repo.grails.org/grails/plugins3-releases-local" - } - - protected String getDefaultGrailsCentralSnapshotRepo() { - "https://repo.grails.org/grails/plugins3-snapshots-local" - } - protected Map getDefaultExtraArtifact(Project project) { String pluginXml = "${project.sourceSets.main.groovy.getClassesDirectory().get().getAsFile()}/META-INF/grails-plugin.xml".toString() new File(pluginXml).exists()? [ @@ -347,13 +331,5 @@ BINTRAY_KEY=key protected String getDefaultClassifier() { "plugin" } - - protected String getDefaultDescription(Project project) { - "Grails ${project.name} $defaultClassifier" - } - - protected String getDefaultRepo() { - "plugins" - } } diff --git a/src/main/groovy/org/grails/gradle/plugin/publishing/RepositoryType.groovy b/src/main/groovy/org/grails/gradle/plugin/publishing/RepositoryType.groovy new file mode 100644 index 00000000..bd141695 --- /dev/null +++ b/src/main/groovy/org/grails/gradle/plugin/publishing/RepositoryType.groovy @@ -0,0 +1,6 @@ +package org.grails.gradle.plugin.publishing + +enum RepositoryType { + ARTIFACTORY, // standard maven repository such as artifactory + CENTRAL // maven central +} diff --git a/src/main/resources/META-INF/gradle-plugins/org.grails.grails-profile-publish.properties b/src/main/resources/META-INF/gradle-plugins/org.grails.grails-profile-publish.properties new file mode 100644 index 00000000..23a14a96 --- /dev/null +++ b/src/main/resources/META-INF/gradle-plugins/org.grails.grails-profile-publish.properties @@ -0,0 +1 @@ +implementation-class=org.grails.gradle.plugin.profiles.GrailsProfilePublishGradlePlugin diff --git a/src/main/resources/META-INF/gradle-plugins/org.grails.grails-publish.properties b/src/main/resources/META-INF/gradle-plugins/org.grails.grails-publish.properties new file mode 100644 index 00000000..81adad31 --- /dev/null +++ b/src/main/resources/META-INF/gradle-plugins/org.grails.grails-publish.properties @@ -0,0 +1 @@ +implementation-class=org.grails.gradle.plugin.publishing.GrailsPublishGradlePlugin diff --git a/src/main/resources/META-INF/gradle-plugins/org.grails.internal.grails-plugin-publish.properties b/src/main/resources/META-INF/gradle-plugins/org.grails.internal.grails-plugin-publish.properties deleted file mode 100644 index 4944dcca..00000000 --- a/src/main/resources/META-INF/gradle-plugins/org.grails.internal.grails-plugin-publish.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=org.grails.gradle.plugin.publishing.internal.GrailsCentralPublishGradlePlugin diff --git a/src/main/resources/META-INF/gradle-plugins/org.grails.internal.grails-profile-publish.properties b/src/main/resources/META-INF/gradle-plugins/org.grails.internal.grails-profile-publish.properties deleted file mode 100644 index 2e332bff..00000000 --- a/src/main/resources/META-INF/gradle-plugins/org.grails.internal.grails-profile-publish.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=org.grails.gradle.plugin.profiles.internal.GrailsProfilePublishGradlePlugin From 7ebd89026d96834036f5026e7a26d6499346df30 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Thu, 21 Nov 2024 13:25:16 -0500 Subject: [PATCH 2/6] Replace Puneet with grails-build --- .github/workflows/gradle.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 61078129..87b81807 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -67,8 +67,8 @@ jobs: permissions: contents: write env: - GIT_USER_NAME: puneetbehl - GIT_USER_EMAIL: behlp@unityfoundation.io + GIT_USER_NAME: 'grails-build' + GIT_USER_EMAIL: 'grails-build@users.noreply.github.com' steps: - name: "📥 Checkout repository" uses: actions/checkout@v4 @@ -102,4 +102,4 @@ jobs: DOC_FOLDER: gh-pages COMMIT_EMAIL: behlp@unityfoundation.io COMMIT_NAME: Puneet Behl - VERSION: ${{ needs.publish.outputs.release_version }} \ No newline at end of file + VERSION: ${{ needs.publish.outputs.release_version }} From c9bc9a2af360805b396d740ad594fb90c2338a65 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Sat, 30 Nov 2024 22:52:17 -0500 Subject: [PATCH 3/6] feedback #355 --- .github/workflows/gradle.yml | 19 ++--- .github/workflows/release.yml | 47 ++++++------ README.md | 27 ++++--- settings.gradle | 2 +- .../publishing/GrailsPublishExtension.groovy | 2 +- .../GrailsPublishGradlePlugin.groovy | 73 ++++++++++--------- .../plugin/publishing/RepositoryTarget.groovy | 6 ++ .../plugin/publishing/RepositoryType.groovy | 6 -- 8 files changed, 92 insertions(+), 90 deletions(-) create mode 100644 src/main/groovy/org/grails/gradle/plugin/publishing/RepositoryTarget.groovy delete mode 100644 src/main/groovy/org/grails/gradle/plugin/publishing/RepositoryType.groovy diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 87b81807..d8e23a9e 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: ['17'] + java: ['17', '21'] env: WORKSPACE: ${{ github.workspace }} steps: @@ -67,8 +67,8 @@ jobs: permissions: contents: write env: - GIT_USER_NAME: 'grails-build' - GIT_USER_EMAIL: 'grails-build@users.noreply.github.com' + GIT_USER_NAME: grails-build + GIT_USER_EMAIL: grails-build@users.noreply.github.com steps: - name: "📥 Checkout repository" uses: actions/checkout@v4 @@ -81,15 +81,13 @@ jobs: uses: gradle/actions/setup-gradle@v4 with: develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - - name: Generate Groovydoc + - name: "📜 Generate Groovydoc" id: groovydoc - uses: gradle/gradle-build-action@v3 env: DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - with: - arguments: groovydoc - - name: Publish to Github Pages + run: ./gradle groovydoc + - name: "🚀 Publish to Github Pages" id: docs if: success() uses: grails/github-pages-deploy-action@v2 @@ -100,6 +98,5 @@ jobs: BRANCH: gh-pages FOLDER: build/docs DOC_FOLDER: gh-pages - COMMIT_EMAIL: behlp@unityfoundation.io - COMMIT_NAME: Puneet Behl - VERSION: ${{ needs.publish.outputs.release_version }} + COMMIT_EMAIL: ${{ env.GIT_USER_EMAIL }} + COMMIT_NAME: ${{ env.GIT_USER_NAME }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 98f2de0f..1199852e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,19 +49,18 @@ jobs: DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} run: ./gradlew assemble - - name: Upload Distribution + - name: "🚀 Upload Distribution" if: success() uses: actions/upload-artifact@v4 with: name: grails-${{ steps.release_version.outputs.value }}.zip path: build/distributions/grails-${{ steps.release_version.outputs.value }}.zip - - name: Generate secring file + - name: "📝 Generate secring file" env: SECRING_FILE: ${{ secrets.SECRING_FILE }} run: echo $SECRING_FILE | base64 -d > ${{ github.workspace }}/secring.gpg - - name: Publish to Sonatype OSSRH + - name: "🚀 Publish to Sonatype OSSRH" id: publish - uses: gradle/gradle-build-action@v3 env: SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} @@ -72,8 +71,8 @@ jobs: SECRING_FILE: ${{ secrets.SECRING_FILE }} DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - with: - arguments: | + run: | + ./gradlew -Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg publishToSonatype closeSonatypeStagingRepository @@ -83,27 +82,31 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@v4 - - name: Set up JDK + - name: "📥 Checkout repository" + uses: actions/checkout@v4 + - name: "☕️ Setup JDK" uses: actions/setup-java@v4 with: - distribution: temurin + distribution: liberica java-version: 17 - - name: Checkout repository + - name: "📥 Checkout repository" uses: actions/checkout@v4 with: token: ${{ secrets.GH_TOKEN }} ref: v${{ needs.publish.outputs.release_version }} + - name: "🐘 Setup Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - name: Nexus Staging Close And Release - uses: gradle/gradle-build-action@v3 env: DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} - with: - arguments: | + run: | + ./gradlew findSonatypeStagingRepository releaseSonatypeStagingRepository - name: Run post-release @@ -122,36 +125,34 @@ jobs: GIT_USER_NAME: 'grails-build' GIT_USER_EMAIL: 'grails-build@users.noreply.github.com' steps: - - name: Checkout repository + - name: "📥 Checkout repository" uses: actions/checkout@v4 with: token: ${{ secrets.GH_TOKEN }} ref: v${{ needs.publish.outputs.release_version }} - - name: Set up JDK + - name: "☕️ Setup JDK" uses: actions/setup-java@v4 with: - distribution: temurin + distribution: liberica java-version: 17 - - name: Generate Groovydoc + - name: "📜 Generate Groovydoc" id: groovydoc - uses: gradle/gradle-build-action@v3 env: DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - with: - arguments: groovydoc - - name: Publish to Github Pages + run: ./gradlew groovydoc + - name: "🚀 Publish to Github Pages" id: docs if: success() uses: grails/github-pages-deploy-action@v2 env: SKIP_SNAPSHOT: ${{ contains(needs.publish.outputs.release_version, 'M') }} - SKIP_LATEST: ${{ !startsWith(needs.publish.outputs.target_branch, '6.1') }} + SKIP_LATEST: ${{ !startsWith(needs.publish.outputs.target_branch, '6.2') }} TARGET_REPOSITORY: ${{ github.repository }} GH_TOKEN: ${{ secrets.GH_TOKEN }} BRANCH: gh-pages FOLDER: build/docs DOC_FOLDER: gh-pages COMMIT_EMAIL: ${{ env.GIT_USER_EMAIL }} - COMMIT_NAME: Puneet Behl + COMMIT_NAME: ${{ env.GIT_USER_NAME }} VERSION: ${{ needs.publish.outputs.release_version }} diff --git a/README.md b/README.md index 38887d58..dd77ee15 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,10 @@ _Todo_: Add the docs grails-publish --------- -A Gradle plugin to simplify publishing to either an Artifactory or Maven Central endpoint for snapshots & to Maven Central for releases. +A Gradle plugin to simplify publishing: + +1. snapshots with either the Maven Publish gradle plugin or Nexus Publish gradle plugin. +2. releases with the Nexus Publish gradle plugin. Example Usage: @@ -52,11 +55,11 @@ Example Usage: license { name = 'Apache-2.0' } - issueTrackerUrl = 'http://github.com/myname/myplugin/issues' - vcsUrl = 'http://github.com/myname/myplugin' - title = "My plugin title" - desc = "My plugin description" - developers = [johndoe:"John Doe"] + issueTrackerUrl = 'https://github.com/myname/myplugin/issues' + vcsUrl = 'https://github.com/myname/myplugin' + title = 'My plugin title' + desc = 'My plugin description' + developers = [johndoe: 'John Doe'] } or @@ -66,22 +69,22 @@ or license { name = 'Apache-2.0' } - title = "My plugin title" - desc = "My plugin description" - developers = [johndoe:"John Doe"] + title = 'My plugin title' + desc = 'My plugin description' + developers = [johndoe: 'John Doe'] } -By default this plugin will publish to the specified Artifactory instance for snapshots, and Maven Central for releases. To change the snapshot publish behavior, you can set the `snapshotRepoType` to `RepositoryType.CENTRAL`. +By default this plugin will publish to the specified `MAVEN_PUBLISH` instance for snapshots, and `NEXUS_PUBLISH` for releases. To change the snapshot publish behavior, you can set the `snapshotRepoType` to `RepositoryTarget.NEXUS_PUBLISH`. The credentials and connection url must be specified as a project property or an environment variable. -Artifactory Environment Variables are: +The `MAVEN_PUBLISH` Environment Variables are: ARTIFACTORY_USERNAME ARTIFACTORY_PASSWORD ARTIFACTORY_URL -Sonatype Environment Variables are: +The `NEXUS_PUBLISH` Environment Variables are: SONATYPE_NEXUS_URL SONATYPE_SNAPSHOT_URL diff --git a/settings.gradle b/settings.gradle index 1dada324..8a07d8a1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,7 +8,7 @@ def isLocal = !isCI def isAuthenticated = System.getenv('DEVELOCITY_ACCESS_KEY') != null def isBuildCacheAuthenticated = System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') != null && - System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') != null + System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') != null develocity { server = 'https://ge.grails.org' diff --git a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishExtension.groovy b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishExtension.groovy index bb3fde64..2fa7934b 100644 --- a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishExtension.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishExtension.groovy @@ -28,7 +28,7 @@ class GrailsPublishExtension { /** * Determines the snapshot repository to publish to */ - RepositoryType snapshotRepoType = RepositoryType.ARTIFACTORY + RepositoryTarget snapshotRepoType = RepositoryTarget.MAVEN_PUBLISH /** * The slug from github 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 29fc27a2..8bca82f5 100644 --- a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy @@ -17,6 +17,7 @@ package org.grails.gradle.plugin.publishing import grails.util.GrailsNameUtils +import io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository import io.github.gradlenexus.publishplugin.NexusPublishPlugin import org.gradle.api.Plugin import org.gradle.api.Project @@ -51,11 +52,11 @@ grailsPublish { license { name = 'Apache-2.0' } - issueTrackerUrl = 'http://github.com/myname/myplugin/issues' - vcsUrl = 'http://github.com/myname/myplugin' - title = "My plugin title" - desc = "My plugin description" - developers = [johndoe:"John Doe"] + issueTrackerUrl = 'https://github.com/myname/myplugin/issues' + vcsUrl = 'https://github.com/myname/myplugin' + title = 'My plugin title' + desc = 'My plugin description' + developers = [johndoe: 'John Doe'] } or @@ -65,19 +66,19 @@ grailsPublish { license { name = 'Apache-2.0' } - title = "My plugin title" - desc = "My plugin description" - developers = [johndoe:"John Doe"] + title = 'My plugin title' + desc = 'My plugin description' + developers = [johndoe: 'John Doe'] } The credentials and connection url must be specified as a project property or an environment variable: -Artifactory Environment Variables are: +`MAVEN_PUBLISH` Environment Variables are: ARTIFACTORY_USERNAME ARTIFACTORY_PASSWORD ARTIFACTORY_URL -Sonatype Environment Variables are: +`NEXUS_PUBLISH` Environment Variables are: SONATYPE_NEXUS_URL SONATYPE_SNAPSHOT_URL SONATYPE_USERNAME @@ -91,33 +92,33 @@ Sonatype Environment Variables are: void apply(Project project) { final ExtensionContainer extensionContainer = project.extensions final TaskContainer taskContainer = project.tasks - final GrailsPublishExtension gpe = extensionContainer.create("grailsPublish", GrailsPublishExtension) + final GrailsPublishExtension gpe = extensionContainer.create('grailsPublish', GrailsPublishExtension) - final String artifactoryUsername = project.findProperty("artifactoryPublishUsername") ?: System.getenv("ARTIFACTORY_USERNAME") ?: '' - final String artifactoryPassword = project.findProperty("artifactoryPublishPassword") ?: System.getenv("ARTIFACTORY_PASSWORD") ?: '' - final String artifactoryPublishUrl = project.findProperty("artifactoryPublishUrl") ?: System.getenv("ARTIFACTORY_URL") ?: '' - final String sonatypeNexusUrl = project.findProperty("sonatypeNexusUrl") ?: System.getenv("SONATYPE_NEXUS_URL") ?: '' - final String sonatypeSnapshotUrl = project.findProperty("sonatypeSnapshotUrl") ?: System.getenv("SONATYPE_SNAPSHOT_URL") ?: '' - final String sonatypeUsername = project.findProperty("sonatypeUsername") ?: System.getenv("SONATYPE_USERNAME") ?: '' - final String sonatypePassword = project.findProperty("sonatypePassword") ?: System.getenv("SONATYPE_PASSWORD") ?: '' - final String sonatypeStagingProfileId = project.findProperty("sonatypeStagingProfileId") ?: System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: '' + final String artifactoryUsername = project.findProperty('artifactoryPublishUsername') ?: System.getenv('ARTIFACTORY_USERNAME') ?: '' + final String artifactoryPassword = project.findProperty('artifactoryPublishPassword') ?: System.getenv('ARTIFACTORY_PASSWORD') ?: '' + final String artifactoryPublishUrl = project.findProperty('artifactoryPublishUrl') ?: System.getenv('ARTIFACTORY_URL') ?: '' + final String sonatypeNexusUrl = project.findProperty('sonatypeNexusUrl') ?: System.getenv('SONATYPE_NEXUS_URL') ?: '' + final String sonatypeSnapshotUrl = project.findProperty('sonatypeSnapshotUrl') ?: System.getenv('SONATYPE_SNAPSHOT_URL') ?: '' + final String sonatypeUsername = project.findProperty('sonatypeUsername') ?: System.getenv('SONATYPE_USERNAME') ?: '' + final String sonatypePassword = project.findProperty('sonatypePassword') ?: System.getenv('SONATYPE_PASSWORD') ?: '' + final String sonatypeStagingProfileId = project.findProperty('sonatypeStagingProfileId') ?: System.getenv('SONATYPE_STAGING_PROFILE_ID') ?: '' final ExtraPropertiesExtension extraPropertiesExtension = extensionContainer.findByType(ExtraPropertiesExtension) - extraPropertiesExtension.setProperty(SIGNING_KEY_ID, project.hasProperty(SIGNING_KEY_ID) ? project[SIGNING_KEY_ID] : System.getenv("SIGNING_KEY") ?: null) - extraPropertiesExtension.setProperty(SIGNING_PASSWORD, project.hasProperty(SIGNING_PASSWORD) ? project[SIGNING_PASSWORD] : System.getenv("SIGNING_PASSPHRASE") ?: null) - extraPropertiesExtension.setProperty(SIGNING_KEYRING, project.hasProperty(SIGNING_KEYRING) ? project[SIGNING_KEYRING] : System.getenv("SIGNING_KEYRING") ?: null) + extraPropertiesExtension.setProperty(SIGNING_KEY_ID, project.hasProperty(SIGNING_KEY_ID) ? project[SIGNING_KEY_ID] : System.getenv('SIGNING_KEY') ?: null) + extraPropertiesExtension.setProperty(SIGNING_PASSWORD, project.hasProperty(SIGNING_PASSWORD) ? project[SIGNING_PASSWORD] : System.getenv('SIGNING_PASSPHRASE') ?: null) + extraPropertiesExtension.setProperty(SIGNING_KEYRING, project.hasProperty(SIGNING_KEYRING) ? project[SIGNING_KEYRING] : System.getenv('SIGNING_KEYRING') ?: null) project.afterEvaluate { - RepositoryType snapshotType = gpe.snapshotRepoType - boolean isSnapshot = project.version.endsWith("SNAPSHOT") + RepositoryTarget snapshotType = gpe.snapshotRepoType + boolean isSnapshot = project.version.endsWith('SNAPSHOT') boolean isRelease = !isSnapshot final PluginManager projectPluginManager = project.getPluginManager() final PluginManager rootProjectPluginManager = project.rootProject.getPluginManager() - projectPluginManager.apply(MavenPublishPlugin.class) + projectPluginManager.apply(MavenPublishPlugin) project.publishing { - if (isSnapshot && snapshotType == RepositoryType.ARTIFACTORY) { + if (isSnapshot && snapshotType == RepositoryTarget.MAVEN_PUBLISH) { System.setProperty('org.gradle.internal.publish.checksums.insecure', true as String) repositories { maven { @@ -126,10 +127,10 @@ Sonatype Environment Variables are: password = artifactoryPassword } - if(!artifactoryPublishUrl) { - throw new RuntimeException("Could not locate a project property of `artifactoryPublishUrl` or an environment variable of `ARTIFACTORY_URL` for the snapshot url") + if (!artifactoryPublishUrl) { + throw new RuntimeException('Could not locate a project property of `artifactoryPublishUrl` or an environment variable of `ARTIFACTORY_URL` for the snapshot url') } - url artifactoryPublishUrl + url = artifactoryPublishUrl } } } @@ -139,11 +140,11 @@ Sonatype Environment Variables are: artifactId project.name doAddArtefact(project, delegate) - def sourcesJar = taskContainer.findByName("sourcesJar") + def sourcesJar = taskContainer.findByName('sourcesJar') if (sourcesJar != null) { artifact sourcesJar } - def javadocJar = taskContainer.findByName("javadocJar") + def javadocJar = taskContainer.findByName('javadocJar') if (javadocJar != null) { artifact javadocJar } @@ -262,17 +263,17 @@ Sonatype Environment Variables are: } } - if (isRelease || (isSnapshot && snapshotType == RepositoryType.CENTRAL)) { - rootProjectPluginManager.apply(NexusPublishPlugin.class) - projectPluginManager.apply(SigningPlugin.class) + if (isRelease || (isSnapshot && snapshotType == RepositoryTarget.NEXUS_PUBLISH)) { + rootProjectPluginManager.apply(NexusPublishPlugin) + projectPluginManager.apply(SigningPlugin) extensionContainer.configure(SigningExtension, { it.required = isRelease it.sign project.publishing.publications.maven }) - project.rootProject.tasks.withType(io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository).configureEach { io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository task -> - task.setShouldRunAfter(project.tasks.withType(Sign)) + project.rootProject.tasks.withType(InitializeNexusStagingRepository).configureEach { InitializeNexusStagingRepository task -> + task.shouldRunAfter = project.tasks.withType(Sign) } project.tasks.withType(Sign) { diff --git a/src/main/groovy/org/grails/gradle/plugin/publishing/RepositoryTarget.groovy b/src/main/groovy/org/grails/gradle/plugin/publishing/RepositoryTarget.groovy new file mode 100644 index 00000000..0dd468f1 --- /dev/null +++ b/src/main/groovy/org/grails/gradle/plugin/publishing/RepositoryTarget.groovy @@ -0,0 +1,6 @@ +package org.grails.gradle.plugin.publishing + +enum RepositoryTarget { + MAVEN_PUBLISH, + NEXUS_PUBLISH +} diff --git a/src/main/groovy/org/grails/gradle/plugin/publishing/RepositoryType.groovy b/src/main/groovy/org/grails/gradle/plugin/publishing/RepositoryType.groovy deleted file mode 100644 index bd141695..00000000 --- a/src/main/groovy/org/grails/gradle/plugin/publishing/RepositoryType.groovy +++ /dev/null @@ -1,6 +0,0 @@ -package org.grails.gradle.plugin.publishing - -enum RepositoryType { - ARTIFACTORY, // standard maven repository such as artifactory - CENTRAL // maven central -} From 5d2869eee2bc0b7dcb12c99a8d93adf6a20a91c3 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 2 Dec 2024 20:03:23 -0500 Subject: [PATCH 4/6] Feedback on plugin rework --- .github/workflows/gradle.yml | 4 +- .github/workflows/release.yml | 8 +- README.md | 27 ++-- settings.gradle | 2 +- .../GrailsProfilePublishGradlePlugin.groovy | 19 +-- .../publishing/GrailsPublishExtension.groovy | 10 +- .../GrailsPublishGradlePlugin.groovy | 141 +++++++++--------- ...sitoryTarget.groovy => PublishType.groovy} | 2 +- 8 files changed, 111 insertions(+), 102 deletions(-) rename src/main/groovy/org/grails/gradle/plugin/publishing/{RepositoryTarget.groovy => PublishType.groovy} (77%) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index d8e23a9e..feb785d6 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -13,8 +13,6 @@ jobs: strategy: matrix: java: ['17', '21'] - env: - WORKSPACE: ${{ github.workspace }} steps: - name: "📥 Checkout repository" uses: actions/checkout@v4 @@ -86,7 +84,7 @@ jobs: env: DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - run: ./gradle groovydoc + run: ./gradlew groovydoc - name: "🚀 Publish to Github Pages" id: docs if: success() diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1199852e..506035dc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -71,7 +71,7 @@ jobs: SECRING_FILE: ${{ secrets.SECRING_FILE }} DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - run: | + run: > ./gradlew -Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg publishToSonatype @@ -105,7 +105,7 @@ jobs: SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} - run: | + run: > ./gradlew findSonatypeStagingRepository releaseSonatypeStagingRepository @@ -135,6 +135,10 @@ jobs: with: distribution: liberica java-version: 17 + - name: "🐘 Setup Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - name: "📜 Generate Groovydoc" id: groovydoc env: diff --git a/README.md b/README.md index dd77ee15..e36b0aee 100644 --- a/README.md +++ b/README.md @@ -43,10 +43,7 @@ _Todo_: Add the docs grails-publish --------- -A Gradle plugin to simplify publishing: - -1. snapshots with either the Maven Publish gradle plugin or Nexus Publish gradle plugin. -2. releases with the Nexus Publish gradle plugin. +A Gradle plugin to ease publishing with the maven publish plugin or the nexus publish plugin. Example Usage: @@ -74,23 +71,23 @@ or developers = [johndoe: 'John Doe'] } -By default this plugin will publish to the specified `MAVEN_PUBLISH` instance for snapshots, and `NEXUS_PUBLISH` for releases. To change the snapshot publish behavior, you can set the `snapshotRepoType` to `RepositoryTarget.NEXUS_PUBLISH`. +By default this plugin will publish to the specified `MAVEN_PUBLISH` instance for snapshots, and `NEXUS_PUBLISH` for releases. To change the snapshot publish behavior, set `snapshotRepoType` to `PublishType.NEXUS_PUBLISH`. To change the release publish behavior, set `releaseRepoType` to `PublishType.NEXUS_PUBLISH`. The credentials and connection url must be specified as a project property or an environment variable. -The `MAVEN_PUBLISH` Environment Variables are: +`MAVEN_PUBLISH` Environment Variables are: - ARTIFACTORY_USERNAME - ARTIFACTORY_PASSWORD - ARTIFACTORY_URL + MAVEN_PUBLISH_USERNAME + MAVEN_PUBLISH_PASSWORD + MAVEN_PUBLISH_URL -The `NEXUS_PUBLISH` Environment Variables are: +`NEXUS_PUBLISH` Environment Variables are: - SONATYPE_NEXUS_URL - SONATYPE_SNAPSHOT_URL - SONATYPE_USERNAME - SONATYPE_PASSWORD - SONATYPE_STAGING_PROFILE_ID + NEXUS_PUBLISH_URL + NEXUS_PUBLISH_SNAPSHOT_URL + NEXUS_PUBLISH_USERNAME + NEXUS_PUBLISH_PASSWORD + NEXUS_PUBLISH_STAGING_PROFILE_ID grails-web --------- diff --git a/settings.gradle b/settings.gradle index 8a07d8a1..db4ebcf9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -31,4 +31,4 @@ buildCache { } -rootProject.name = "grails-gradle-plugin" \ No newline at end of file +rootProject.name = 'grails-gradle-plugin' \ No newline at end of file diff --git a/src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfilePublishGradlePlugin.groovy b/src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfilePublishGradlePlugin.groovy index 04d55f15..63ef4729 100644 --- a/src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfilePublishGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfilePublishGradlePlugin.groovy @@ -23,6 +23,7 @@ import org.gradle.api.XmlProvider import org.gradle.api.artifacts.Dependency import org.gradle.api.artifacts.DependencySet import org.gradle.api.artifacts.SelfResolvingDependency +import org.gradle.api.publish.maven.MavenPom import org.gradle.api.publish.maven.MavenPublication import org.gradle.api.tasks.bundling.Jar import org.grails.gradle.plugin.publishing.GrailsPublishGradlePlugin @@ -43,13 +44,13 @@ class GrailsProfilePublishGradlePlugin extends GrailsPublishGradlePlugin { @Override void apply(Project project) { super.apply(project) - final File tempReadmeForJavadoc = Files.createTempFile("README", "txt").toFile() - tempReadmeForJavadoc << "https://central.sonatype.org/publish/requirements/#supply-javadoc-and-sources" - project.tasks.create("javadocJar", Jar, { Jar jar -> + final File tempReadmeForJavadoc = Files.createTempFile('README', 'txt').toFile() + tempReadmeForJavadoc << 'https://central.sonatype.org/publish/requirements/#supply-javadoc-and-sources' + project.tasks.create('javadocJar', Jar, { Jar jar -> jar.from(tempReadmeForJavadoc) - jar.archiveClassifier.set("javadoc") - jar.destinationDirectory.set(new File(project.layout.buildDirectory.getAsFile().get(), "libs")) - jar.setDescription("Assembles a jar archive containing the profile javadoc.") + jar.archiveClassifier.set('javadoc') + jar.destinationDirectory.set(new File(project.layout.buildDirectory.getAsFile().get(), 'libs')) + jar.setDescription('Assembles a jar archive containing the profile javadoc.') jar.setGroup(BUILD_GROUP) }) } @@ -68,10 +69,10 @@ class GrailsProfilePublishGradlePlugin extends GrailsPublishGradlePlugin { @Override protected void doAddArtefact(Project project, MavenPublication publication) { - publication.artifact(project.tasks.findByName("jar")) - publication.pom(new Action() { + publication.artifact(project.tasks.findByName('jar')) + publication.pom(new Action() { @Override - void execute(org.gradle.api.publish.maven.MavenPom mavenPom) { + void execute(MavenPom mavenPom) { mavenPom.withXml(new Action() { @Override void execute(XmlProvider xml) { diff --git a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishExtension.groovy b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishExtension.groovy index 2fa7934b..9342ba99 100644 --- a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishExtension.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishExtension.groovy @@ -21,14 +21,20 @@ import org.gradle.util.ConfigureUtil /** * @author Puneet Behl + * @author James Daugherty * @since 4.0.11 */ @CompileStatic class GrailsPublishExtension { /** - * Determines the snapshot repository to publish to + * Determines which plugin is used to publish snapshots */ - RepositoryTarget snapshotRepoType = RepositoryTarget.MAVEN_PUBLISH + PublishType snapshotPublishType = PublishType.MAVEN_PUBLISH + + /** + * Determines which plugin is used to publish releases + */ + PublishType releasePublishType = PublishType.NEXUS_PUBLISH /** * The slug from github 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 8bca82f5..11356f90 100644 --- a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -//file:noinspection DuplicatedCode package org.grails.gradle.plugin.publishing import grails.util.GrailsNameUtils @@ -40,6 +39,7 @@ import static com.bmuschko.gradle.nexus.NexusPlugin.getSIGNING_KEYRING * A plugin to ease publishing Grails related artifacts * * @author Graeme Rocher + * @author James Daugherty * @since 3.1 */ class GrailsPublishGradlePlugin implements Plugin { @@ -48,7 +48,7 @@ class GrailsPublishGradlePlugin implements Plugin { return """No '$missingSetting' was specified. Please provide a valid publishing configuration. Example: grailsPublish { - websiteUrl = 'http://foo.com/myplugin' + websiteUrl = 'https://example.com/myplugin' license { name = 'Apache-2.0' } @@ -71,20 +71,21 @@ grailsPublish { developers = [johndoe: 'John Doe'] } +By default snapshotPublishType is set to MAVEN_PUBLISH and releasePublishType is set to NEXUS_PUBLISH. + The credentials and connection url must be specified as a project property or an environment variable: `MAVEN_PUBLISH` Environment Variables are: - ARTIFACTORY_USERNAME - ARTIFACTORY_PASSWORD - ARTIFACTORY_URL + MAVEN_PUBLISH_USERNAME + MAVEN_PUBLISH_PASSWORD + MAVEN_PUBLISH_URL `NEXUS_PUBLISH` Environment Variables are: - SONATYPE_NEXUS_URL - SONATYPE_SNAPSHOT_URL - SONATYPE_USERNAME - SONATYPE_PASSWORD - SONATYPE_STAGING_PROFILE_ID - + NEXUS_PUBLISH_URL + NEXUS_PUBLISH_SNAPSHOT_URL + NEXUS_PUBLISH_USERNAME + NEXUS_PUBLISH_PASSWORD + NEXUS_PUBLISH_STAGING_PROFILE_ID """ } @@ -94,43 +95,50 @@ The credentials and connection url must be specified as a project property or an final TaskContainer taskContainer = project.tasks final GrailsPublishExtension gpe = extensionContainer.create('grailsPublish', GrailsPublishExtension) - final String artifactoryUsername = project.findProperty('artifactoryPublishUsername') ?: System.getenv('ARTIFACTORY_USERNAME') ?: '' - final String artifactoryPassword = project.findProperty('artifactoryPublishPassword') ?: System.getenv('ARTIFACTORY_PASSWORD') ?: '' - final String artifactoryPublishUrl = project.findProperty('artifactoryPublishUrl') ?: System.getenv('ARTIFACTORY_URL') ?: '' - final String sonatypeNexusUrl = project.findProperty('sonatypeNexusUrl') ?: System.getenv('SONATYPE_NEXUS_URL') ?: '' - final String sonatypeSnapshotUrl = project.findProperty('sonatypeSnapshotUrl') ?: System.getenv('SONATYPE_SNAPSHOT_URL') ?: '' - final String sonatypeUsername = project.findProperty('sonatypeUsername') ?: System.getenv('SONATYPE_USERNAME') ?: '' - final String sonatypePassword = project.findProperty('sonatypePassword') ?: System.getenv('SONATYPE_PASSWORD') ?: '' - final String sonatypeStagingProfileId = project.findProperty('sonatypeStagingProfileId') ?: System.getenv('SONATYPE_STAGING_PROFILE_ID') ?: '' + final String mavenPublishUsername = project.findProperty('mavenPublishUsername') ?: System.getenv('MAVEN_PUBLISH_USERNAME') ?: '' + final String mavenPublishPassword = project.findProperty('mavenPublishPassword') ?: System.getenv('MAVEN_PUBLISH_PASSWORD') ?: '' + final String mavenPublishUrl = project.findProperty('mavenPublishUrl') ?: System.getenv('MAVEN_PUBLISH_URL') ?: '' + + final String nexusPublishUrl = project.findProperty('nexusPublishUrl') ?: System.getenv('NEXUS_PUBLISH_URL') ?: '' + final String nexusPublishSnapshotUrl = project.findProperty('nexusPublishSnapshotUrl') ?: System.getenv('NEXUS_PUBLISH_SNAPSHOT_URL') ?: '' + final String nexusPublishUsername = project.findProperty('nexusPublishUsername') ?: System.getenv('NEXUS_PUBLISH_USERNAME') ?: '' + final String nexusPublishPassword = project.findProperty('nexusPublishPassword') ?: System.getenv('NEXUS_PUBLISH_PASSWORD') ?: '' + final String nexusPublishStagingProfileId = project.findProperty('nexusPublishStagingProfileId') ?: System.getenv('NEXUS_PUBLISH_STAGING_PROFILE_ID') ?: '' final ExtraPropertiesExtension extraPropertiesExtension = extensionContainer.findByType(ExtraPropertiesExtension) - extraPropertiesExtension.setProperty(SIGNING_KEY_ID, project.hasProperty(SIGNING_KEY_ID) ? project[SIGNING_KEY_ID] : System.getenv('SIGNING_KEY') ?: null) - extraPropertiesExtension.setProperty(SIGNING_PASSWORD, project.hasProperty(SIGNING_PASSWORD) ? project[SIGNING_PASSWORD] : System.getenv('SIGNING_PASSPHRASE') ?: null) - extraPropertiesExtension.setProperty(SIGNING_KEYRING, project.hasProperty(SIGNING_KEYRING) ? project[SIGNING_KEYRING] : System.getenv('SIGNING_KEYRING') ?: null) + extraPropertiesExtension.setProperty(SIGNING_KEY_ID, project.findProperty(SIGNING_KEY_ID) ?: System.getenv('SIGNING_KEY')) + extraPropertiesExtension.setProperty(SIGNING_PASSWORD, project.findProperty(SIGNING_PASSWORD) ?: System.getenv('SIGNING_PASSPHRASE')) + extraPropertiesExtension.setProperty(SIGNING_KEYRING, project.findProperty(SIGNING_KEYRING) ?: System.getenv('SIGNING_KEYRING')) project.afterEvaluate { - RepositoryTarget snapshotType = gpe.snapshotRepoType + PublishType snapshotPublishType = gpe.snapshotPublishType + PublishType releasePublishType = gpe.releasePublishType + boolean isSnapshot = project.version.endsWith('SNAPSHOT') boolean isRelease = !isSnapshot + + boolean mavenPublish = (isSnapshot && snapshotPublishType == PublishType.MAVEN_PUBLISH) || (isRelease && releasePublishType == PublishType.MAVEN_PUBLISH) + boolean sonatypePublish = (isSnapshot && snapshotPublishType == PublishType.NEXUS_PUBLISH) || (isRelease && releasePublishType == PublishType.NEXUS_PUBLISH) + final PluginManager projectPluginManager = project.getPluginManager() final PluginManager rootProjectPluginManager = project.rootProject.getPluginManager() projectPluginManager.apply(MavenPublishPlugin) project.publishing { - if (isSnapshot && snapshotType == RepositoryTarget.MAVEN_PUBLISH) { + if (mavenPublish) { System.setProperty('org.gradle.internal.publish.checksums.insecure', true as String) repositories { maven { credentials { - username = artifactoryUsername - password = artifactoryPassword + username = mavenPublishUsername + password = mavenPublishPassword } - if (!artifactoryPublishUrl) { - throw new RuntimeException('Could not locate a project property of `artifactoryPublishUrl` or an environment variable of `ARTIFACTORY_URL` for the snapshot url') + if (!mavenPublishUrl) { + throw new RuntimeException('Could not locate a project property of `mavenPublishUrl` or an environment variable of `MAVEN_PUBLISH_URL`') } - url = artifactoryPublishUrl + url = mavenPublishUrl } } } @@ -164,36 +172,32 @@ The credentials and connection url must be specified as a project property or an if (gpe != null) { pomNode.children().last() + { def title = gpe.title ?: project.name - delegate.name title - delegate.description gpe.desc ?: title + delegate.name = title + delegate.description = gpe.desc ?: title def websiteUrl = gpe.websiteUrl ?: gpe.githubSlug ? "https://github.com/$gpe.githubSlug" : '' if (!websiteUrl) { throw new RuntimeException(getErrorMessage('websiteUrl')) } - - delegate.url websiteUrl - + delegate.url = websiteUrl def license = gpe.license if (license != null) { - def concreteLicense = GrailsPublishExtension.License.LICENSES.get(license.name) if (concreteLicense != null) { - delegate.licenses { delegate.license { - delegate.name concreteLicense.name - delegate.url concreteLicense.url - delegate.distribution concreteLicense.distribution + delegate.name = concreteLicense.name + delegate.url = concreteLicense.url + delegate.distribution = concreteLicense.distribution } } } else if (license.name && license.url) { delegate.licenses { delegate.license { - delegate.name license.name - delegate.url license.url - delegate.distribution license.distribution + delegate.name = license.name + delegate.url = license.url + delegate.distribution = license.distribution } } } @@ -203,20 +207,20 @@ The credentials and connection url must be specified as a project property or an if (gpe.githubSlug) { delegate.scm { - delegate.url "https://github.com/$gpe.githubSlug" - delegate.connection "scm:git@github.com:${gpe.githubSlug}.git" - delegate.developerConnection "scm:git@github.com:${gpe.githubSlug}.git" + delegate.url = "https://github.com/$gpe.githubSlug" + delegate.connection = "scm:git@github.com:${gpe.githubSlug}.git" + delegate.developerConnection = "scm:git@github.com:${gpe.githubSlug}.git" } delegate.issueManagement { - delegate.system "Github Issues" - delegate.url "https://github.com/$gpe.githubSlug/issues" + delegate.system = 'Github Issues' + delegate.url = "https://github.com/$gpe.githubSlug/issues" } } else { if (gpe.vcsUrl) { delegate.scm { - delegate.url gpe.vcsUrl - delegate.connection "scm:$gpe.vcsUrl" - delegate.developerConnection "scm:$gpe.vcsUrl" + delegate.url = gpe.vcsUrl + delegate.connection = "scm:$gpe.vcsUrl" + delegate.developerConnection = "scm:$gpe.vcsUrl" } } else { throw new RuntimeException(getErrorMessage('vcsUrl')) @@ -224,21 +228,20 @@ The credentials and connection url must be specified as a project property or an if (gpe.issueTrackerUrl) { delegate.issueManagement { - delegate.system "Issue Tracker" - delegate.url gpe.issueTrackerUrl + delegate.system = 'Issue Tracker' + delegate.url = gpe.issueTrackerUrl } } else { throw new RuntimeException(getErrorMessage('issueTrackerUrl')) } - } if (gpe.developers) { delegate.developers { for (entry in gpe.developers.entrySet()) { delegate.developer { - delegate.id entry.key - delegate.name entry.value + delegate.id = entry.key + delegate.name = entry.value } } } @@ -263,7 +266,7 @@ The credentials and connection url must be specified as a project property or an } } - if (isRelease || (isSnapshot && snapshotType == RepositoryTarget.NEXUS_PUBLISH)) { + if (sonatypePublish) { rootProjectPluginManager.apply(NexusPublishPlugin) projectPluginManager.apply(SigningPlugin) @@ -283,34 +286,34 @@ The credentials and connection url must be specified as a project property or an project.rootProject.nexusPublishing { repositories { sonatype { - if (sonatypeNexusUrl) { - nexusUrl = project.uri(sonatypeNexusUrl) + if (nexusPublishUrl) { + nexusUrl = project.uri(nexusPublishUrl) } - if (sonatypeSnapshotUrl) { - snapshotRepositoryUrl = project.uri(sonatypeSnapshotUrl) + if (nexusPublishSnapshotUrl) { + snapshotRepositoryUrl = project.uri(nexusPublishSnapshotUrl) } - username = sonatypeUsername - password = sonatypePassword - stagingProfileId = sonatypeStagingProfileId + username = nexusPublishUsername + password = nexusPublishPassword + stagingProfileId = nexusPublishStagingProfileId } } } } - def installTask = taskContainer.findByName("install") + def installTask = taskContainer.findByName('install') def publishToSonatypeTask = taskContainer.findByName('publishToSonatype') def closeAndReleaseSonatypeStagingRepositoryTask = taskContainer.findByName('closeAndReleaseSonatypeStagingRepository') - def publishToMavenLocal = taskContainer.findByName("publishToMavenLocal") + def publishToMavenLocal = taskContainer.findByName('publishToMavenLocal') if (publishToSonatypeTask != null && taskContainer.findByName("publish${GrailsNameUtils.getClassName(defaultClassifier)}") == null) { taskContainer.register("publish${GrailsNameUtils.getClassName(defaultClassifier)}", { Task task -> task.dependsOn([publishToSonatypeTask, closeAndReleaseSonatypeStagingRepositoryTask]) - task.setGroup("publishing") + task.setGroup('publishing') }) } if (installTask == null) { - taskContainer.register("install", { Task task -> + taskContainer.register('install', { Task task -> task.dependsOn(publishToMavenLocal) - task.setGroup("publishing") + task.setGroup('publishing') }) } } @@ -330,7 +333,7 @@ The credentials and connection url must be specified as a project property or an } protected String getDefaultClassifier() { - "plugin" + 'plugin' } } diff --git a/src/main/groovy/org/grails/gradle/plugin/publishing/RepositoryTarget.groovy b/src/main/groovy/org/grails/gradle/plugin/publishing/PublishType.groovy similarity index 77% rename from src/main/groovy/org/grails/gradle/plugin/publishing/RepositoryTarget.groovy rename to src/main/groovy/org/grails/gradle/plugin/publishing/PublishType.groovy index 0dd468f1..bda1491e 100644 --- a/src/main/groovy/org/grails/gradle/plugin/publishing/RepositoryTarget.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/publishing/PublishType.groovy @@ -1,6 +1,6 @@ package org.grails.gradle.plugin.publishing -enum RepositoryTarget { +enum PublishType { MAVEN_PUBLISH, NEXUS_PUBLISH } From 765a019acb8dc31c9bfcd923127b4e6437d361d0 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Tue, 3 Dec 2024 10:12:21 -0500 Subject: [PATCH 5/6] Feedback on plugin rework --- README.md | 6 +- .../GrailsPublishGradlePlugin.groovy | 80 ++++++++++--------- 2 files changed, 45 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index e36b0aee..05534f39 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ or developers = [johndoe: 'John Doe'] } -By default this plugin will publish to the specified `MAVEN_PUBLISH` instance for snapshots, and `NEXUS_PUBLISH` for releases. To change the snapshot publish behavior, set `snapshotRepoType` to `PublishType.NEXUS_PUBLISH`. To change the release publish behavior, set `releaseRepoType` to `PublishType.NEXUS_PUBLISH`. +By default, this plugin will publish to the specified `MAVEN_PUBLISH` instance for snapshots, and `NEXUS_PUBLISH` for releases. To change the snapshot publish behavior, set `snapshotRepoType` to `PublishType.NEXUS_PUBLISH`. To change the release publish behavior, set `releaseRepoType` to `PublishType.MAVEN_PUBLISH`. The credentials and connection url must be specified as a project property or an environment variable. @@ -83,10 +83,10 @@ The credentials and connection url must be specified as a project property or an `NEXUS_PUBLISH` Environment Variables are: - NEXUS_PUBLISH_URL - NEXUS_PUBLISH_SNAPSHOT_URL NEXUS_PUBLISH_USERNAME NEXUS_PUBLISH_PASSWORD + NEXUS_PUBLISH_URL + NEXUS_PUBLISH_SNAPSHOT_URL NEXUS_PUBLISH_STAGING_PROFILE_ID grails-web 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 11356f90..d39dcec2 100644 --- a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy @@ -81,10 +81,10 @@ The credentials and connection url must be specified as a project property or an MAVEN_PUBLISH_URL `NEXUS_PUBLISH` Environment Variables are: - NEXUS_PUBLISH_URL - NEXUS_PUBLISH_SNAPSHOT_URL NEXUS_PUBLISH_USERNAME NEXUS_PUBLISH_PASSWORD + NEXUS_PUBLISH_URL + NEXUS_PUBLISH_SNAPSHOT_URL NEXUS_PUBLISH_STAGING_PROFILE_ID """ } @@ -111,20 +111,27 @@ The credentials and connection url must be specified as a project property or an extraPropertiesExtension.setProperty(SIGNING_PASSWORD, project.findProperty(SIGNING_PASSWORD) ?: System.getenv('SIGNING_PASSPHRASE')) extraPropertiesExtension.setProperty(SIGNING_KEYRING, project.findProperty(SIGNING_KEYRING) ?: System.getenv('SIGNING_KEYRING')) - project.afterEvaluate { - PublishType snapshotPublishType = gpe.snapshotPublishType - PublishType releasePublishType = gpe.releasePublishType - boolean isSnapshot = project.version.endsWith('SNAPSHOT') - boolean isRelease = !isSnapshot + PublishType snapshotPublishType = gpe.snapshotPublishType + PublishType releasePublishType = gpe.releasePublishType - boolean mavenPublish = (isSnapshot && snapshotPublishType == PublishType.MAVEN_PUBLISH) || (isRelease && releasePublishType == PublishType.MAVEN_PUBLISH) - boolean sonatypePublish = (isSnapshot && snapshotPublishType == PublishType.NEXUS_PUBLISH) || (isRelease && releasePublishType == PublishType.NEXUS_PUBLISH) + boolean isSnapshot = project.version.endsWith('SNAPSHOT') + boolean isRelease = !isSnapshot + boolean mavenPublish = (isSnapshot && snapshotPublishType == PublishType.MAVEN_PUBLISH) || (isRelease && releasePublishType == PublishType.MAVEN_PUBLISH) + boolean nexusPublish = (isSnapshot && snapshotPublishType == PublishType.NEXUS_PUBLISH) || (isRelease && releasePublishType == PublishType.NEXUS_PUBLISH) - final PluginManager projectPluginManager = project.getPluginManager() - final PluginManager rootProjectPluginManager = project.rootProject.getPluginManager() - projectPluginManager.apply(MavenPublishPlugin) + final PluginManager projectPluginManager = project.getPluginManager() + final PluginManager rootProjectPluginManager = project.rootProject.getPluginManager() + // Required for the pom always + projectPluginManager.apply(MavenPublishPlugin) + + if(nexusPublish) { + rootProjectPluginManager.apply(NexusPublishPlugin) + projectPluginManager.apply(SigningPlugin) + } + + project.afterEvaluate { project.publishing { if (mavenPublish) { System.setProperty('org.gradle.internal.publish.checksums.insecure', true as String) @@ -136,7 +143,7 @@ The credentials and connection url must be specified as a project property or an } if (!mavenPublishUrl) { - throw new RuntimeException('Could not locate a project property of `mavenPublishUrl` or an environment variable of `MAVEN_PUBLISH_URL`') + // throw new RuntimeException('Could not locate a project property of `mavenPublishUrl` or an environment variable of `MAVEN_PUBLISH_URL`') } url = mavenPublishUrl } @@ -172,14 +179,14 @@ The credentials and connection url must be specified as a project property or an if (gpe != null) { pomNode.children().last() + { def title = gpe.title ?: project.name - delegate.name = title - delegate.description = gpe.desc ?: title + delegate.name title + delegate.description gpe.desc ?: title def websiteUrl = gpe.websiteUrl ?: gpe.githubSlug ? "https://github.com/$gpe.githubSlug" : '' if (!websiteUrl) { throw new RuntimeException(getErrorMessage('websiteUrl')) } - delegate.url = websiteUrl + delegate.url websiteUrl def license = gpe.license if (license != null) { @@ -187,17 +194,17 @@ The credentials and connection url must be specified as a project property or an if (concreteLicense != null) { delegate.licenses { delegate.license { - delegate.name = concreteLicense.name - delegate.url = concreteLicense.url - delegate.distribution = concreteLicense.distribution + delegate.name concreteLicense.name + delegate.url concreteLicense.url + delegate.distribution concreteLicense.distribution } } } else if (license.name && license.url) { delegate.licenses { delegate.license { - delegate.name = license.name - delegate.url = license.url - delegate.distribution = license.distribution + delegate.name license.name + delegate.url license.url + delegate.distribution license.distribution } } } @@ -207,20 +214,20 @@ The credentials and connection url must be specified as a project property or an if (gpe.githubSlug) { delegate.scm { - delegate.url = "https://github.com/$gpe.githubSlug" - delegate.connection = "scm:git@github.com:${gpe.githubSlug}.git" - delegate.developerConnection = "scm:git@github.com:${gpe.githubSlug}.git" + delegate.url "https://github.com/$gpe.githubSlug" + delegate.connection "scm:git@github.com:${gpe.githubSlug}.git" + delegate.developerConnection "scm:git@github.com:${gpe.githubSlug}.git" } delegate.issueManagement { - delegate.system = 'Github Issues' - delegate.url = "https://github.com/$gpe.githubSlug/issues" + delegate.system 'Github Issues' + delegate.url "https://github.com/$gpe.githubSlug/issues" } } else { if (gpe.vcsUrl) { delegate.scm { - delegate.url = gpe.vcsUrl - delegate.connection = "scm:$gpe.vcsUrl" - delegate.developerConnection = "scm:$gpe.vcsUrl" + delegate.url gpe.vcsUrl + delegate.connection "scm:$gpe.vcsUrl" + delegate.developerConnection "scm:$gpe.vcsUrl" } } else { throw new RuntimeException(getErrorMessage('vcsUrl')) @@ -228,8 +235,8 @@ The credentials and connection url must be specified as a project property or an if (gpe.issueTrackerUrl) { delegate.issueManagement { - delegate.system = 'Issue Tracker' - delegate.url = gpe.issueTrackerUrl + delegate.system 'Issue Tracker' + delegate.url gpe.issueTrackerUrl } } else { throw new RuntimeException(getErrorMessage('issueTrackerUrl')) @@ -240,8 +247,8 @@ The credentials and connection url must be specified as a project property or an delegate.developers { for (entry in gpe.developers.entrySet()) { delegate.developer { - delegate.id = entry.key - delegate.name = entry.value + delegate.id entry.key + delegate.name entry.value } } } @@ -266,10 +273,7 @@ The credentials and connection url must be specified as a project property or an } } - if (sonatypePublish) { - rootProjectPluginManager.apply(NexusPublishPlugin) - projectPluginManager.apply(SigningPlugin) - + if (nexusPublish) { extensionContainer.configure(SigningExtension, { it.required = isRelease it.sign project.publishing.publications.maven From 8f926fe7c04f4726b2006c2dff74efde84667ac0 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Tue, 3 Dec 2024 10:46:40 -0500 Subject: [PATCH 6/6] Updating copyright --- .../plugin/agent/AgentTasksEnhancer.groovy | 15 +++++++++++++++ .../ApplicationContextCommandTask.groovy | 4 ++-- .../ApplicationContextScriptTask.groovy | 15 +++++++++++++++ .../gradle/plugin/core/GrailsExtension.groovy | 15 +++++++++++++++ .../plugin/core/GrailsGradlePlugin.groovy | 4 ++-- .../core/IntegrationTestGradlePlugin.groovy | 4 ++-- .../gradle/plugin/core/PluginDefiner.groovy | 15 +++++++++++++++ .../plugin/doc/GrailsDocGradlePlugin.groovy | 4 ++-- .../gradle/plugin/doc/PublishGuideTask.groovy | 4 ++-- .../GrailsClasspathToolingModelBuilder.groovy | 5 ++--- .../profiles/GrailsProfileGradlePlugin.groovy | 4 ++-- .../GrailsProfilePublishGradlePlugin.groovy | 5 ++--- .../profiles/tasks/ProfileCompilerTask.groovy | 5 ++--- .../publishing/GrailsPublishExtension.groovy | 5 ++--- .../GrailsPublishGradlePlugin.groovy | 6 +++--- .../plugin/publishing/PublishType.groovy | 15 +++++++++++++++ .../gradle/plugin/run/FindMainClassTask.groovy | 18 +++++++++++++++--- .../gradle/plugin/run/GrailsRunTask.groovy | 4 ++-- .../gradle/plugin/util/SourceSets.groovy | 15 +++++++++++++++ .../plugin/web/GrailsWebGradlePlugin.groovy | 4 ++-- .../web/gsp/GroovyPageForkCompileTask.groovy | 15 +++++++++++++++ .../plugin/web/gsp/GroovyPagePlugin.groovy | 15 +++++++++++++++ .../plugin/web/gsp/GspCompileOptions.groovy | 17 ++++++++++++++++- 23 files changed, 178 insertions(+), 35 deletions(-) diff --git a/src/main/groovy/org/grails/gradle/plugin/agent/AgentTasksEnhancer.groovy b/src/main/groovy/org/grails/gradle/plugin/agent/AgentTasksEnhancer.groovy index cc60e7ee..82722e34 100644 --- a/src/main/groovy/org/grails/gradle/plugin/agent/AgentTasksEnhancer.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/agent/AgentTasksEnhancer.groovy @@ -1,3 +1,18 @@ +/* + * Copyright 2015-2024 original authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.grails.gradle.plugin.agent import groovy.transform.CompileStatic diff --git a/src/main/groovy/org/grails/gradle/plugin/commands/ApplicationContextCommandTask.groovy b/src/main/groovy/org/grails/gradle/plugin/commands/ApplicationContextCommandTask.groovy index aea1d42f..92af1da7 100644 --- a/src/main/groovy/org/grails/gradle/plugin/commands/ApplicationContextCommandTask.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/commands/ApplicationContextCommandTask.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2014 original authors + * Copyright 2014-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/main/groovy/org/grails/gradle/plugin/commands/ApplicationContextScriptTask.groovy b/src/main/groovy/org/grails/gradle/plugin/commands/ApplicationContextScriptTask.groovy index d7ae876e..af00ec4b 100644 --- a/src/main/groovy/org/grails/gradle/plugin/commands/ApplicationContextScriptTask.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/commands/ApplicationContextScriptTask.groovy @@ -1,3 +1,18 @@ +/* + * Copyright 2024 original authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.grails.gradle.plugin.commands import groovy.transform.CompileStatic diff --git a/src/main/groovy/org/grails/gradle/plugin/core/GrailsExtension.groovy b/src/main/groovy/org/grails/gradle/plugin/core/GrailsExtension.groovy index 71508746..f17f068e 100644 --- a/src/main/groovy/org/grails/gradle/plugin/core/GrailsExtension.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/core/GrailsExtension.groovy @@ -1,3 +1,18 @@ +/* + * Copyright 2024 original authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.grails.gradle.plugin.core import groovy.transform.CompileStatic diff --git a/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy b/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy index d2c9a315..c15240c9 100644 --- a/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2015 original authors + * Copyright 2015-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/main/groovy/org/grails/gradle/plugin/core/IntegrationTestGradlePlugin.groovy b/src/main/groovy/org/grails/gradle/plugin/core/IntegrationTestGradlePlugin.groovy index 9139cbe7..21a610b5 100644 --- a/src/main/groovy/org/grails/gradle/plugin/core/IntegrationTestGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/core/IntegrationTestGradlePlugin.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/main/groovy/org/grails/gradle/plugin/core/PluginDefiner.groovy b/src/main/groovy/org/grails/gradle/plugin/core/PluginDefiner.groovy index 7ddc9730..4662fe5e 100644 --- a/src/main/groovy/org/grails/gradle/plugin/core/PluginDefiner.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/core/PluginDefiner.groovy @@ -1,3 +1,18 @@ +/* + * Copyright 2015-2024 original authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.grails.gradle.plugin.core import grails.util.BuildSettings diff --git a/src/main/groovy/org/grails/gradle/plugin/doc/GrailsDocGradlePlugin.groovy b/src/main/groovy/org/grails/gradle/plugin/doc/GrailsDocGradlePlugin.groovy index 8621097d..4ac79f58 100644 --- a/src/main/groovy/org/grails/gradle/plugin/doc/GrailsDocGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/doc/GrailsDocGradlePlugin.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2014 original authors + * Copyright 2014-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/main/groovy/org/grails/gradle/plugin/doc/PublishGuideTask.groovy b/src/main/groovy/org/grails/gradle/plugin/doc/PublishGuideTask.groovy index bd89e1d0..0a823961 100644 --- a/src/main/groovy/org/grails/gradle/plugin/doc/PublishGuideTask.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/doc/PublishGuideTask.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2014 original authors + * Copyright 2014-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/main/groovy/org/grails/gradle/plugin/model/GrailsClasspathToolingModelBuilder.groovy b/src/main/groovy/org/grails/gradle/plugin/model/GrailsClasspathToolingModelBuilder.groovy index c09b39c4..c82802f2 100644 --- a/src/main/groovy/org/grails/gradle/plugin/model/GrailsClasspathToolingModelBuilder.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/model/GrailsClasspathToolingModelBuilder.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.grails.gradle.plugin.model import groovy.transform.CompileStatic diff --git a/src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfileGradlePlugin.groovy b/src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfileGradlePlugin.groovy index 20881ced..ac64e960 100644 --- a/src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfileGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfileGradlePlugin.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2015 original authors + * Copyright 2015-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfilePublishGradlePlugin.groovy b/src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfilePublishGradlePlugin.groovy index 63ef4729..8ee4968d 100644 --- a/src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfilePublishGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfilePublishGradlePlugin.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2015 original authors + * Copyright 2015-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -15,7 +15,6 @@ */ package org.grails.gradle.plugin.profiles - import groovy.transform.CompileStatic import org.gradle.api.Action import org.gradle.api.Project diff --git a/src/main/groovy/org/grails/gradle/plugin/profiles/tasks/ProfileCompilerTask.groovy b/src/main/groovy/org/grails/gradle/plugin/profiles/tasks/ProfileCompilerTask.groovy index b0eee59e..d4c0b156 100644 --- a/src/main/groovy/org/grails/gradle/plugin/profiles/tasks/ProfileCompilerTask.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/profiles/tasks/ProfileCompilerTask.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2015 original authors + * Copyright 2015-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.grails.gradle.plugin.profiles.tasks import groovy.transform.CompileStatic diff --git a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishExtension.groovy b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishExtension.groovy index 9342ba99..860e390d 100644 --- a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishExtension.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishExtension.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2015 original authors + * Copyright 2015-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.grails.gradle.plugin.publishing import groovy.transform.CompileStatic 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 d39dcec2..0b2f41a1 100644 --- a/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishGradlePlugin.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2015 original authors + * Copyright 2015-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -126,7 +126,7 @@ The credentials and connection url must be specified as a project property or an // Required for the pom always projectPluginManager.apply(MavenPublishPlugin) - if(nexusPublish) { + if (nexusPublish) { rootProjectPluginManager.apply(NexusPublishPlugin) projectPluginManager.apply(SigningPlugin) } diff --git a/src/main/groovy/org/grails/gradle/plugin/publishing/PublishType.groovy b/src/main/groovy/org/grails/gradle/plugin/publishing/PublishType.groovy index bda1491e..2002aaf6 100644 --- a/src/main/groovy/org/grails/gradle/plugin/publishing/PublishType.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/publishing/PublishType.groovy @@ -1,3 +1,18 @@ +/* + * Copyright 2024 original authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.grails.gradle.plugin.publishing enum PublishType { diff --git a/src/main/groovy/org/grails/gradle/plugin/run/FindMainClassTask.groovy b/src/main/groovy/org/grails/gradle/plugin/run/FindMainClassTask.groovy index ed26c214..ad613d78 100644 --- a/src/main/groovy/org/grails/gradle/plugin/run/FindMainClassTask.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/run/FindMainClassTask.groovy @@ -1,18 +1,30 @@ +/* + * Copyright 2024 original authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.grails.gradle.plugin.run -import groovy.transform.CompileDynamic import groovy.transform.CompileStatic import org.gradle.api.DefaultTask import org.gradle.api.Project import org.gradle.api.file.FileCollection import org.gradle.api.plugins.ExtraPropertiesExtension -import org.gradle.api.tasks.JavaExec import org.gradle.api.tasks.SourceSet import org.gradle.api.tasks.SourceSetOutput import org.gradle.api.tasks.TaskAction import org.grails.gradle.plugin.util.SourceSets import org.grails.io.support.MainClassFinder -import org.springframework.boot.gradle.tasks.bundling.BootArchive import org.springframework.boot.gradle.tasks.run.BootRun /** diff --git a/src/main/groovy/org/grails/gradle/plugin/run/GrailsRunTask.groovy b/src/main/groovy/org/grails/gradle/plugin/run/GrailsRunTask.groovy index 536b2d67..73f6d5c1 100644 --- a/src/main/groovy/org/grails/gradle/plugin/run/GrailsRunTask.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/run/GrailsRunTask.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2015 original authors + * Copyright 2015-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/main/groovy/org/grails/gradle/plugin/util/SourceSets.groovy b/src/main/groovy/org/grails/gradle/plugin/util/SourceSets.groovy index 04935e16..c9173436 100644 --- a/src/main/groovy/org/grails/gradle/plugin/util/SourceSets.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/util/SourceSets.groovy @@ -1,3 +1,18 @@ +/* + * Copyright 2024 original authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.grails.gradle.plugin.util import groovy.transform.CompileStatic diff --git a/src/main/groovy/org/grails/gradle/plugin/web/GrailsWebGradlePlugin.groovy b/src/main/groovy/org/grails/gradle/plugin/web/GrailsWebGradlePlugin.groovy index d76c4062..36ff7816 100644 --- a/src/main/groovy/org/grails/gradle/plugin/web/GrailsWebGradlePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/web/GrailsWebGradlePlugin.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2014 original authors + * Copyright 2014-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/main/groovy/org/grails/gradle/plugin/web/gsp/GroovyPageForkCompileTask.groovy b/src/main/groovy/org/grails/gradle/plugin/web/gsp/GroovyPageForkCompileTask.groovy index 6d8cdc43..7c87911d 100644 --- a/src/main/groovy/org/grails/gradle/plugin/web/gsp/GroovyPageForkCompileTask.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/web/gsp/GroovyPageForkCompileTask.groovy @@ -1,3 +1,18 @@ +/* + * Copyright 2024 original authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.grails.gradle.plugin.web.gsp import groovy.transform.CompileDynamic diff --git a/src/main/groovy/org/grails/gradle/plugin/web/gsp/GroovyPagePlugin.groovy b/src/main/groovy/org/grails/gradle/plugin/web/gsp/GroovyPagePlugin.groovy index 938f7ff2..29a6c457 100644 --- a/src/main/groovy/org/grails/gradle/plugin/web/gsp/GroovyPagePlugin.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/web/gsp/GroovyPagePlugin.groovy @@ -1,3 +1,18 @@ +/* + * Copyright 2024 original authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.grails.gradle.plugin.web.gsp import groovy.transform.CompileDynamic diff --git a/src/main/groovy/org/grails/gradle/plugin/web/gsp/GspCompileOptions.groovy b/src/main/groovy/org/grails/gradle/plugin/web/gsp/GspCompileOptions.groovy index a21376fb..5a61490f 100644 --- a/src/main/groovy/org/grails/gradle/plugin/web/gsp/GspCompileOptions.groovy +++ b/src/main/groovy/org/grails/gradle/plugin/web/gsp/GspCompileOptions.groovy @@ -1,3 +1,18 @@ +/* + * Copyright 2024 original authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.grails.gradle.plugin.web.gsp import org.gradle.api.model.ObjectFactory @@ -5,7 +20,7 @@ import org.gradle.api.tasks.Input import org.gradle.api.tasks.Nested import org.gradle.api.tasks.compile.AbstractOptions import org.gradle.api.tasks.compile.GroovyForkOptions -import javax.inject.Inject; +import javax.inject.Inject /** * Presents the Compile Options used by the {@llink GroovyPageForkCompileTask}