diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 43a1e53c7..3b6b6d266 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -75,6 +75,8 @@ jobs: steps: - name: "📥 Checkout repository" uses: actions/checkout@v4 + with: + fetch-tags: true - name: "☕️ Setup JDK" uses: actions/setup-java@v4 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7a319b514..1c2a171c6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -218,6 +218,8 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} ref: v${{ needs.publish.outputs.release_version }} + fetch-depth: 1 + fetch-tags: true - name: "☕️ Setup JDK" uses: actions/setup-java@v4 with: diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index bf5d293ce..34d22dda9 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -56,20 +56,5 @@ dependencies { implementation 'org.apache.grails:grails-gradle-plugins' implementation "org.nosphere.apache.rat:org.nosphere.apache.rat.gradle.plugin:${versions.get('ratVersion')}" implementation "org.gradle.crypto.checksum:org.gradle.crypto.checksum.gradle.plugin:${versions.get('gradleCryptoChecksumVersion')}" - - testImplementation 'org.spockframework:spock-core', { - exclude(group: 'org.codehaus.groovy') // Use Gradle provided version because: Could not resolve org.codehaus.groovy:groovy:3.0.12 - } - testRuntimeOnly 'org.junit.platform:junit-platform-launcher', { - // In Gradle 9, this needs to be declared - // https://docs.gradle.org/8.3/userguide/upgrading_version_8.html#test_framework_implementation_dependencies - } -} - -tasks.withType(Test).configureEach { - onlyIf { - !project.hasProperty('skipTests') - } - - useJUnitPlatform() + implementation 'org.apache.grails:grails-docs-core' } diff --git a/buildSrc/src/main/groovy/grails/plugin/springsecurity/CreateReleaseDropDownTask.groovy b/buildSrc/src/main/groovy/grails/plugin/springsecurity/CreateReleaseDropDownTask.groovy deleted file mode 100644 index 75fa3c50a..000000000 --- a/buildSrc/src/main/groovy/grails/plugin/springsecurity/CreateReleaseDropDownTask.groovy +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 grails.plugin.springsecurity - -import groovy.json.JsonSlurper -import org.gradle.api.DefaultTask -import org.gradle.api.file.RegularFileProperty -import org.gradle.api.provider.ListProperty -import org.gradle.api.provider.Property -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.InputFile -import org.gradle.api.tasks.Optional -import org.gradle.api.tasks.OutputFile -import org.gradle.api.tasks.TaskAction - -import java.util.regex.Pattern - -abstract class CreateReleaseDropDownTask extends DefaultTask { - - private static final Pattern VERSION_PATTERN = Pattern.compile("^[0-9]+\\.[0-9]+\\.[0-9]+([-.])?((RC|M)[0-9])?") - - @Input - abstract Property getGithubSlug() - - @Input - abstract Property getCurrentVersion() - - @Optional - @Input - abstract ListProperty getVersions() - - @Optional - @OutputFile - abstract RegularFileProperty getGuide() - - @OutputFile - abstract RegularFileProperty getIndex() - - @TaskAction - void createReleaseDropdown() { - def softwareVersions = getSoftwareVersions() - def versionHtml = "version ${currentVersion.get()}" - def selectHtml = createVersionSelectDropDownHtml(softwareVersions) - def versionWithSelectHtml = "version: $selectHtml" - if (guide.present) { - def guideFile = guide.get().asFile - guideFile.text = guideFile.text.replace(versionHtml, versionWithSelectHtml) - } - def indexFile = index.get().asFile - indexFile.text = indexFile.text.replace(versionHtml, versionWithSelectHtml) - } - - private List getSoftwareVersions() { - List softwareVersions = [] - if (versions.get().isEmpty()) { - def tags = new JsonSlurper() - .parse(new URL("https://api.github.com/repos/${this.githubSlug.get()}/tags")) - if (tags instanceof List) { - tags.stream() - . map(tagInfo -> { return (String) tagInfo['name'] }) - .filter(version -> version.startsWith('v')) - .map(version -> version.replace('v', '')) - .filter(VERSION_PATTERN.asPredicate()) - .map(version -> SoftwareVersion.build(version)) - .forEach(softwareVersions::add) - } - } else { - versions.get().stream() - .map(version -> SoftwareVersion.build(version)) - .forEach(softwareVersions::add) - } - - softwareVersions = softwareVersions.sort().unique().reverse() - softwareVersions - } - - private String createVersionSelectDropDownHtml(List softwareVersions) { - def repo = githubSlug.get().split('/')[1] - def selectHtml = '' - selectHtml - } -} diff --git a/buildSrc/src/main/groovy/grails/plugin/springsecurity/Snapshot.groovy b/buildSrc/src/main/groovy/grails/plugin/springsecurity/Snapshot.groovy deleted file mode 100644 index 21c369f25..000000000 --- a/buildSrc/src/main/groovy/grails/plugin/springsecurity/Snapshot.groovy +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 grails.plugin.springsecurity - -class Snapshot implements Comparable { - - private String text - - int getMilestoneVersion() { - text.replace("M", "").toInteger() - } - - int getReleaseCandidateVersion() { - text.replace("RC", "").toInteger() - } - - boolean isBuildSnapshot() { - text.endsWith("BUILD-SNAPSHOT") - } - - boolean isReleaseCandidate() { - text.startsWith("RC") - } - - boolean isMilestone() { - text.startsWith("M") - } - - Snapshot(String text) { - this.text = text - } - - @Override - int compareTo(Snapshot o) { - - if (this.buildSnapshot && !o.buildSnapshot) { - return 1 - } else if (!this.buildSnapshot && o.buildSnapshot) { - return -1 - } else if (this.buildSnapshot && o.buildSnapshot) { - return 0 - } - - if (this.releaseCandidate && !o.releaseCandidate) { - return 1 - } else if (!this.releaseCandidate && o.releaseCandidate) { - return -1 - } else if (this.releaseCandidate && o.releaseCandidate) { - return this.releaseCandidateVersion <=> o.releaseCandidateVersion - } - - if (this.milestone && !o.milestone) { - return 1 - } else if (!this.milestone && o.milestone) { - return -1 - } else if (this.milestone && o.milestone) { - return this.milestoneVersion <=> o.milestoneVersion - } - - return 0 - } -} - diff --git a/buildSrc/src/main/groovy/grails/plugin/springsecurity/SoftwareVersion.groovy b/buildSrc/src/main/groovy/grails/plugin/springsecurity/SoftwareVersion.groovy deleted file mode 100644 index f8492052a..000000000 --- a/buildSrc/src/main/groovy/grails/plugin/springsecurity/SoftwareVersion.groovy +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 grails.plugin.springsecurity - -class SoftwareVersion implements Comparable { - - int major - int minor - int patch - - Snapshot snapshot - String versionText - - static SoftwareVersion build(String versionString) { - - String[] parts = versionString.split('\\.') - SoftwareVersion version = null - - if (parts.length >= 3) { - - version = new SoftwareVersion() - version.versionText = versionString - version.major = parts[0].toInteger() - version.minor = parts[1].toInteger() - def patchParts = parts[2].split('-') - version.patch = patchParts[0].toInteger() - - if (patchParts.length > 1) { - version.snapshot = new Snapshot(patchParts[1]) - } else if (parts[2].contains('-')) { - String[] subparts = parts[2].split("-") - version.patch = subparts.first() as int - version.snapshot = new Snapshot(subparts[1..-1].join("-")) - return version - } - } - version - } - - String getStableVersion() { - if (this.isSnapshot()) { - return "${this.major}.${this.minor}.${this.patch - 1}" - } else { - return this.versionText - } - } - - String getSnapshotVersion() { - if (this.isSnapshot()) { - return this.versionText - } else { - return "${this.major}.${this.minor}.${this.patch + 1}" - } - } - - boolean isSnapshot() { - snapshot != null - } - - @Override - int compareTo(SoftwareVersion o) { - int majorCompare = this.major <=> o.major - if (majorCompare != 0) { - return majorCompare - } - - int minorCompare = this.minor <=> o.minor - if (minorCompare != 0) { - return minorCompare - } - - int patchCompare = this.patch <=> o.patch - if (patchCompare != 0) { - return patchCompare - } - - if (this.isSnapshot() && !o.isSnapshot()) { - return -1 - } else if (!this.isSnapshot() && o.isSnapshot()) { - return 1 - } else if (this.isSnapshot() && o.isSnapshot()) { - return this.getSnapshot() <=> o.getSnapshot() - } else { - return 0 - } - } - - @Override - String toString() { - return "SoftwareVersion{" + - "major=" + major + - ", minor=" + minor + - ", patch=" + patch + - ", snapshot=" + snapshot + - ", versionText='" + versionText + '\'' + - '}'; - } -} diff --git a/buildSrc/src/test/groovy/grails/plugin/springsecurity/SoftwareVersionSpec.groovy b/buildSrc/src/test/groovy/grails/plugin/springsecurity/SoftwareVersionSpec.groovy deleted file mode 100644 index e9e525100..000000000 --- a/buildSrc/src/test/groovy/grails/plugin/springsecurity/SoftwareVersionSpec.groovy +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 grails.plugin.springsecurity - -import spock.lang.Specification - -class SoftwareVersionSpec extends Specification { - - // TODO: I'm not 100% sure how the SoftwareVersion class is supposed to work so this test is incomplete - void "versions are parsed correctly"() { - - when: 'creating a SoftwareVersion' - def version = SoftwareVersion.build(versionString) - - then: 'the version is parsed correctly' - version.major == major - version.minor == minor - version.patch == patch - version.isSnapshot() == isSnapshot - version.stableVersion == stableVersion - version.snapshotVersion == snapshotVersion - - where: - versionString | major | minor | patch || isSnapshot | stableVersion | snapshotVersion - '1.2.3' | 1 | 2 | 3 || false | '1.2.3' | '1.2.4' - } -} diff --git a/gradle.properties b/gradle.properties index a4322778c..01cf377b8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -38,12 +38,6 @@ spyMemcachedVersion=2.12.3 # https://github.com/apache/grails-gradle-plugin/issues/222 slf4jPreventExclusion=true -# This list should be kept up-to-date with the latest release versions for each minor version branch. -# However, not all of these have documentation available, check the gh-pages branch to see -# if the docs are available before adding them to the list. -# The current projectVersion should not be included in this list, it will be added automatically. -docsVersionSelectorInclude=6.1.1, 6.0.3, 5.3.0, 5.2.1, 5.1.1, 5.0.0, 4.0.4, 3.2.3, 3.1.2 - org.gradle.caching=true org.gradle.daemon=true org.gradle.parallel=true diff --git a/gradle/docs-config.gradle b/gradle/docs-config.gradle index 1a1df3d5e..534d22300 100644 --- a/gradle/docs-config.gradle +++ b/gradle/docs-config.gradle @@ -17,17 +17,29 @@ * under the License. */ -import grails.plugin.springsecurity.CreateReleaseDropDownTask + +import grails.doc.dropdown.SoftwareVersion +import grails.doc.git.FetchTagsTask +import grails.doc.dropdown.CreateReleaseDropDownTask import org.asciidoctor.gradle.jvm.AsciidoctorTask apply plugin: 'org.asciidoctor.jvm.convert' -tasks.register('createReleaseDropDown', CreateReleaseDropDownTask) { - group = 'documentation' - githubSlug = 'apache/grails-spring-security' - currentVersion = version - versions = docsVersionSelectorInclude.split(',').collect { it.strip() } - index = layout.buildDirectory.file('docs/index.html') +def createReleaseDropdownTask = tasks.register('createReleaseDropdown', CreateReleaseDropDownTask) +createReleaseDropdownTask.configure { CreateReleaseDropDownTask it -> + it.filesToAddDropdowns = project.layout.buildDirectory.files('docs-modified/index.html') + it.sourceDocsDirectory = project.layout.buildDirectory.dir('docs') + it.modifiedPagesDirectory = project.layout.buildDirectory.dir('docs-modified') + + it.docBaseUrl = "https://apache.github.io/grails-spring-security" + it.versionHtml = 'version ' + project.version + '' + it.additionalPath = "${project.name - '-docs'}-plugin/guide/" + it.minimumVersion = SoftwareVersion.build('7.0.0-SNAPSHOT') // The combination of plugins & docs occurred for 7.0.x +} + +def fetchTagsTask = project.tasks.register('fetchTags', FetchTagsTask) +createReleaseDropdownTask.configure { + dependsOn(fetchTagsTask) } apply from: rootProject.layout.projectDirectory.file('gradle/groovydoc-config.gradle') @@ -61,16 +73,17 @@ tasks.named('asciidoctor', AsciidoctorTask) { outputs.dir(outputDir) } -tasks.register('guideDocs', Copy) { - group = 'documentation' - dependsOn('asciidoctor') +def guideDocsTask = project.tasks.register('guideDocs', Copy) +guideDocsTask.configure { Copy it -> + it.group = 'documentation' + it.dependsOn('asciidoctor') def sourceDir = layout.projectDirectory.dir('src/docs') def targetDir = layout.buildDirectory.dir('docs') - outputs.dir(targetDir) - from(sourceDir) - into(targetDir) - include('**/*.png', '**/*.jpg', '**/*.gif', '**/*.svg') - finalizedBy(findProperty('docsFinalizeTasks') as List ?: []) + it.outputs.dir(targetDir) + it.from(sourceDir) + it.into(targetDir) + it.include('**/*.png', '**/*.jpg', '**/*.gif', '**/*.svg') + it.finalizedBy(createReleaseDropdownTask) } tasks.register('copyGhPages', Copy) { @@ -86,7 +99,7 @@ tasks.register('copyGhPages', Copy) { } tasks.register('copyGuide', Copy) { - def sourceDir = layout.buildDirectory.dir('docs') + def sourceDir = layout.buildDirectory.dir('docs-modified') def targetDir = rootProject.layout.buildDirectory.dir("docs/${project.name - '-docs'}-plugin/guide") from(sourceDir) into(targetDir) @@ -94,7 +107,7 @@ tasks.register('copyGuide', Copy) { finalizedBy('copyGhPages') } dependsOn('guideDocs') - dependsOn(findProperty('docsFinalizeTasks') as List ?: []) + dependsOn(createReleaseDropdownTask) outputs.dir(targetDir) } diff --git a/plugin-core/docs/build.gradle b/plugin-core/docs/build.gradle index 2c046526e..85524df97 100644 --- a/plugin-core/docs/build.gradle +++ b/plugin-core/docs/build.gradle @@ -17,7 +17,8 @@ * under the License. */ -import grails.plugin.springsecurity.SoftwareVersion +import grails.doc.dropdown.CreateReleaseDropDownTask +import grails.doc.dropdown.SoftwareVersion plugins { id 'groovy' // For groovydoc task @@ -30,9 +31,8 @@ ext { windowTitle: 'spring-security-core ' + projectVersion + ' API' ] ] + asciidoctorAttributes = [ - stableversion : SoftwareVersion.build(projectVersion).stableVersion, - snapshotversion : SoftwareVersion.build(projectVersion).snapshotVersion, copyright : 'Apache License, Version 2.0', docinfo1 : 'true', doctype : 'book', @@ -52,7 +52,6 @@ ext { toc2 : '', toclevels : '2' ] - docsFinalizeTasks = ['createReleaseDropDown'] } apply { diff --git a/plugin-core/docs/src/docs/introduction/configGroovy.adoc b/plugin-core/docs/src/docs/introduction/configGroovy.adoc index 74d5b1630..cbe5035c6 100644 --- a/plugin-core/docs/src/docs/introduction/configGroovy.adoc +++ b/plugin-core/docs/src/docs/introduction/configGroovy.adoc @@ -44,6 +44,6 @@ If your application incorporates the CXF Grails plugin, it's crucial to arrange dependencies { implementation 'org.grails.plugins:cxf:3.1.1' // CXF above security. - implementation 'org.grails.plugins:spring-security-core:{stableversion}' + implementation 'org.grails.plugins:spring-security-core:{revnumber}' } ---- \ No newline at end of file diff --git a/plugin-core/docs/src/docs/introduction/gettingStarted.adoc b/plugin-core/docs/src/docs/introduction/gettingStarted.adoc index 4488d45ff..b2d4107ef 100644 --- a/plugin-core/docs/src/docs/introduction/gettingStarted.adoc +++ b/plugin-core/docs/src/docs/introduction/gettingStarted.adoc @@ -28,7 +28,7 @@ Begin by installing the Spring Security plugin into your Grails project. Add the [source,gradle,subs="+attributes"] ---- -implementation 'org.grails.plugins:spring-security-core:{stableversion}' +implementation 'org.grails.plugins:spring-security-core:{revnumber}' ---- .Step 2: Run the Initialization Script diff --git a/plugin-core/docs/src/docs/introduction/installation.adoc b/plugin-core/docs/src/docs/introduction/installation.adoc index 324f6c4fc..99119bef6 100644 --- a/plugin-core/docs/src/docs/introduction/installation.adoc +++ b/plugin-core/docs/src/docs/introduction/installation.adoc @@ -40,7 +40,7 @@ Ensure you have the following set up: ---- dependencies { // ... other dependencies - implementation 'org.grails.plugins:spring-security-core:{stableversion}' + implementation 'org.grails.plugins:spring-security-core:{revnumber}' } ---- + diff --git a/plugin-rest/docs/src/docs/index.adoc b/plugin-rest/docs/src/docs/index.adoc index ad4f313b8..9b27757cb 100644 --- a/plugin-rest/docs/src/docs/index.adoc +++ b/plugin-rest/docs/src/docs/index.adoc @@ -23,8 +23,6 @@ under the License. :source-highlighter: coderay :numbered: -Version: {version} - == Introduction to the Spring Security REST plugin include::introduction.adoc[]