diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 33e79b2c..feb785d6 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -12,45 +12,52 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: ['17'] - env: - WORKSPACE: ${{ github.workspace }} + java: ['17', '21'] 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 @@ -58,24 +65,27 @@ 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 + - 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: Generate Groovydoc + - 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 }} - with: - arguments: groovydoc - - name: Publish to Github Pages + 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 groovydoc + - name: "🚀 Publish to Github Pages" id: docs if: success() uses: grails/github-pages-deploy-action@v2 @@ -86,6 +96,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 }} \ No newline at end of file + 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 1db237d7..506035dc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,53 +12,55 @@ 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 }} - - name: Upload Distribution + 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 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 }} @@ -67,9 +69,10 @@ 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 }} - with: - arguments: | + 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 -Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg publishToSonatype closeSonatypeStagingRepository @@ -79,26 +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: - 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 }} - with: - arguments: | + run: > + ./gradlew findSonatypeStagingRepository releaseSonatypeStagingRepository - name: Run post-release @@ -114,38 +122,41 @@ 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 + - 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: "🐘 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 }} - with: - arguments: groovydoc - - name: Publish to Github Pages + 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 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 4e66fcc1..05534f39 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 ease publishing with the maven publish plugin or the nexus publish plugin. + +Example Usage: + + grailsPublish { + websiteUrl = 'http://foo.com/myplugin' + license { + name = 'Apache-2.0' + } + 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 + + 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 `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. + +`MAVEN_PUBLISH` Environment Variables are: + + MAVEN_PUBLISH_USERNAME + MAVEN_PUBLISH_PASSWORD + MAVEN_PUBLISH_URL + +`NEXUS_PUBLISH` Environment Variables are: + + NEXUS_PUBLISH_USERNAME + NEXUS_PUBLISH_PASSWORD + NEXUS_PUBLISH_URL + NEXUS_PUBLISH_SNAPSHOT_URL + NEXUS_PUBLISH_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..db4ebcf9 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 +rootProject.name = 'grails-gradle-plugin' \ No newline at end of file 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/internal/GrailsProfilePublishGradlePlugin.groovy b/src/main/groovy/org/grails/gradle/plugin/profiles/GrailsProfilePublishGradlePlugin.groovy similarity index 67% 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..8ee4968d 100644 --- a/src/main/groovy/org/grails/gradle/plugin/profiles/internal/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, @@ -13,8 +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 import org.gradle.api.Action @@ -23,10 +22,10 @@ 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.profiles.GrailsProfileGradlePlugin -import org.grails.gradle.plugin.publishing.internal.GrailsCentralPublishGradlePlugin +import org.grails.gradle.plugin.publishing.GrailsPublishGradlePlugin import java.nio.file.Files @@ -39,32 +38,22 @@ 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) { 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) }) } - @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,17 +66,12 @@ class GrailsProfilePublishGradlePlugin extends GrailsCentralPublishGradlePlugin 'profile' } - @Override - protected String getDefaultRepo() { - 'profiles' - } - @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/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/internal/GrailsPublishExtension.groovy b/src/main/groovy/org/grails/gradle/plugin/publishing/GrailsPublishExtension.groovy similarity index 78% 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..860e390d 100644 --- a/src/main/groovy/org/grails/gradle/plugin/publishing/internal/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,41 +13,40 @@ * See the License for the specific language governing permissions and * 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 /** * @author Puneet Behl + * @author James Daugherty * @since 4.0.11 */ @CompileStatic class GrailsPublishExtension { - /** - * The slug from github + * Determines which plugin is used to publish snapshots */ - String githubSlug + PublishType snapshotPublishType = PublishType.MAVEN_PUBLISH /** - * The the publishing user + * Determines which plugin is used to publish releases */ - String user + PublishType releasePublishType = PublishType.NEXUS_PUBLISH /** - * 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 +56,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 +70,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 67% 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..0b2f41a1 100644 --- a/src/main/groovy/org/grails/gradle/plugin/publishing/internal/GrailsCentralPublishGradlePlugin.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, @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * 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.InitializeNexusStagingRepository import io.github.gradlenexus.publishplugin.NexusPublishPlugin import org.gradle.api.Plugin import org.gradle.api.Project @@ -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,57 +36,56 @@ 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 + * @author James Daugherty * @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' + websiteUrl = 'https://example.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"] + 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 grailsPublish { - user = 'user' - key = 'key' githubSlug = 'foo/bar' 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'] } -Your publishing user and key can also be placed in PROJECT_HOME/gradle.properties or USER_HOME/gradle.properties. For example: +By default snapshotPublishType is set to MAVEN_PUBLISH and releasePublishType is set to NEXUS_PUBLISH. -bintrayUser=user -bintrayKey=key +The credentials and connection url must be specified as a project property or an environment variable: -Or using environment variables: +`MAVEN_PUBLISH` Environment Variables are: + MAVEN_PUBLISH_USERNAME + MAVEN_PUBLISH_PASSWORD + MAVEN_PUBLISH_URL -BINTRAY_USER=user -BINTRAY_KEY=key +`NEXUS_PUBLISH` Environment Variables are: + NEXUS_PUBLISH_USERNAME + NEXUS_PUBLISH_PASSWORD + NEXUS_PUBLISH_URL + NEXUS_PUBLISH_SNAPSHOT_URL + NEXUS_PUBLISH_STAGING_PROFILE_ID """ } @@ -95,43 +93,59 @@ BINTRAY_KEY=key void apply(Project project) { final ExtensionContainer extensionContainer = project.extensions 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 GrailsPublishExtension gpe = extensionContainer.create('grailsPublish', GrailsPublishExtension) + + 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 { - 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("") - } + 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 nexusPublish = (isSnapshot && snapshotPublishType == PublishType.NEXUS_PUBLISH) || (isRelease && releasePublishType == PublishType.NEXUS_PUBLISH) + + 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 (isSnapshot) { + 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 (!mavenPublishUrl) { + // throw new RuntimeException('Could not locate a project property of `mavenPublishUrl` or an environment variable of `MAVEN_PUBLISH_URL`') } - url gpe.snapshotUrl? gpe.snapshotUrl : getDefaultGrailsCentralSnapshotRepo() + url = mavenPublishUrl } } } @@ -141,11 +155,11 @@ BINTRAY_KEY=key 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 } @@ -157,6 +171,7 @@ BINTRAY_KEY=key pom.withXml { Node pomNode = asNode() + // Prevent multiple dependencyManagement nodes if (pomNode.dependencyManagement) { pomNode.dependencyManagement[0].replaceNode {} } @@ -171,16 +186,12 @@ BINTRAY_KEY=key if (!websiteUrl) { throw new RuntimeException(getErrorMessage('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 @@ -208,7 +219,7 @@ BINTRAY_KEY=key delegate.developerConnection "scm:git@github.com:${gpe.githubSlug}.git" } delegate.issueManagement { - delegate.system "Github Issues" + delegate.system 'Github Issues' delegate.url "https://github.com/$gpe.githubSlug/issues" } } else { @@ -224,17 +235,15 @@ BINTRAY_KEY=key if (gpe.issueTrackerUrl) { delegate.issueManagement { - delegate.system "Issue Tracker" + 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 { @@ -264,56 +273,51 @@ BINTRAY_KEY=key } } - if (isRelease) { - pluginManager.apply(NexusPublishPlugin.class) - pluginManager.apply(SigningPlugin.class) - + if (nexusPublish) { 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(InitializeNexusStagingRepository).configureEach { InitializeNexusStagingRepository task -> + task.shouldRunAfter = 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 (nexusPublishUrl) { + nexusUrl = project.uri(nexusPublishUrl) } - if (ossSnapshotUrl) { - snapshotRepositoryUrl = project.uri(ossSnapshotUrl) + if (nexusPublishSnapshotUrl) { + snapshotRepositoryUrl = project.uri(nexusPublishSnapshotUrl) } - username = ossUser - password = ossPass - stagingProfileId = ossStagingProfileId + 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') }) } } @@ -323,18 +327,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()? [ @@ -345,15 +337,7 @@ BINTRAY_KEY=key } protected String getDefaultClassifier() { - "plugin" - } - - protected String getDefaultDescription(Project project) { - "Grails ${project.name} $defaultClassifier" - } - - protected String getDefaultRepo() { - "plugins" + 'plugin' } } diff --git a/src/main/groovy/org/grails/gradle/plugin/publishing/PublishType.groovy b/src/main/groovy/org/grails/gradle/plugin/publishing/PublishType.groovy new file mode 100644 index 00000000..2002aaf6 --- /dev/null +++ b/src/main/groovy/org/grails/gradle/plugin/publishing/PublishType.groovy @@ -0,0 +1,21 @@ +/* + * 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 { + MAVEN_PUBLISH, + NEXUS_PUBLISH +} 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} 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