Skip to content

Commit 739db6f

Browse files
committed
Use Automation from Security Projects
1 parent 8bd4e27 commit 739db6f

File tree

57 files changed

+1851
-954
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1851
-954
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,68 +8,41 @@ on:
88

99
jobs:
1010
build:
11-
runs-on: ubuntu-latest
12-
if: ${{ github.repository == 'spring-projects/spring-security-kerberos' }}
11+
name: Build
12+
uses: spring-io/spring-security-release-tools/.github/workflows/build.yml@v1
1313
strategy:
14-
fail-fast: false
1514
matrix:
1615
include:
17-
- nickname: linux adopt 17
18-
version: 17
19-
distribution: adopt
20-
- nickname: linux liberica 17
21-
version: 17
22-
distribution: liberica
23-
name: CI Build ${{ matrix.nickname }}
24-
steps:
25-
- uses: actions/checkout@v3
26-
- uses: spring-io/spring-gradle-build-action@v1
27-
with:
28-
distribution: ${{ matrix.distribution }}
29-
java-version: ${{ matrix.version }}
30-
- name: Build
31-
env:
32-
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }}
33-
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
34-
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
35-
run: ./gradlew build
36-
- uses: actions/upload-artifact@v3
37-
if: ${{ failure() }}
38-
with:
39-
name: buildreports
40-
retention-days: 1
41-
path: |
42-
*/build/reports
43-
spring-security-kerberos-samples/*/build/reports
44-
publish:
45-
runs-on: ubuntu-latest
46-
needs: [build]
47-
steps:
48-
- uses: actions/checkout@v3
49-
- uses: spring-io/spring-gradle-build-action@v1
50-
with:
51-
distribution: adopt
52-
java-version: 17
53-
- name: Build
54-
env:
55-
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
56-
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PASSPHRASE }}
57-
OSSRH_TOKEN_USERNAME: ${{ secrets.OSSRH_S01_TOKEN_USERNAME }}
58-
OSSRH_TOKEN_PASSWORD: ${{ secrets.OSSRH_S01_TOKEN_PASSWORD }}
59-
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
60-
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
61-
DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
62-
run: |
63-
./gradlew build publishArtifacts \
64-
-PossrhUsername="$OSSRH_TOKEN_USERNAME" \
65-
-PossrhPassword="$OSSRH_TOKEN_PASSWORD" \
66-
-PartifactoryUsername="$ARTIFACTORY_USERNAME" \
67-
-PartifactoryPassword="$ARTIFACTORY_PASSWORD"
16+
- nickname: linux adopt 17
17+
jdk: 17
18+
jdk-distribution: adopt
19+
- nickname: linux liberica 17
20+
version: 17
21+
distribution: liberica
22+
with:
23+
runs-on: ubuntu-latest
24+
java-version: ${{ matrix.jdk }}
25+
distribution: ${{ matrix.jdk-distribution }}
26+
secrets: inherit
27+
deploy-artifacts:
28+
name: Deploy Artifacts
29+
needs: [ build ]
30+
uses: spring-io/spring-security-release-tools/.github/workflows/deploy-artifacts.yml@v1
31+
with:
32+
should-deploy-artifacts: ${{ needs.build.outputs.should-deploy-artifacts }}
33+
secrets: inherit
34+
deploy-docs:
35+
name: Deploy Javadocs
36+
needs: [ build ]
37+
uses: spring-io/spring-security-release-tools/.github/workflows/deploy-docs.yml@v1
38+
with:
39+
should-deploy-docs: ${{ needs.build.outputs.should-deploy-artifacts }}
40+
secrets: inherit
6841
docs:
6942
runs-on: ubuntu-latest
70-
needs: [publish]
43+
needs: [build]
7144
steps:
72-
- uses: actions/checkout@v3
45+
- uses: actions/checkout@v4
7346
- name: Dispatch (partial build)
7447
if: github.ref_type == 'branch'
7548
env:

build.gradle

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
2-
id "base"
3-
id 'org.springframework.security.kerberos.root'
2+
id 'io.spring.convention.root'
3+
alias(libs.plugins.security.release)
44
}
55

66
description = 'Spring Security Kerberos'
@@ -37,3 +37,14 @@ develocity {
3737
termsOfUseAgree = 'yes'
3838
}
3939
}
40+
41+
springRelease {
42+
repositoryOwner = "spring-projects"
43+
repositoryName = "spring-security-kerberos"
44+
weekOfMonth = 4
45+
dayOfWeek = 1
46+
referenceDocUrl = "https://docs.spring.io/spring-security-kerberos/reference/{version}/"
47+
apiDocUrl = "https://docs.spring.io/spring-security-kerberos/docs/{version}/api/"
48+
replaceVersionInReferenceDocUrl = true
49+
releaseVersionPrefix = "v"
50+
}

buildSrc/build.gradle

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,39 @@
11
plugins {
22
id "java-gradle-plugin"
33
id "java"
4+
id "groovy"
45
}
56

6-
sourceCompatibility = JavaVersion.VERSION_17
7+
java {
8+
sourceCompatibility = JavaVersion.VERSION_17
9+
}
710

811
repositories {
912
gradlePluginPortal()
1013
mavenCentral()
11-
maven { url 'https://repo.spring.io/plugins-release/' }
12-
maven { url "https://repo.spring.io/snapshot" }
13-
}
14-
15-
ext {
16-
def propertiesFile = new File(new File("$projectDir").parentFile, "gradle.properties")
17-
propertiesFile.withInputStream {
18-
def properties = new Properties()
19-
properties.load(it)
20-
set("springFrameworkVersion", properties["springFrameworkVersion"])
21-
}
14+
maven { url "https://repo.spring.io/plugins-release/" }
2215
}
2316

2417
dependencies {
25-
implementation(platform(libs.spring.framework.bom))
26-
implementation("org.springframework:spring-core")
27-
implementation 'org.asciidoctor:asciidoctor-gradle-jvm:3.3.2'
28-
implementation 'org.jfrog.buildinfo:build-info-extractor-gradle:4.33.16'
29-
implementation 'org.antora:gradle-antora-plugin:1.0.0'
30-
implementation 'io.spring.gradle.antora:spring-antora-plugin:0.0.1'
31-
implementation 'io.github.gradle-nexus:publish-plugin:1.1.0'
18+
implementation "com.github.ben-manes:gradle-versions-plugin:0.38.0"
19+
implementation "io.github.gradle-nexus:publish-plugin:1.1.0"
20+
implementation "io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.41"
21+
implementation "io.spring.nohttp:nohttp-gradle:0.0.11"
22+
implementation "org.asciidoctor:asciidoctor-gradle-jvm:3.3.2"
23+
implementation "org.asciidoctor:asciidoctor-gradle-jvm-pdf:3.3.2"
24+
implementation "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
25+
implementation "org.hidetake:gradle-ssh-plugin:2.10.1"
26+
implementation "org.jfrog.buildinfo:build-info-extractor-gradle:5.2.0"
27+
implementation "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.7.1"
28+
implementation "org.springframework:spring-core:6.1.7"
3229
}
3330

31+
3432
gradlePlugin {
3533
plugins {
36-
modulePlugin {
37-
id = "org.springframework.security.kerberos.module"
38-
implementationClass = "org.springframework.security.kerberos.gradle.ModulePlugin"
39-
}
40-
bomPlugin {
41-
id = "org.springframework.security.kerberos.bom"
42-
implementationClass = "org.springframework.security.kerberos.gradle.BomPlugin"
43-
}
44-
docsPlugin {
45-
id = "org.springframework.security.kerberos.docs"
46-
implementationClass = "org.springframework.security.kerberos.gradle.DocsPlugin"
47-
}
48-
distPlugin {
49-
id = "org.springframework.security.kerberos.root"
50-
implementationClass = "org.springframework.security.kerberos.gradle.RootPlugin"
51-
}
5234
samplePlugin {
5335
id = "org.springframework.security.kerberos.sample"
5436
implementationClass = "org.springframework.security.kerberos.gradle.SamplePlugin"
5537
}
5638
}
57-
}
39+
}

buildSrc/gradle/libs.versions.toml

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package io.spring.gradle.convention
2+
3+
import org.gradle.api.Plugin
4+
import org.gradle.api.Project
5+
import org.gradle.api.plugins.JavaPlatformPlugin
6+
import org.springframework.gradle.properties.SpringCopyPropertiesPlugin
7+
import org.springframework.gradle.SpringMavenPlugin
8+
9+
public class SpringMavenBomPlugin implements Plugin<Project> {
10+
static String MAVEN_BOM_TASK_NAME = "mavenBom"
11+
12+
public void apply(Project project) {
13+
project.plugins.apply(JavaPlatformPlugin)
14+
project.plugins.apply(SpringMavenPlugin)
15+
project.plugins.apply(SpringCopyPropertiesPlugin)
16+
}
17+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright 2002-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package org.springframework.gradle.docs
17+
18+
import org.gradle.api.Plugin
19+
import org.gradle.api.Project
20+
21+
class SpringDeployDocsPlugin implements Plugin<Project> {
22+
23+
@Override
24+
void apply(Project project) {
25+
project.getPluginManager().apply('org.hidetake.ssh')
26+
27+
project.ssh.settings {
28+
knownHosts = allowAnyHosts
29+
}
30+
project.remotes {
31+
docs {
32+
role 'docs'
33+
if (project.hasProperty('deployDocsHost')) {
34+
host = project.findProperty('deployDocsHost')
35+
}
36+
retryCount = 5 // retry 5 times (default is 0)
37+
retryWaitSec = 10 // wait 10 seconds between retries (default is 0)
38+
user = project.findProperty('deployDocsSshUsername')
39+
if (project.hasProperty('deployDocsSshKeyPath')) {
40+
identity = project.file(project.findProperty('deployDocsSshKeyPath'))
41+
} else if (project.hasProperty('deployDocsSshKey')) {
42+
identity = project.findProperty('deployDocsSshKey')
43+
}
44+
if (project.hasProperty('deployDocsSshPassphrase')) {
45+
passphrase = project.findProperty('deployDocsSshPassphrase')
46+
}
47+
}
48+
}
49+
50+
project.task('deployDocs') {
51+
dependsOn 'docsZip'
52+
doFirst {
53+
project.ssh.run {
54+
session(project.remotes.docs) {
55+
def now = System.currentTimeMillis()
56+
def name = project.rootProject.name
57+
def version = project.rootProject.version
58+
def tempPath = "/tmp/${name}-${now}-docs/".replaceAll(' ', '_')
59+
execute "mkdir -p $tempPath"
60+
61+
project.tasks.docsZip.outputs.each { o ->
62+
put from: o.files, into: tempPath
63+
}
64+
65+
execute "unzip $tempPath*.zip -d $tempPath"
66+
67+
def extractPath = "/var/www/domains/spring.io/docs/htdocs/autorepo/docs/${name}/${version}/"
68+
69+
execute "rm -rf $extractPath"
70+
execute "mkdir -p $extractPath"
71+
execute "mv $tempPath/docs/* $extractPath"
72+
execute "chmod -R g+w $extractPath"
73+
}
74+
}
75+
}
76+
}
77+
}
78+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Copyright 2002-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.spring.gradle.convention;
18+
19+
import java.io.File;
20+
21+
import org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask;
22+
import org.gradle.api.Plugin;
23+
import org.gradle.api.Project;
24+
import org.gradle.api.Task;
25+
import org.gradle.api.file.DuplicatesStrategy;
26+
import org.gradle.api.plugins.BasePlugin;
27+
import org.gradle.api.plugins.JavaPlugin;
28+
import org.gradle.api.plugins.PluginManager;
29+
import org.gradle.api.tasks.TaskContainer;
30+
import org.gradle.api.tasks.bundling.Zip;
31+
32+
import org.springframework.gradle.docs.SpringAsciidoctorPlugin;
33+
import org.springframework.gradle.docs.SpringJavadocApiPlugin;
34+
import org.springframework.gradle.docs.SpringJavadocOptionsPlugin;
35+
import org.springframework.gradle.management.SpringManagementConfigurationPlugin;
36+
import org.springframework.gradle.maven.SpringRepositoryPlugin;
37+
38+
/**
39+
* Aggregates asciidoc, javadoc, and deploying of the docs into a single plugin.
40+
*
41+
* @author Steve Riesenberg
42+
*/
43+
public class SpringDocsPlugin implements Plugin<Project> {
44+
@Override
45+
public void apply(Project project) {
46+
// Apply default plugins
47+
PluginManager pluginManager = project.getPluginManager();
48+
pluginManager.apply(BasePlugin.class);
49+
pluginManager.apply(JavaPlugin.class);
50+
pluginManager.apply(SpringManagementConfigurationPlugin.class);
51+
pluginManager.apply(SpringRepositoryPlugin.class);
52+
pluginManager.apply(SpringAsciidoctorPlugin.class);
53+
// Note: Applying plugin via id since it requires groovy compilation
54+
pluginManager.apply("org.springframework.gradle.deploy-docs");
55+
pluginManager.apply(SpringJavadocApiPlugin.class);
56+
pluginManager.apply(SpringJavadocOptionsPlugin.class);
57+
58+
TaskContainer tasks = project.getTasks();
59+
project.configure(tasks.withType(AbstractAsciidoctorTask.class), (task) -> {
60+
File destination = new File(project.getBuildDir(), "docs");
61+
task.setOutputDir(destination);
62+
task.sources((patternSet) -> {
63+
patternSet.include("**/*.adoc");
64+
patternSet.exclude("_*/**");
65+
});
66+
});
67+
68+
// Add task to create documentation archive
69+
Zip docsZip = tasks.create("docsZip", Zip.class, (zip) -> {
70+
zip.dependsOn(tasks.getByName("api"), tasks.getByName("asciidoctor")/*, tasks.getByName("asciidoctorPdf")*/);
71+
zip.setGroup("Distribution");
72+
zip.getArchiveBaseName().set(project.getRootProject().getName());
73+
zip.getArchiveClassifier().set("docs");
74+
zip.setDescription("Builds -docs archive containing all " +
75+
"Docs for deployment at docs.spring.io");
76+
zip.into("docs");
77+
zip.setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE);
78+
});
79+
80+
// Add task to aggregate documentation
81+
Task docs = tasks.create("docs", (task) -> {
82+
task.dependsOn(docsZip);
83+
task.setGroup("Documentation");
84+
task.setDescription("An aggregator task to generate all the documentation");
85+
});
86+
87+
// Wire docs task into the build
88+
tasks.getByName("assemble").dependsOn(docs);
89+
}
90+
}

0 commit comments

Comments
 (0)