diff --git a/.github/actions/deploy-schema/action.yml b/.github/actions/deploy-schema/action.yml new file mode 100644 index 000000000..f2a65e201 --- /dev/null +++ b/.github/actions/deploy-schema/action.yml @@ -0,0 +1,21 @@ +name: Deploy Schema +description: Deploys the schema zip to the docs site + +inputs: + java-version: + description: "The Java version to use" + required: false + default: "17" + +runs: + using: composite + steps: + - name: Set up JDK ${{ inputs.java-version }} + uses: spring-io/spring-gradle-build-action@c8668747d7c264864c8c7f7026d0d277d14a78dc # v2.0.6 + with: + java-version: ${{ inputs.java-version }} + distribution: temurin + - name: Deploy Schema + shell: bash + run: | + ./gradlew deploySchema -PdeployDocsSshKey="$DOCS_SSH_KEY" -PdeployDocsSshUsername="$DOCS_USERNAME" -PdeployDocsHost="$DOCS_HOST" --stacktrace --info diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..d2e443251 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,75 @@ +name: CI + +on: + push: + branches: + - "*.x" + - "release/**" + schedule: + - cron: '0 10 * * *' # Once per day at 10am UTC + workflow_dispatch: # Manual trigger + +permissions: + contents: read + +jobs: + test: + name: Test Against Snapshots + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: spring-io/spring-security-actions/test@4386090bf7852faa1d61782f981811441757dbb8 # main + with: + java-version: '17' + gradle-args: -PisOverrideVersionCatalog -PtestToolchain=17 -PspringFrameworkVersion=7.+ -PspringDataVersion=2025.0.+ + compute-version: + name: Compute Version + runs-on: ubuntu-latest + outputs: + version: ${{ steps.project-version.outputs.version }} + snapshot: ${{ steps.project-version.outputs.snapshot }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - id: project-version + name: Extract Project Version + uses: spring-io/spring-release-actions/compute-version@a1f321783a0769dd2aea4fad6c2ae2f95a52b885 # 0.0.5 + build-and-deploy: + name: Build and Deploy + needs: [ test, compute-version ] + if: needs.compute-version.outputs.snapshot == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: spring-io/spring-security-actions/build@4386090bf7852faa1d61782f981811441757dbb8 # main + with: + java-version: '17' + - id: deploy-location + name: Compute Deploy Location + uses: spring-io/spring-release-actions/compute-artifact-repository@a1f321783a0769dd2aea4fad6c2ae2f95a52b885 # 0.0.5 + with: + version: ${{ needs.compute-version.outputs.version }} + - name: Deploy Artifacts + uses: spring-io/spring-security-actions/ensure-artifacts@f8ef0d53fc61799c18f19bc6a4c42ccb9aa265de + with: + version: ${{ needs.compute-version.outputs.version }} + username: ${{ secrets.ARTIFACTORY_USERNAME }} + password: ${{ secrets.ARTIFACTORY_PASSWORD }} + repository-uri: ${{ steps.deploy-location.outputs.uri }} + repository-name: ${{ steps.deploy-location.outputs.name }} + project: ${{ steps.deploy-location.outputs.project }} + local-repository: build/publications/repos + artifact-path: org/springframework/ldap/spring-ldap-core + deploy-schema: + name: Deploy Schema + needs: [ test, compute-version ] + if: needs.compute-version.outputs.snapshot == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: ./.github/actions/deploy-schema + with: + java-version: '17' + env: + DOCS_SSH_KEY: ${{ secrets.DOCS_SSH_KEY }} + DOCS_USERNAME: ${{ secrets.DOCS_USERNAME }} + DOCS_HOST: ${{ secrets.DOCS_HOST }} diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml deleted file mode 100644 index ced8a704d..000000000 --- a/.github/workflows/continuous-integration-workflow.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: CI - -on: - push: - branches-ignore: - - "dependabot/**" - schedule: - - cron: '0 10 * * *' # Once per day at 10am UTC - workflow_dispatch: # Manual trigger - -jobs: - build: - name: Build - uses: spring-io/spring-security-release-tools/.github/workflows/build.yml@b92832ecbc7cbe969201e6beafbde0ee400cf095 # v1.0.15 - strategy: - matrix: - os: [ ubuntu-latest ] - jdk: [ 17 ] - with: - runs-on: ${{ matrix.os }} - java-version: ${{ matrix.jdk }} - distribution: temurin - secrets: inherit - test: - name: Test Against Snapshots - uses: spring-io/spring-security-release-tools/.github/workflows/test.yml@b92832ecbc7cbe969201e6beafbde0ee400cf095 # v1.0.15 - strategy: - matrix: - include: - - java-version: 17 - with: - java-version: ${{ matrix.java-version }} - test-args: --refresh-dependencies -PforceMavenRepositories=snapshot -PisOverrideVersionCatalog -PtestToolchain=17 -PspringFrameworkVersion=7.+ -PspringDataVersion=2025.0.+ --stacktrace - deploy-artifacts: - name: Deploy Artifacts - needs: [ build, test ] - uses: spring-io/spring-security-release-tools/.github/workflows/deploy-artifacts.yml@b92832ecbc7cbe969201e6beafbde0ee400cf095 # v1.0.15 - with: - should-deploy-artifacts: ${{ needs.build.outputs.should-deploy-artifacts }} - default-publish-milestones-central: true - secrets: inherit - deploy-schema: - name: Deploy Schema - needs: [ build ] - uses: spring-io/spring-security-release-tools/.github/workflows/deploy-schema.yml@b92832ecbc7cbe969201e6beafbde0ee400cf095 # v1.0.15 - with: - should-deploy-schema: ${{ needs.build.outputs.should-deploy-artifacts }} - secrets: inherit - perform-release: - name: Perform Release - needs: [ deploy-artifacts, deploy-schema ] - uses: spring-io/spring-security-release-tools/.github/workflows/perform-release.yml@b92832ecbc7cbe969201e6beafbde0ee400cf095 # v1.0.15 - with: - should-perform-release: ${{ needs.deploy-artifacts.outputs.artifacts-deployed }} - project-version: ${{ needs.deploy-artifacts.outputs.project-version }} - milestone-repo-url: https://repo1.maven.org/maven2 - release-repo-url: https://repo1.maven.org/maven2 - artifact-path: org/springframework/ldap/spring-ldap-core - slack-announcing-id: spring-ldap-announcing - secrets: inherit diff --git a/.github/workflows/auto-merge-dependabot-prs.yml b/.github/workflows/dependabot-pull-request-automerge.yml similarity index 100% rename from .github/workflows/auto-merge-dependabot-prs.yml rename to .github/workflows/dependabot-pull-request-automerge.yml diff --git a/.github/workflows/pr-build-workflow.yml b/.github/workflows/pr-build-workflow.yml deleted file mode 100644 index 6de2ef0cf..000000000 --- a/.github/workflows/pr-build-workflow.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: PR Build - -on: pull_request - -jobs: - build: - name: Build - runs-on: ubuntu-latest - if: github.repository == 'spring-projects/spring-ldap' - strategy: - matrix: - jdk: [17] - fail-fast: false - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - name: Set up JDK ${{ matrix.jdk }} - uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5.6.0 - with: - java-version: ${{ matrix.jdk }} - distribution: 'temurin' - cache: 'gradle' - - name: Cache Gradle packages - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} - - name: Build with Gradle - run: ./gradlew clean build --no-daemon --stacktrace diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml deleted file mode 100644 index 7bfa6704d..000000000 --- a/.github/workflows/publish-release.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Publish Release - -on: - workflow_dispatch: # Manual trigger - inputs: - version: - description: "The release to publish" - required: true - -jobs: - perform-release: - name: Perform Release - uses: spring-io/spring-security-release-tools/.github/workflows/perform-release.yml@b92832ecbc7cbe969201e6beafbde0ee400cf095 # v1.0.15 - with: - should-perform-release: true - project-version: ${{ inputs.version }} - milestone-repo-url: https://repo1.maven.org/maven2 - release-repo-url: https://repo1.maven.org/maven2 - artifact-path: org/springframework/ldap/spring-ldap-core - slack-announcing-id: spring-ldap-announcing - secrets: inherit \ No newline at end of file diff --git a/.github/workflows/pull-request-build.yml b/.github/workflows/pull-request-build.yml new file mode 100644 index 000000000..5d23285c6 --- /dev/null +++ b/.github/workflows/pull-request-build.yml @@ -0,0 +1,17 @@ +name: Pull Request - Build + +on: pull_request + +permissions: + contents: read + +jobs: + build: + name: Build + runs-on: ubuntu-latest + if: github.repository == 'spring-projects/spring-ldap' + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: spring-io/spring-security-actions/pr-build@4386090bf7852faa1d61782f981811441757dbb8 # main + with: + java-version: '17' diff --git a/.github/workflows/release-scheduler.yml b/.github/workflows/release-scheduler.yml deleted file mode 100644 index 13616654d..000000000 --- a/.github/workflows/release-scheduler.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Release Scheduler - -on: - workflow_dispatch: - -permissions: read-all - -jobs: - dispatch_scheduled_releases: - name: Dispatch scheduled releases - if: ${{ github.repository_owner == 'spring-projects' }} - strategy: - matrix: - # List of active maintenance branches. - branch: [ main, 4.0.x, 3.3.x, 3.2.x, 2.4.x ] - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - fetch-depth: 1 - - name: Dispatch - env: - GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }} - run: gh workflow run update-scheduled-release-version.yml -r ${{ matrix.branch }} diff --git a/.github/workflows/update-scheduled-release-version.yml b/.github/workflows/update-scheduled-release-version.yml deleted file mode 100644 index f4a3720d7..000000000 --- a/.github/workflows/update-scheduled-release-version.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: Update Scheduled Release Version - -on: - workflow_dispatch: # Manual trigger only. Triggered by release-scheduler.yml on main. - -jobs: - update-scheduled-release-version: - name: Update Scheduled Release Version - uses: spring-io/spring-security-release-tools/.github/workflows/update-scheduled-release-version.yml@b92832ecbc7cbe969201e6beafbde0ee400cf095 # v1.0.15 - secrets: inherit diff --git a/build.gradle b/build.gradle index c8572dca1..c9dbb9170 100644 --- a/build.gradle +++ b/build.gradle @@ -6,9 +6,7 @@ buildscript { dependencies { classpath "com.github.ben-manes:gradle-versions-plugin:0.53.0" classpath "io.spring.gradle:dependency-management-plugin:1.1.7" - classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.34.2" classpath 'org.hidetake:gradle-ssh-plugin:2.10.1' - classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0' classpath "io.spring.javaformat:spring-javaformat-gradle-plugin:$springJavaformatVersion" } } @@ -33,10 +31,6 @@ description = "Spring LDAP" ext.coreModules = subprojects.findAll { p-> (!p.name.contains("test") && !p.name.contains("sample") && !p.name.contains("sandbox")) || p.name.contains("spring-ldap-test") } -configure(subprojects - coreModules) { - tasks.findByPath("publishArtifacts")?.enabled = false -} - nohttp { source.exclude "buildSrc/build/**" } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index e4b027272..42cc7a43e 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -49,18 +49,6 @@ gradlePlugin { id = "org.springframework.security.sagan" implementationClass = "org.springframework.gradle.sagan.SaganPlugin" } - githubMilestone { - id = "org.springframework.github.milestone" - implementationClass = "org.springframework.gradle.github.milestones.GitHubMilestonePlugin" - } - githubChangelog { - id = "org.springframework.github.changelog" - implementationClass = "org.springframework.gradle.github.changelog.GitHubChangelogPlugin" - } - githubRelease { - id = "org.springframework.github.release" - implementationClass = "org.springframework.gradle.github.release.GitHubReleasePlugin" - } s101 { id = "s101" implementationClass = "s101.S101Plugin" @@ -81,7 +69,6 @@ dependencies { implementation 'org.yaml:snakeyaml:1.33' implementation localGroovy() - implementation 'io.github.gradle-nexus:publish-plugin:2.0.0' implementation 'io.projectreactor:reactor-core:3.8.6' implementation ('org.gretty:gretty:5.0.2') { exclude group: 'org.springframework.boot', module: 'spring-boot-loader-tools' @@ -95,7 +82,6 @@ dependencies { implementation 'net.sourceforge.htmlunit:htmlunit:2.70.0' implementation 'org.asciidoctor:asciidoctor-gradle-jvm:4.0.5' implementation 'org.hidetake:gradle-ssh-plugin:2.10.1' - implementation 'org.jfrog.buildinfo:build-info-extractor-gradle:4.34.2' implementation 'org.springframework:spring-core:6.2.19' implementation 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:7.1.0.6387' diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/ArtifactoryPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/ArtifactoryPlugin.groovy deleted file mode 100644 index c0c0f5057..000000000 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/ArtifactoryPlugin.groovy +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2006-present the original author or 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 io.spring.gradle.convention - -import org.gradle.api.Plugin -import org.gradle.api.Project - -class ArtifactoryPlugin implements Plugin { - - @Override - void apply(Project project) { - project.plugins.apply('com.jfrog.artifactory') - String name = Utils.getProjectName(project); - boolean isSnapshot = Utils.isSnapshot(project); - boolean isMilestone = Utils.isMilestone(project); - project.artifactory { - contextUrl = 'https://repo.spring.io' - publish { - repository { - repoKey = isSnapshot ? 'libs-snapshot-local' : isMilestone ? 'libs-milestone-local' : 'libs-release-local' - if(project.hasProperty('artifactoryUsername')) { - username = artifactoryUsername - password = artifactoryPassword - } - } - defaults { - publications('mavenJava') - } - } - } - } -} diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/MavenBomPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/MavenBomPlugin.groovy deleted file mode 100644 index 3b51b5267..000000000 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/MavenBomPlugin.groovy +++ /dev/null @@ -1,17 +0,0 @@ -package io.spring.gradle.convention - -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.plugins.JavaPlatformPlugin -import org.springframework.gradle.CopyPropertiesPlugin -import org.springframework.gradle.maven.SpringMavenPlugin - -public class MavenBomPlugin implements Plugin { - static String MAVEN_BOM_TASK_NAME = "mavenBom" - - public void apply(Project project) { - project.plugins.apply(JavaPlatformPlugin) - project.plugins.apply(SpringMavenPlugin) - project.plugins.apply(CopyPropertiesPlugin) - } -} diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/RootProjectPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/RootProjectPlugin.groovy index a12f3b6fd..ad6a49a33 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/RootProjectPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/RootProjectPlugin.groovy @@ -21,7 +21,6 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.plugins.BasePlugin import org.gradle.api.plugins.PluginManager -import org.springframework.gradle.maven.SpringNexusPublishPlugin class RootProjectPlugin implements Plugin { @@ -31,7 +30,6 @@ class RootProjectPlugin implements Plugin { pluginManager.apply(BasePlugin) pluginManager.apply(SchemaPlugin) pluginManager.apply(NoHttpPlugin) - pluginManager.apply(SpringNexusPublishPlugin) pluginManager.apply("org.sonarqube") project.repositories.mavenCentral() @@ -49,11 +47,6 @@ class RootProjectPlugin implements Plugin { property "sonar.links.scm_dev", "https://github.com/spring-projects/${projectName}.git" } } - - def finalizeDeployArtifacts = project.task("finalizeDeployArtifacts") - if (Utils.isRelease(project) && project.hasProperty("ossrhUsername")) { - finalizeDeployArtifacts.dependsOn project.tasks.closeAndReleaseOssrhStagingRepository - } } } diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringModulePlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringModulePlugin.groovy index 4cc008558..dee2917cb 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringModulePlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringModulePlugin.groovy @@ -35,12 +35,6 @@ class SpringModulePlugin extends AbstractSpringJavaPlugin { pluginManager.apply(SpringMavenPlugin.class); pluginManager.apply("io.spring.convention.jacoco"); - def deployArtifacts = project.task("deployArtifacts") - deployArtifacts.group = 'Deploy tasks' - deployArtifacts.description = "Deploys the artifacts to either Artifactory or Maven Central" - if (!Utils.isRelease(project)) { - deployArtifacts.dependsOn project.tasks.artifactoryPublish - } project.tasks.withType(Jar) { from(project.rootProject.files('LICENSE.txt')) { into('META-INF') diff --git a/buildSrc/src/main/java/org/springframework/gradle/github/RepositoryRef.java b/buildSrc/src/main/java/org/springframework/gradle/github/RepositoryRef.java deleted file mode 100644 index e570a47e9..000000000 --- a/buildSrc/src/main/java/org/springframework/gradle/github/RepositoryRef.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.springframework.gradle.github; - -public class RepositoryRef { - private String owner; - - private String name; - - public RepositoryRef() { - } - - public RepositoryRef(String owner, String name) { - this.owner = owner; - this.name = name; - } - - public String getOwner() { - return owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public String toString() { - return "RepositoryRef{" + - "owner='" + owner + '\'' + - ", name='" + name + '\'' + - '}'; - } - - public static RepositoryRefBuilder owner(String owner) { - return new RepositoryRefBuilder().owner(owner); - } - - public static final class RepositoryRefBuilder { - private String owner; - private String repository; - - private RepositoryRefBuilder() { - } - - private RepositoryRefBuilder owner(String owner) { - this.owner = owner; - return this; - } - - public RepositoryRefBuilder repository(String repository) { - this.repository = repository; - return this; - } - - public RepositoryRef build() { - return new RepositoryRef(owner, repository); - } - } -} diff --git a/buildSrc/src/main/java/org/springframework/gradle/github/changelog/GitHubChangelogPlugin.java b/buildSrc/src/main/java/org/springframework/gradle/github/changelog/GitHubChangelogPlugin.java deleted file mode 100644 index fe240dd6b..000000000 --- a/buildSrc/src/main/java/org/springframework/gradle/github/changelog/GitHubChangelogPlugin.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2006-present the original author or 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.springframework.gradle.github.changelog; - -import java.io.File; -import java.nio.file.Paths; - -import org.gradle.api.Action; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.artifacts.DependencySet; -import org.gradle.api.artifacts.repositories.ExclusiveContentRepository; -import org.gradle.api.artifacts.repositories.InclusiveRepositoryContentDescriptor; -import org.gradle.api.artifacts.repositories.IvyArtifactRepository; -import org.gradle.api.artifacts.repositories.IvyPatternRepositoryLayout; -import org.gradle.api.tasks.JavaExec; - -public class GitHubChangelogPlugin implements Plugin { - - public static final String CHANGELOG_GENERATOR_CONFIGURATION_NAME = "changelogGenerator"; - public static final String RELEASE_NOTES_PATH = "changelog/release-notes.md"; - - @Override - public void apply(Project project) { - createRepository(project); - createChangelogGeneratorConfiguration(project); - project.getTasks().register("generateChangelog", JavaExec.class, new Action<>() { - @Override - public void execute(JavaExec generateChangelog) { - File outputFile = project.file(Paths.get(project.getBuildDir().getPath(), RELEASE_NOTES_PATH)); - outputFile.getParentFile().mkdirs(); - generateChangelog.setGroup("Release"); - generateChangelog.setDescription("Generates the changelog"); - generateChangelog.setWorkingDir(project.getRootDir()); - generateChangelog.classpath(project.getConfigurations().getAt(CHANGELOG_GENERATOR_CONFIGURATION_NAME)); - generateChangelog.doFirst(new Action<>() { - @Override - public void execute(Task task) { - generateChangelog.args("--spring.config.location=scripts/release/release-notes-sections.yml", project.property("nextVersion"), outputFile.toString()); - } - }); - } - }); - } - - private void createChangelogGeneratorConfiguration(Project project) { - project.getConfigurations().create(CHANGELOG_GENERATOR_CONFIGURATION_NAME, new Action<>() { - @Override - public void execute(Configuration configuration) { - configuration.defaultDependencies(new Action<>() { - @Override - public void execute(DependencySet dependencies) { - dependencies.add(project.getDependencies().create("spring-io:github-changelog-generator:0.0.6")); - } - }); - } - }); - } - - private void createRepository(Project project) { - IvyArtifactRepository repository = project.getRepositories().ivy(new Action<>() { - @Override - public void execute(IvyArtifactRepository repository) { - repository.setUrl("https://github.com/"); - repository.patternLayout(new Action<>() { - @Override - public void execute(IvyPatternRepositoryLayout layout) { - layout.artifact("[organization]/[artifact]/releases/download/v[revision]/[artifact].[ext]"); - } - }); - repository.getMetadataSources().artifact(); - } - }); - project.getRepositories().exclusiveContent(new Action<>() { - @Override - public void execute(ExclusiveContentRepository exclusiveContentRepository) { - exclusiveContentRepository.forRepositories(repository); - exclusiveContentRepository.filter(new Action<>() { - @Override - public void execute(InclusiveRepositoryContentDescriptor descriptor) { - descriptor.includeGroup("spring-io"); - } - }); - } - }); - } -} diff --git a/buildSrc/src/main/java/org/springframework/gradle/github/milestones/GitHubMilestoneApi.java b/buildSrc/src/main/java/org/springframework/gradle/github/milestones/GitHubMilestoneApi.java deleted file mode 100644 index 8f24f6a6e..000000000 --- a/buildSrc/src/main/java/org/springframework/gradle/github/milestones/GitHubMilestoneApi.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2006-present the original author or 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.springframework.gradle.github.milestones; - -import java.io.IOException; -import java.util.List; - -import com.google.common.reflect.TypeToken; -import com.google.gson.Gson; -import okhttp3.Interceptor; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; - -import org.springframework.gradle.github.RepositoryRef; - -public class GitHubMilestoneApi { - private String baseUrl = "https://api.github.com"; - - private OkHttpClient client; - - private Gson gson = new Gson(); - - public GitHubMilestoneApi() { - this.client = new OkHttpClient.Builder().build(); - } - - public GitHubMilestoneApi(String gitHubToken) { - this.client = new OkHttpClient.Builder() - .addInterceptor(new AuthorizationInterceptor(gitHubToken)) - .build(); - } - - public void setBaseUrl(String baseUrl) { - this.baseUrl = baseUrl; - } - - public long findMilestoneNumberByTitle(RepositoryRef repositoryRef, String milestoneTitle) { - String url = this.baseUrl + "/repos/" + repositoryRef.getOwner() + "/" + repositoryRef.getName() + "/milestones?per_page=100"; - Request request = new Request.Builder().get().url(url) - .build(); - try { - Response response = this.client.newCall(request).execute(); - if (!response.isSuccessful()) { - throw new RuntimeException("Could not find milestone with title " + milestoneTitle + " for repository " + repositoryRef + ". Response " + response); - } - List milestones = this.gson.fromJson(response.body().charStream(), new TypeToken>(){}.getType()); - for (Milestone milestone : milestones) { - if (milestoneTitle.equals(milestone.getTitle())) { - return milestone.getNumber(); - } - } - if (milestones.size() <= 100) { - throw new RuntimeException("Could not find open milestone with title " + milestoneTitle + " for repository " + repositoryRef + " Got " + milestones); - } - throw new RuntimeException("It is possible there are too many open milestones open (only 100 are supported). Could not find open milestone with title " + milestoneTitle + " for repository " + repositoryRef + " Got " + milestones); - } catch (IOException e) { - throw new RuntimeException("Could not find open milestone with title " + milestoneTitle + " for repository " + repositoryRef, e); - } - } - - public boolean isOpenIssuesForMilestoneNumber(RepositoryRef repositoryRef, long milestoneNumber) { - String url = this.baseUrl + "/repos/" + repositoryRef.getOwner() + "/" + repositoryRef.getName() + "/issues?per_page=1&milestone=" + milestoneNumber; - Request request = new Request.Builder().get().url(url) - .build(); - try { - Response response = this.client.newCall(request).execute(); - if (!response.isSuccessful()) { - throw new RuntimeException("Could not find issues for milestone number " + milestoneNumber + " for repository " + repositoryRef + ". Response " + response); - } - List issues = this.gson.fromJson(response.body().charStream(), new TypeToken>(){}.getType()); - return !issues.isEmpty(); - } catch (IOException e) { - throw new RuntimeException("Could not find issues for milestone number " + milestoneNumber + " for repository " + repositoryRef, e); - } - } - -// public boolean isOpenIssuesForMilestoneName(String owner, String repository, String milestoneName) { -// -// } - - - private static class AuthorizationInterceptor implements Interceptor { - - private final String token; - - public AuthorizationInterceptor(String token) { - this.token = token; - } - - @Override - public okhttp3.Response intercept(Chain chain) throws IOException { - Request request = chain.request().newBuilder() - .addHeader("Authorization", "Bearer " + this.token).build(); - return chain.proceed(request); - } - } -} diff --git a/buildSrc/src/main/java/org/springframework/gradle/github/milestones/GitHubMilestoneHasNoOpenIssuesTask.java b/buildSrc/src/main/java/org/springframework/gradle/github/milestones/GitHubMilestoneHasNoOpenIssuesTask.java deleted file mode 100644 index bfee59755..000000000 --- a/buildSrc/src/main/java/org/springframework/gradle/github/milestones/GitHubMilestoneHasNoOpenIssuesTask.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2006-present the original author or 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.springframework.gradle.github.milestones; - -import org.gradle.api.Action; -import org.gradle.api.DefaultTask; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.Optional; -import org.gradle.api.tasks.TaskAction; - -import org.springframework.gradle.github.RepositoryRef; - -public class GitHubMilestoneHasNoOpenIssuesTask extends DefaultTask { - @Input - private RepositoryRef repository = new RepositoryRef(); - - @Input - private String milestoneTitle; - - @Input @Optional - private String gitHubAccessToken; - - private GitHubMilestoneApi milestones = new GitHubMilestoneApi(); - - @TaskAction - public void checkHasNoOpenIssues() { - long milestoneNumber = this.milestones.findMilestoneNumberByTitle(this.repository, this.milestoneTitle); - boolean isOpenIssues = this.milestones.isOpenIssuesForMilestoneNumber(this.repository, milestoneNumber); - if (isOpenIssues) { - throw new IllegalStateException("The repository " + this.repository + " has open issues for milestone with the title " + this.milestoneTitle + " and number " + milestoneNumber); - } - System.out.println("The repository " + this.repository + " has no open issues for milestone with the title " + this.milestoneTitle + " and number " + milestoneNumber); - } - - public RepositoryRef getRepository() { - return repository; - } - - public void repository(Action repository) { - repository.execute(this.repository); - } - - public void setRepository(RepositoryRef repository) { - this.repository = repository; - } - - public String getMilestoneTitle() { - return milestoneTitle; - } - - public void setMilestoneTitle(String milestoneTitle) { - this.milestoneTitle = milestoneTitle; - } - - public String getGitHubAccessToken() { - return gitHubAccessToken; - } - - public void setGitHubAccessToken(String gitHubAccessToken) { - this.gitHubAccessToken = gitHubAccessToken; - this.milestones = new GitHubMilestoneApi(gitHubAccessToken); - } -} diff --git a/buildSrc/src/main/java/org/springframework/gradle/github/milestones/GitHubMilestonePlugin.java b/buildSrc/src/main/java/org/springframework/gradle/github/milestones/GitHubMilestonePlugin.java deleted file mode 100644 index 45cc06fb3..000000000 --- a/buildSrc/src/main/java/org/springframework/gradle/github/milestones/GitHubMilestonePlugin.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2006-present the original author or 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.springframework.gradle.github.milestones; - -import org.gradle.api.Action; -import org.gradle.api.Plugin; -import org.gradle.api.Project; - -public class GitHubMilestonePlugin implements Plugin { - @Override - public void apply(Project project) { - project.getTasks().register("gitHubCheckMilestoneHasNoOpenIssues", GitHubMilestoneHasNoOpenIssuesTask.class, new Action<>() { - @Override - public void execute(GitHubMilestoneHasNoOpenIssuesTask githubCheckMilestoneHasNoOpenIssues) { - githubCheckMilestoneHasNoOpenIssues.setGroup("Release"); - githubCheckMilestoneHasNoOpenIssues.setDescription("Checks if there are any open issues for the specified repository and milestone"); - githubCheckMilestoneHasNoOpenIssues.setMilestoneTitle((String) project.findProperty("nextVersion")); - if (project.hasProperty("gitHubAccessToken")) { - githubCheckMilestoneHasNoOpenIssues.setGitHubAccessToken((String) project.findProperty("gitHubAccessToken")); - } - } - }); - } -} diff --git a/buildSrc/src/main/java/org/springframework/gradle/github/milestones/Milestone.java b/buildSrc/src/main/java/org/springframework/gradle/github/milestones/Milestone.java deleted file mode 100644 index 5d0ff2348..000000000 --- a/buildSrc/src/main/java/org/springframework/gradle/github/milestones/Milestone.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.springframework.gradle.github.milestones; - -public class Milestone { - private String title; - - private long number; - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public long getNumber() { - return number; - } - - public void setNumber(long number) { - this.number = number; - } - - @Override - public String toString() { - return "Milestone{" + - "title='" + title + '\'' + - ", number=" + number + - '}'; - } -} diff --git a/buildSrc/src/main/java/org/springframework/gradle/github/release/CreateGitHubReleaseTask.java b/buildSrc/src/main/java/org/springframework/gradle/github/release/CreateGitHubReleaseTask.java deleted file mode 100644 index 6598e2985..000000000 --- a/buildSrc/src/main/java/org/springframework/gradle/github/release/CreateGitHubReleaseTask.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2006-present the original author or 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.springframework.gradle.github.release; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; - -import org.gradle.api.Action; -import org.gradle.api.DefaultTask; -import org.gradle.api.Project; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.Optional; -import org.gradle.api.tasks.TaskAction; - -import org.springframework.gradle.github.RepositoryRef; -import org.springframework.gradle.github.changelog.GitHubChangelogPlugin; - -/** - * @author Steve Riesenberg - */ -public class CreateGitHubReleaseTask extends DefaultTask { - @Input - private RepositoryRef repository = new RepositoryRef(); - - @Input @Optional - private String gitHubAccessToken; - - @Input - private String version; - - @Input @Optional - private String branch = "main"; - - @Input - private boolean createRelease = false; - - @TaskAction - public void createGitHubRelease() { - String body = readReleaseNotes(); - Release release = Release.tag(this.version) - .commit(this.branch) - .name(this.version) - .body(body) - .preRelease(this.version.contains("-")) - .build(); - - System.out.printf("%sCreating GitHub release for %s/%s@%s\n", - this.createRelease ? "" : "[DRY RUN] ", - this.repository.getOwner(), - this.repository.getName(), - this.version - ); - System.out.printf(" Release Notes:\n\n----\n%s\n----\n\n", body.trim()); - - if (this.createRelease) { - GitHubReleaseApi github = new GitHubReleaseApi(this.gitHubAccessToken); - github.publishRelease(this.repository, release); - } - } - - private String readReleaseNotes() { - Project project = getProject(); - File inputFile = project.file(Paths.get(project.getBuildDir().getPath(), GitHubChangelogPlugin.RELEASE_NOTES_PATH)); - try { - return Files.readString(inputFile.toPath()); - } catch (IOException ex) { - throw new RuntimeException("Unable to read release notes from " + inputFile, ex); - } - } - - public RepositoryRef getRepository() { - return repository; - } - - public void repository(Action repository) { - repository.execute(this.repository); - } - - public void setRepository(RepositoryRef repository) { - this.repository = repository; - } - - public String getGitHubAccessToken() { - return gitHubAccessToken; - } - - public void setGitHubAccessToken(String gitHubAccessToken) { - this.gitHubAccessToken = gitHubAccessToken; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getBranch() { - return branch; - } - - public void setBranch(String branch) { - this.branch = branch; - } - - public boolean isCreateRelease() { - return createRelease; - } - - public void setCreateRelease(boolean createRelease) { - this.createRelease = createRelease; - } -} diff --git a/buildSrc/src/main/java/org/springframework/gradle/github/release/GitHubReleaseApi.java b/buildSrc/src/main/java/org/springframework/gradle/github/release/GitHubReleaseApi.java deleted file mode 100644 index 6cc8e78eb..000000000 --- a/buildSrc/src/main/java/org/springframework/gradle/github/release/GitHubReleaseApi.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2006-present the original author or 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.springframework.gradle.github.release; - -import java.io.IOException; - -import com.google.gson.Gson; -import okhttp3.Interceptor; -import okhttp3.MediaType; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; - -import org.springframework.gradle.github.RepositoryRef; - -/** - * Manage GitHub releases. - * - * @author Steve Riesenberg - */ -public class GitHubReleaseApi { - private String baseUrl = "https://api.github.com"; - - private final OkHttpClient httpClient; - private Gson gson = new Gson(); - - public GitHubReleaseApi(String gitHubAccessToken) { - this.httpClient = new OkHttpClient.Builder() - .addInterceptor(new AuthorizationInterceptor(gitHubAccessToken)) - .build(); - } - - public void setBaseUrl(String baseUrl) { - this.baseUrl = baseUrl; - } - - /** - * Publish a release with no binary attachments. - * - * @param repository The repository owner/name - * @param release The contents of the release - */ - public void publishRelease(RepositoryRef repository, Release release) { - String url = this.baseUrl + "/repos/" + repository.getOwner() + "/" + repository.getName() + "/releases"; - String json = this.gson.toJson(release); - RequestBody body = RequestBody.create(MediaType.parse("application/json"), json); - Request request = new Request.Builder().url(url).post(body).build(); - try { - Response response = this.httpClient.newCall(request).execute(); - if (!response.isSuccessful()) { - throw new RuntimeException(String.format("Could not create release %s for repository %s/%s. Got response %s", - release.getName(), repository.getOwner(), repository.getName(), response)); - } - } catch (IOException ex) { - throw new RuntimeException(String.format("Could not create release %s for repository %s/%s", - release.getName(), repository.getOwner(), repository.getName()), ex); - } - } - - private static class AuthorizationInterceptor implements Interceptor { - private final String token; - - public AuthorizationInterceptor(String token) { - this.token = token; - } - - @Override - public Response intercept(Chain chain) throws IOException { - Request request = chain.request().newBuilder() - .addHeader("Authorization", "Bearer " + this.token) - .build(); - - return chain.proceed(request); - } - } -} diff --git a/buildSrc/src/main/java/org/springframework/gradle/github/release/GitHubReleasePlugin.java b/buildSrc/src/main/java/org/springframework/gradle/github/release/GitHubReleasePlugin.java deleted file mode 100644 index 6182ff9b0..000000000 --- a/buildSrc/src/main/java/org/springframework/gradle/github/release/GitHubReleasePlugin.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2006-present the original author or 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.springframework.gradle.github.release; - -import groovy.lang.MissingPropertyException; -import org.gradle.api.Action; -import org.gradle.api.Plugin; -import org.gradle.api.Project; - -/** - * @author Steve Riesenberg - */ -public class GitHubReleasePlugin implements Plugin { - @Override - public void apply(Project project) { - project.getTasks().register("createGitHubRelease", CreateGitHubReleaseTask.class, new Action<>() { - @Override - public void execute(CreateGitHubReleaseTask createGitHubRelease) { - createGitHubRelease.setGroup("Release"); - createGitHubRelease.setDescription("Create a github release"); - createGitHubRelease.dependsOn("generateChangelog"); - - createGitHubRelease.setCreateRelease("true".equals(project.findProperty("createRelease"))); - createGitHubRelease.setVersion((String) project.findProperty("nextVersion")); - if (project.hasProperty("branch")) { - createGitHubRelease.setBranch((String) project.findProperty("branch")); - } - createGitHubRelease.setGitHubAccessToken((String) project.findProperty("gitHubAccessToken")); - if (createGitHubRelease.isCreateRelease() && createGitHubRelease.getGitHubAccessToken() == null) { - throw new MissingPropertyException("Please provide an access token with -PgitHubAccessToken=..."); - } - } - }); - } -} diff --git a/buildSrc/src/main/java/org/springframework/gradle/github/release/Release.java b/buildSrc/src/main/java/org/springframework/gradle/github/release/Release.java deleted file mode 100644 index 74d7a45e8..000000000 --- a/buildSrc/src/main/java/org/springframework/gradle/github/release/Release.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2006-present the original author or 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.springframework.gradle.github.release; - -import com.google.gson.annotations.SerializedName; - -/** - * @author Steve Riesenberg - */ -public class Release { - @SerializedName("tag_name") - private final String tag; - - @SerializedName("target_commitish") - private final String commit; - - @SerializedName("name") - private final String name; - - @SerializedName("body") - private final String body; - - @SerializedName("draft") - private final boolean draft; - - @SerializedName("prerelease") - private final boolean preRelease; - - @SerializedName("generate_release_notes") - private final boolean generateReleaseNotes; - - private Release(String tag, String commit, String name, String body, boolean draft, boolean preRelease, boolean generateReleaseNotes) { - this.tag = tag; - this.commit = commit; - this.name = name; - this.body = body; - this.draft = draft; - this.preRelease = preRelease; - this.generateReleaseNotes = generateReleaseNotes; - } - - public String getTag() { - return tag; - } - - public String getCommit() { - return commit; - } - - public String getName() { - return name; - } - - public String getBody() { - return body; - } - - public boolean isDraft() { - return draft; - } - - public boolean isPreRelease() { - return preRelease; - } - - public boolean isGenerateReleaseNotes() { - return generateReleaseNotes; - } - - @Override - public String toString() { - return "Release{" + - "tag='" + tag + '\'' + - ", commit='" + commit + '\'' + - ", name='" + name + '\'' + - ", body='" + body + '\'' + - ", draft=" + draft + - ", preRelease=" + preRelease + - ", generateReleaseNotes=" + generateReleaseNotes + - '}'; - } - - public static Builder tag(String tag) { - return new Builder().tag(tag); - } - - public static Builder commit(String commit) { - return new Builder().commit(commit); - } - - public static final class Builder { - private String tag; - private String commit; - private String name; - private String body; - private boolean draft; - private boolean preRelease; - private boolean generateReleaseNotes; - - private Builder() { - } - - public Builder tag(String tag) { - this.tag = tag; - return this; - } - - public Builder commit(String commit) { - this.commit = commit; - return this; - } - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder body(String body) { - this.body = body; - return this; - } - - public Builder draft(boolean draft) { - this.draft = draft; - return this; - } - - public Builder preRelease(boolean preRelease) { - this.preRelease = preRelease; - return this; - } - - public Builder generateReleaseNotes(boolean generateReleaseNotes) { - this.generateReleaseNotes = generateReleaseNotes; - return this; - } - - public Release build() { - return new Release(tag, commit, name, body, draft, preRelease, generateReleaseNotes); - } - } -} diff --git a/buildSrc/src/main/java/org/springframework/gradle/maven/PublishArtifactsPlugin.java b/buildSrc/src/main/java/org/springframework/gradle/maven/PublishArtifactsPlugin.java deleted file mode 100644 index 0bf363dd0..000000000 --- a/buildSrc/src/main/java/org/springframework/gradle/maven/PublishArtifactsPlugin.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.springframework.gradle.maven; - -import io.spring.gradle.convention.Utils; -import org.gradle.api.Action; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.Task; - -public class PublishArtifactsPlugin implements Plugin { - @Override - public void apply(Project project) { - project.getTasks().register("publishArtifacts", new Action<>() { - @Override - public void execute(Task publishArtifacts) { - publishArtifacts.setGroup("Publishing"); - publishArtifacts.setDescription("Publish the artifacts to either Artifactory or Maven Central based on the version"); - if (Utils.isRelease(project)) { - publishArtifacts.dependsOn("publishToOssrh"); - } - else { - publishArtifacts.dependsOn("artifactoryPublish"); - } - } - }); - } -} diff --git a/buildSrc/src/main/java/org/springframework/gradle/maven/SpringMavenPlugin.java b/buildSrc/src/main/java/org/springframework/gradle/maven/SpringMavenPlugin.java index 8b0621299..de47492ad 100644 --- a/buildSrc/src/main/java/org/springframework/gradle/maven/SpringMavenPlugin.java +++ b/buildSrc/src/main/java/org/springframework/gradle/maven/SpringMavenPlugin.java @@ -1,6 +1,5 @@ package org.springframework.gradle.maven; -import io.spring.gradle.convention.ArtifactoryPlugin; import org.gradle.api.Plugin; import org.gradle.api.Project; import org.gradle.api.plugins.PluginManager; @@ -15,7 +14,5 @@ public void apply(Project project) { pluginManager.apply(MavenPublishingConventionsPlugin.class); pluginManager.apply(PublishAllJavaComponentsPlugin.class); pluginManager.apply(PublishLocalPlugin.class); - pluginManager.apply(PublishArtifactsPlugin.class); - pluginManager.apply(ArtifactoryPlugin.class); } } diff --git a/buildSrc/src/main/java/org/springframework/gradle/maven/SpringNexusPublishPlugin.java b/buildSrc/src/main/java/org/springframework/gradle/maven/SpringNexusPublishPlugin.java deleted file mode 100644 index c94a8164e..000000000 --- a/buildSrc/src/main/java/org/springframework/gradle/maven/SpringNexusPublishPlugin.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.springframework.gradle.maven; - -import java.net.URI; -import java.time.Duration; - -import io.github.gradlenexus.publishplugin.NexusPublishExtension; -import io.github.gradlenexus.publishplugin.NexusPublishPlugin; -import io.github.gradlenexus.publishplugin.NexusRepository; -import org.gradle.api.Action; -import org.gradle.api.Plugin; -import org.gradle.api.Project; - -public class SpringNexusPublishPlugin implements Plugin { - @Override - public void apply(Project project) { - project.getPlugins().apply(NexusPublishPlugin.class); - NexusPublishExtension nexusPublishing = project.getExtensions().findByType(NexusPublishExtension.class); - nexusPublishing.getRepositories().create("ossrh", new Action<>() { - @Override - public void execute(NexusRepository nexusRepository) { - nexusRepository.getNexusUrl().set(URI.create("https://s01.oss.sonatype.org/service/local/")); - nexusRepository.getSnapshotRepositoryUrl().set(URI.create("https://s01.oss.sonatype.org/content/repositories/snapshots/")); - } - }); - nexusPublishing.getConnectTimeout().set(Duration.ofMinutes(3)); - nexusPublishing.getClientTimeout().set(Duration.ofMinutes(3)); - } -} diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.artifactory.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.artifactory.properties deleted file mode 100644 index 573d12813..000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.artifactory.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=io.spring.gradle.convention.ArtifactoryPlugin \ No newline at end of file diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.bom.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.bom.properties deleted file mode 100644 index dec2e7a80..000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.bom.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=io.spring.gradle.convention.MavenBomPlugin \ No newline at end of file diff --git a/buildSrc/src/test/java/io/spring/gradle/github/milestones/GitHubMilestoneApiTests.java b/buildSrc/src/test/java/io/spring/gradle/github/milestones/GitHubMilestoneApiTests.java deleted file mode 100644 index b234b3519..000000000 --- a/buildSrc/src/test/java/io/spring/gradle/github/milestones/GitHubMilestoneApiTests.java +++ /dev/null @@ -1,389 +0,0 @@ -package io.spring.gradle.github.milestones; - -import java.util.concurrent.TimeUnit; - -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.gradle.github.RepositoryRef; -import org.springframework.gradle.github.milestones.GitHubMilestoneApi; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - - -public class GitHubMilestoneApiTests { - private GitHubMilestoneApi github; - - private RepositoryRef repositoryRef = RepositoryRef.owner("spring-projects").repository("spring-security").build(); - - private MockWebServer server; - - private String baseUrl; - - @BeforeEach - public void setup() throws Exception { - this.server = new MockWebServer(); - this.server.start(); - this.github = new GitHubMilestoneApi("mock-oauth-token"); - this.baseUrl = this.server.url("/api").toString(); - this.github.setBaseUrl(this.baseUrl); - } - - @AfterEach - public void cleanup() throws Exception { - this.server.shutdown(); - } - - @Test - public void findMilestoneNumberByTitleWhenFoundThenSuccess() throws Exception { - String responseJson = "[\n" + - " {\n" + - " \"url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/207\",\n" + - " \"html_url\":\"https://github.com/spring-projects/spring-security/milestone/207\",\n" + - " \"labels_url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/207/labels\",\n" + - " \"id\":6611880,\n" + - " \"node_id\":\"MDk6TWlsZXN0b25lNjYxMTg4MA==\",\n" + - " \"number\":207,\n" + - " \"title\":\"5.6.x\",\n" + - " \"description\":\"\",\n" + - " \"creator\":{\n" + - " \"login\":\"jgrandja\",\n" + - " \"id\":10884212,\n" + - " \"node_id\":\"MDQ6VXNlcjEwODg0MjEy\",\n" + - " \"avatar_url\":\"https://avatars.githubusercontent.com/u/10884212?v=4\",\n" + - " \"gravatar_id\":\"\",\n" + - " \"url\":\"https://api.github.com/users/jgrandja\",\n" + - " \"html_url\":\"https://github.com/jgrandja\",\n" + - " \"followers_url\":\"https://api.github.com/users/jgrandja/followers\",\n" + - " \"following_url\":\"https://api.github.com/users/jgrandja/following{/other_user}\",\n" + - " \"gists_url\":\"https://api.github.com/users/jgrandja/gists{/gist_id}\",\n" + - " \"starred_url\":\"https://api.github.com/users/jgrandja/starred{/owner}{/repo}\",\n" + - " \"subscriptions_url\":\"https://api.github.com/users/jgrandja/subscriptions\",\n" + - " \"organizations_url\":\"https://api.github.com/users/jgrandja/orgs\",\n" + - " \"repos_url\":\"https://api.github.com/users/jgrandja/repos\",\n" + - " \"events_url\":\"https://api.github.com/users/jgrandja/events{/privacy}\",\n" + - " \"received_events_url\":\"https://api.github.com/users/jgrandja/received_events\",\n" + - " \"type\":\"User\",\n" + - " \"site_admin\":false\n" + - " },\n" + - " \"open_issues\":1,\n" + - " \"closed_issues\":0,\n" + - " \"state\":\"open\",\n" + - " \"created_at\":\"2021-03-31T11:29:17Z\",\n" + - " \"updated_at\":\"2021-03-31T11:30:47Z\",\n" + - " \"due_on\":null,\n" + - " \"closed_at\":null\n" + - " },\n" + - " {\n" + - " \"url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/191\",\n" + - " \"html_url\":\"https://github.com/spring-projects/spring-security/milestone/191\",\n" + - " \"labels_url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/191/labels\",\n" + - " \"id\":5884208,\n" + - " \"node_id\":\"MDk6TWlsZXN0b25lNTg4NDIwOA==\",\n" + - " \"number\":191,\n" + - " \"title\":\"5.5.0-RC1\",\n" + - " \"description\":\"\",\n" + - " \"creator\":{\n" + - " \"login\":\"jzheaux\",\n" + - " \"id\":3627351,\n" + - " \"node_id\":\"MDQ6VXNlcjM2MjczNTE=\",\n" + - " \"avatar_url\":\"https://avatars.githubusercontent.com/u/3627351?v=4\",\n" + - " \"gravatar_id\":\"\",\n" + - " \"url\":\"https://api.github.com/users/jzheaux\",\n" + - " \"html_url\":\"https://github.com/jzheaux\",\n" + - " \"followers_url\":\"https://api.github.com/users/jzheaux/followers\",\n" + - " \"following_url\":\"https://api.github.com/users/jzheaux/following{/other_user}\",\n" + - " \"gists_url\":\"https://api.github.com/users/jzheaux/gists{/gist_id}\",\n" + - " \"starred_url\":\"https://api.github.com/users/jzheaux/starred{/owner}{/repo}\",\n" + - " \"subscriptions_url\":\"https://api.github.com/users/jzheaux/subscriptions\",\n" + - " \"organizations_url\":\"https://api.github.com/users/jzheaux/orgs\",\n" + - " \"repos_url\":\"https://api.github.com/users/jzheaux/repos\",\n" + - " \"events_url\":\"https://api.github.com/users/jzheaux/events{/privacy}\",\n" + - " \"received_events_url\":\"https://api.github.com/users/jzheaux/received_events\",\n" + - " \"type\":\"User\",\n" + - " \"site_admin\":false\n" + - " },\n" + - " \"open_issues\":21,\n" + - " \"closed_issues\":23,\n" + - " \"state\":\"open\",\n" + - " \"created_at\":\"2020-09-16T13:28:03Z\",\n" + - " \"updated_at\":\"2021-04-06T23:47:10Z\",\n" + - " \"due_on\":\"2021-04-12T07:00:00Z\",\n" + - " \"closed_at\":null\n" + - " }\n" + - "]"; - this.server.enqueue(new MockResponse().setBody(responseJson)); - - long milestoneNumberByTitle = this.github.findMilestoneNumberByTitle(this.repositoryRef, "5.5.0-RC1"); - - RecordedRequest recordedRequest = this.server.takeRequest(1, TimeUnit.SECONDS); - assertThat(recordedRequest.getMethod()).isEqualToIgnoringCase("get"); - assertThat(recordedRequest.getRequestUrl().toString()).isEqualTo(this.baseUrl + "/repos/spring-projects/spring-security/milestones?per_page=100"); - - assertThat(milestoneNumberByTitle).isEqualTo(191); - } - - @Test - public void findMilestoneNumberByTitleWhenNotFoundThenException() throws Exception { - String responseJson = "[\n" + - " {\n" + - " \"url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/207\",\n" + - " \"html_url\":\"https://github.com/spring-projects/spring-security/milestone/207\",\n" + - " \"labels_url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/207/labels\",\n" + - " \"id\":6611880,\n" + - " \"node_id\":\"MDk6TWlsZXN0b25lNjYxMTg4MA==\",\n" + - " \"number\":207,\n" + - " \"title\":\"5.6.x\",\n" + - " \"description\":\"\",\n" + - " \"creator\":{\n" + - " \"login\":\"jgrandja\",\n" + - " \"id\":10884212,\n" + - " \"node_id\":\"MDQ6VXNlcjEwODg0MjEy\",\n" + - " \"avatar_url\":\"https://avatars.githubusercontent.com/u/10884212?v=4\",\n" + - " \"gravatar_id\":\"\",\n" + - " \"url\":\"https://api.github.com/users/jgrandja\",\n" + - " \"html_url\":\"https://github.com/jgrandja\",\n" + - " \"followers_url\":\"https://api.github.com/users/jgrandja/followers\",\n" + - " \"following_url\":\"https://api.github.com/users/jgrandja/following{/other_user}\",\n" + - " \"gists_url\":\"https://api.github.com/users/jgrandja/gists{/gist_id}\",\n" + - " \"starred_url\":\"https://api.github.com/users/jgrandja/starred{/owner}{/repo}\",\n" + - " \"subscriptions_url\":\"https://api.github.com/users/jgrandja/subscriptions\",\n" + - " \"organizations_url\":\"https://api.github.com/users/jgrandja/orgs\",\n" + - " \"repos_url\":\"https://api.github.com/users/jgrandja/repos\",\n" + - " \"events_url\":\"https://api.github.com/users/jgrandja/events{/privacy}\",\n" + - " \"received_events_url\":\"https://api.github.com/users/jgrandja/received_events\",\n" + - " \"type\":\"User\",\n" + - " \"site_admin\":false\n" + - " },\n" + - " \"open_issues\":1,\n" + - " \"closed_issues\":0,\n" + - " \"state\":\"open\",\n" + - " \"created_at\":\"2021-03-31T11:29:17Z\",\n" + - " \"updated_at\":\"2021-03-31T11:30:47Z\",\n" + - " \"due_on\":null,\n" + - " \"closed_at\":null\n" + - " },\n" + - " {\n" + - " \"url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/191\",\n" + - " \"html_url\":\"https://github.com/spring-projects/spring-security/milestone/191\",\n" + - " \"labels_url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/191/labels\",\n" + - " \"id\":5884208,\n" + - " \"node_id\":\"MDk6TWlsZXN0b25lNTg4NDIwOA==\",\n" + - " \"number\":191,\n" + - " \"title\":\"5.5.0-RC1\",\n" + - " \"description\":\"\",\n" + - " \"creator\":{\n" + - " \"login\":\"jzheaux\",\n" + - " \"id\":3627351,\n" + - " \"node_id\":\"MDQ6VXNlcjM2MjczNTE=\",\n" + - " \"avatar_url\":\"https://avatars.githubusercontent.com/u/3627351?v=4\",\n" + - " \"gravatar_id\":\"\",\n" + - " \"url\":\"https://api.github.com/users/jzheaux\",\n" + - " \"html_url\":\"https://github.com/jzheaux\",\n" + - " \"followers_url\":\"https://api.github.com/users/jzheaux/followers\",\n" + - " \"following_url\":\"https://api.github.com/users/jzheaux/following{/other_user}\",\n" + - " \"gists_url\":\"https://api.github.com/users/jzheaux/gists{/gist_id}\",\n" + - " \"starred_url\":\"https://api.github.com/users/jzheaux/starred{/owner}{/repo}\",\n" + - " \"subscriptions_url\":\"https://api.github.com/users/jzheaux/subscriptions\",\n" + - " \"organizations_url\":\"https://api.github.com/users/jzheaux/orgs\",\n" + - " \"repos_url\":\"https://api.github.com/users/jzheaux/repos\",\n" + - " \"events_url\":\"https://api.github.com/users/jzheaux/events{/privacy}\",\n" + - " \"received_events_url\":\"https://api.github.com/users/jzheaux/received_events\",\n" + - " \"type\":\"User\",\n" + - " \"site_admin\":false\n" + - " },\n" + - " \"open_issues\":21,\n" + - " \"closed_issues\":23,\n" + - " \"state\":\"open\",\n" + - " \"created_at\":\"2020-09-16T13:28:03Z\",\n" + - " \"updated_at\":\"2021-04-06T23:47:10Z\",\n" + - " \"due_on\":\"2021-04-12T07:00:00Z\",\n" + - " \"closed_at\":null\n" + - " }\n" + - "]"; - this.server.enqueue(new MockResponse().setBody(responseJson)); - - assertThatExceptionOfType(RuntimeException.class) - .isThrownBy(() -> this.github.findMilestoneNumberByTitle(this.repositoryRef, "missing")); - } - - @Test - public void isOpenIssuesForMilestoneNumberWhenAllClosedThenFalse() throws Exception { - String responseJson = "[]"; - long milestoneNumber = 202; - this.server.enqueue(new MockResponse().setBody(responseJson)); - - assertThat(this.github.isOpenIssuesForMilestoneNumber(this.repositoryRef, milestoneNumber)).isFalse(); - - RecordedRequest recordedRequest = this.server.takeRequest(1, TimeUnit.SECONDS); - assertThat(recordedRequest.getMethod()).isEqualToIgnoringCase("get"); - assertThat(recordedRequest.getRequestUrl().toString()).isEqualTo(this.baseUrl + "/repos/spring-projects/spring-security/issues?per_page=1&milestone=" + milestoneNumber); - } - - @Test - public void isOpenIssuesForMilestoneNumberWhenOpenIssuesThenTrue() throws Exception { - String responseJson = "[\n" + - " {\n" + - " \"url\":\"https://api.github.com/repos/spring-projects/spring-security/issues/9562\",\n" + - " \"repository_url\":\"https://api.github.com/repos/spring-projects/spring-security\",\n" + - " \"labels_url\":\"https://api.github.com/repos/spring-projects/spring-security/issues/9562/labels{/name}\",\n" + - " \"comments_url\":\"https://api.github.com/repos/spring-projects/spring-security/issues/9562/comments\",\n" + - " \"events_url\":\"https://api.github.com/repos/spring-projects/spring-security/issues/9562/events\",\n" + - " \"html_url\":\"https://github.com/spring-projects/spring-security/pull/9562\",\n" + - " \"id\":851886504,\n" + - " \"node_id\":\"MDExOlB1bGxSZXF1ZXN0NjEwMjMzMDcw\",\n" + - " \"number\":9562,\n" + - " \"title\":\"Add package-list\",\n" + - " \"user\":{\n" + - " \"login\":\"jzheaux\",\n" + - " \"id\":3627351,\n" + - " \"node_id\":\"MDQ6VXNlcjM2MjczNTE=\",\n" + - " \"avatar_url\":\"https://avatars.githubusercontent.com/u/3627351?v=4\",\n" + - " \"gravatar_id\":\"\",\n" + - " \"url\":\"https://api.github.com/users/jzheaux\",\n" + - " \"html_url\":\"https://github.com/jzheaux\",\n" + - " \"followers_url\":\"https://api.github.com/users/jzheaux/followers\",\n" + - " \"following_url\":\"https://api.github.com/users/jzheaux/following{/other_user}\",\n" + - " \"gists_url\":\"https://api.github.com/users/jzheaux/gists{/gist_id}\",\n" + - " \"starred_url\":\"https://api.github.com/users/jzheaux/starred{/owner}{/repo}\",\n" + - " \"subscriptions_url\":\"https://api.github.com/users/jzheaux/subscriptions\",\n" + - " \"organizations_url\":\"https://api.github.com/users/jzheaux/orgs\",\n" + - " \"repos_url\":\"https://api.github.com/users/jzheaux/repos\",\n" + - " \"events_url\":\"https://api.github.com/users/jzheaux/events{/privacy}\",\n" + - " \"received_events_url\":\"https://api.github.com/users/jzheaux/received_events\",\n" + - " \"type\":\"User\",\n" + - " \"site_admin\":false\n" + - " },\n" + - " \"labels\":[\n" + - " {\n" + - " \"id\":322225043,\n" + - " \"node_id\":\"MDU6TGFiZWwzMjIyMjUwNDM=\",\n" + - " \"url\":\"https://api.github.com/repos/spring-projects/spring-security/labels/in:%20build\",\n" + - " \"name\":\"in: build\",\n" + - " \"color\":\"e8f9de\",\n" + - " \"default\":false,\n" + - " \"description\":\"An issue in the build\"\n" + - " },\n" + - " {\n" + - " \"id\":322225079,\n" + - " \"node_id\":\"MDU6TGFiZWwzMjIyMjUwNzk=\",\n" + - " \"url\":\"https://api.github.com/repos/spring-projects/spring-security/labels/type:%20bug\",\n" + - " \"name\":\"type: bug\",\n" + - " \"color\":\"e3d9fc\",\n" + - " \"default\":false,\n" + - " \"description\":\"A general bug\"\n" + - " }\n" + - " ],\n" + - " \"state\":\"open\",\n" + - " \"locked\":false,\n" + - " \"assignee\":{\n" + - " \"login\":\"rwinch\",\n" + - " \"id\":362503,\n" + - " \"node_id\":\"MDQ6VXNlcjM2MjUwMw==\",\n" + - " \"avatar_url\":\"https://avatars.githubusercontent.com/u/362503?v=4\",\n" + - " \"gravatar_id\":\"\",\n" + - " \"url\":\"https://api.github.com/users/rwinch\",\n" + - " \"html_url\":\"https://github.com/rwinch\",\n" + - " \"followers_url\":\"https://api.github.com/users/rwinch/followers\",\n" + - " \"following_url\":\"https://api.github.com/users/rwinch/following{/other_user}\",\n" + - " \"gists_url\":\"https://api.github.com/users/rwinch/gists{/gist_id}\",\n" + - " \"starred_url\":\"https://api.github.com/users/rwinch/starred{/owner}{/repo}\",\n" + - " \"subscriptions_url\":\"https://api.github.com/users/rwinch/subscriptions\",\n" + - " \"organizations_url\":\"https://api.github.com/users/rwinch/orgs\",\n" + - " \"repos_url\":\"https://api.github.com/users/rwinch/repos\",\n" + - " \"events_url\":\"https://api.github.com/users/rwinch/events{/privacy}\",\n" + - " \"received_events_url\":\"https://api.github.com/users/rwinch/received_events\",\n" + - " \"type\":\"User\",\n" + - " \"site_admin\":false\n" + - " },\n" + - " \"assignees\":[\n" + - " {\n" + - " \"login\":\"rwinch\",\n" + - " \"id\":362503,\n" + - " \"node_id\":\"MDQ6VXNlcjM2MjUwMw==\",\n" + - " \"avatar_url\":\"https://avatars.githubusercontent.com/u/362503?v=4\",\n" + - " \"gravatar_id\":\"\",\n" + - " \"url\":\"https://api.github.com/users/rwinch\",\n" + - " \"html_url\":\"https://github.com/rwinch\",\n" + - " \"followers_url\":\"https://api.github.com/users/rwinch/followers\",\n" + - " \"following_url\":\"https://api.github.com/users/rwinch/following{/other_user}\",\n" + - " \"gists_url\":\"https://api.github.com/users/rwinch/gists{/gist_id}\",\n" + - " \"starred_url\":\"https://api.github.com/users/rwinch/starred{/owner}{/repo}\",\n" + - " \"subscriptions_url\":\"https://api.github.com/users/rwinch/subscriptions\",\n" + - " \"organizations_url\":\"https://api.github.com/users/rwinch/orgs\",\n" + - " \"repos_url\":\"https://api.github.com/users/rwinch/repos\",\n" + - " \"events_url\":\"https://api.github.com/users/rwinch/events{/privacy}\",\n" + - " \"received_events_url\":\"https://api.github.com/users/rwinch/received_events\",\n" + - " \"type\":\"User\",\n" + - " \"site_admin\":false\n" + - " }\n" + - " ],\n" + - " \"milestone\":{\n" + - " \"url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/191\",\n" + - " \"html_url\":\"https://github.com/spring-projects/spring-security/milestone/191\",\n" + - " \"labels_url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/191/labels\",\n" + - " \"id\":5884208,\n" + - " \"node_id\":\"MDk6TWlsZXN0b25lNTg4NDIwOA==\",\n" + - " \"number\":191,\n" + - " \"title\":\"5.5.0-RC1\",\n" + - " \"description\":\"\",\n" + - " \"creator\":{\n" + - " \"login\":\"jzheaux\",\n" + - " \"id\":3627351,\n" + - " \"node_id\":\"MDQ6VXNlcjM2MjczNTE=\",\n" + - " \"avatar_url\":\"https://avatars.githubusercontent.com/u/3627351?v=4\",\n" + - " \"gravatar_id\":\"\",\n" + - " \"url\":\"https://api.github.com/users/jzheaux\",\n" + - " \"html_url\":\"https://github.com/jzheaux\",\n" + - " \"followers_url\":\"https://api.github.com/users/jzheaux/followers\",\n" + - " \"following_url\":\"https://api.github.com/users/jzheaux/following{/other_user}\",\n" + - " \"gists_url\":\"https://api.github.com/users/jzheaux/gists{/gist_id}\",\n" + - " \"starred_url\":\"https://api.github.com/users/jzheaux/starred{/owner}{/repo}\",\n" + - " \"subscriptions_url\":\"https://api.github.com/users/jzheaux/subscriptions\",\n" + - " \"organizations_url\":\"https://api.github.com/users/jzheaux/orgs\",\n" + - " \"repos_url\":\"https://api.github.com/users/jzheaux/repos\",\n" + - " \"events_url\":\"https://api.github.com/users/jzheaux/events{/privacy}\",\n" + - " \"received_events_url\":\"https://api.github.com/users/jzheaux/received_events\",\n" + - " \"type\":\"User\",\n" + - " \"site_admin\":false\n" + - " },\n" + - " \"open_issues\":21,\n" + - " \"closed_issues\":23,\n" + - " \"state\":\"open\",\n" + - " \"created_at\":\"2020-09-16T13:28:03Z\",\n" + - " \"updated_at\":\"2021-04-06T23:47:10Z\",\n" + - " \"due_on\":\"2021-04-12T07:00:00Z\",\n" + - " \"closed_at\":null\n" + - " },\n" + - " \"comments\":0,\n" + - " \"created_at\":\"2021-04-06T23:47:10Z\",\n" + - " \"updated_at\":\"2021-04-07T17:00:00Z\",\n" + - " \"closed_at\":null,\n" + - " \"author_association\":\"MEMBER\",\n" + - " \"active_lock_reason\":null,\n" + - " \"pull_request\":{\n" + - " \"url\":\"https://api.github.com/repos/spring-projects/spring-security/pulls/9562\",\n" + - " \"html_url\":\"https://github.com/spring-projects/spring-security/pull/9562\",\n" + - " \"diff_url\":\"https://github.com/spring-projects/spring-security/pull/9562.diff\",\n" + - " \"patch_url\":\"https://github.com/spring-projects/spring-security/pull/9562.patch\"\n" + - " },\n" + - " \"body\":\"Closes gh-9528\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\",\n" + - " \"performed_via_github_app\":null\n" + - " }\n" + - "]"; - long milestoneNumber = 191; - this.server.enqueue(new MockResponse().setBody(responseJson)); - - assertThat(this.github.isOpenIssuesForMilestoneNumber(this.repositoryRef, milestoneNumber)).isTrue(); - - RecordedRequest recordedRequest = this.server.takeRequest(1, TimeUnit.SECONDS); - assertThat(recordedRequest.getMethod()).isEqualToIgnoringCase("get"); - assertThat(recordedRequest.getRequestUrl().toString()).isEqualTo(this.baseUrl + "/repos/spring-projects/spring-security/issues?per_page=1&milestone=" + milestoneNumber); - } - -} diff --git a/buildSrc/src/test/java/org/springframework/gradle/github/milestones/GitHubMilestoneApiTests.java b/buildSrc/src/test/java/org/springframework/gradle/github/milestones/GitHubMilestoneApiTests.java deleted file mode 100644 index 9f961cbaf..000000000 --- a/buildSrc/src/test/java/org/springframework/gradle/github/milestones/GitHubMilestoneApiTests.java +++ /dev/null @@ -1,388 +0,0 @@ -package org.springframework.gradle.github.milestones; - -import java.util.concurrent.TimeUnit; - -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.gradle.github.RepositoryRef; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - - -public class GitHubMilestoneApiTests { - private GitHubMilestoneApi github; - - private RepositoryRef repositoryRef = RepositoryRef.owner("spring-projects").repository("spring-security").build(); - - private MockWebServer server; - - private String baseUrl; - - @BeforeEach - public void setup() throws Exception { - this.server = new MockWebServer(); - this.server.start(); - this.github = new GitHubMilestoneApi("mock-oauth-token"); - this.baseUrl = this.server.url("/api").toString(); - this.github.setBaseUrl(this.baseUrl); - } - - @AfterEach - public void cleanup() throws Exception { - this.server.shutdown(); - } - - @Test - public void findMilestoneNumberByTitleWhenFoundThenSuccess() throws Exception { - String responseJson = "[\n" + - " {\n" + - " \"url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/207\",\n" + - " \"html_url\":\"https://github.com/spring-projects/spring-security/milestone/207\",\n" + - " \"labels_url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/207/labels\",\n" + - " \"id\":6611880,\n" + - " \"node_id\":\"MDk6TWlsZXN0b25lNjYxMTg4MA==\",\n" + - " \"number\":207,\n" + - " \"title\":\"5.6.x\",\n" + - " \"description\":\"\",\n" + - " \"creator\":{\n" + - " \"login\":\"jgrandja\",\n" + - " \"id\":10884212,\n" + - " \"node_id\":\"MDQ6VXNlcjEwODg0MjEy\",\n" + - " \"avatar_url\":\"https://avatars.githubusercontent.com/u/10884212?v=4\",\n" + - " \"gravatar_id\":\"\",\n" + - " \"url\":\"https://api.github.com/users/jgrandja\",\n" + - " \"html_url\":\"https://github.com/jgrandja\",\n" + - " \"followers_url\":\"https://api.github.com/users/jgrandja/followers\",\n" + - " \"following_url\":\"https://api.github.com/users/jgrandja/following{/other_user}\",\n" + - " \"gists_url\":\"https://api.github.com/users/jgrandja/gists{/gist_id}\",\n" + - " \"starred_url\":\"https://api.github.com/users/jgrandja/starred{/owner}{/repo}\",\n" + - " \"subscriptions_url\":\"https://api.github.com/users/jgrandja/subscriptions\",\n" + - " \"organizations_url\":\"https://api.github.com/users/jgrandja/orgs\",\n" + - " \"repos_url\":\"https://api.github.com/users/jgrandja/repos\",\n" + - " \"events_url\":\"https://api.github.com/users/jgrandja/events{/privacy}\",\n" + - " \"received_events_url\":\"https://api.github.com/users/jgrandja/received_events\",\n" + - " \"type\":\"User\",\n" + - " \"site_admin\":false\n" + - " },\n" + - " \"open_issues\":1,\n" + - " \"closed_issues\":0,\n" + - " \"state\":\"open\",\n" + - " \"created_at\":\"2021-03-31T11:29:17Z\",\n" + - " \"updated_at\":\"2021-03-31T11:30:47Z\",\n" + - " \"due_on\":null,\n" + - " \"closed_at\":null\n" + - " },\n" + - " {\n" + - " \"url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/191\",\n" + - " \"html_url\":\"https://github.com/spring-projects/spring-security/milestone/191\",\n" + - " \"labels_url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/191/labels\",\n" + - " \"id\":5884208,\n" + - " \"node_id\":\"MDk6TWlsZXN0b25lNTg4NDIwOA==\",\n" + - " \"number\":191,\n" + - " \"title\":\"5.5.0-RC1\",\n" + - " \"description\":\"\",\n" + - " \"creator\":{\n" + - " \"login\":\"jzheaux\",\n" + - " \"id\":3627351,\n" + - " \"node_id\":\"MDQ6VXNlcjM2MjczNTE=\",\n" + - " \"avatar_url\":\"https://avatars.githubusercontent.com/u/3627351?v=4\",\n" + - " \"gravatar_id\":\"\",\n" + - " \"url\":\"https://api.github.com/users/jzheaux\",\n" + - " \"html_url\":\"https://github.com/jzheaux\",\n" + - " \"followers_url\":\"https://api.github.com/users/jzheaux/followers\",\n" + - " \"following_url\":\"https://api.github.com/users/jzheaux/following{/other_user}\",\n" + - " \"gists_url\":\"https://api.github.com/users/jzheaux/gists{/gist_id}\",\n" + - " \"starred_url\":\"https://api.github.com/users/jzheaux/starred{/owner}{/repo}\",\n" + - " \"subscriptions_url\":\"https://api.github.com/users/jzheaux/subscriptions\",\n" + - " \"organizations_url\":\"https://api.github.com/users/jzheaux/orgs\",\n" + - " \"repos_url\":\"https://api.github.com/users/jzheaux/repos\",\n" + - " \"events_url\":\"https://api.github.com/users/jzheaux/events{/privacy}\",\n" + - " \"received_events_url\":\"https://api.github.com/users/jzheaux/received_events\",\n" + - " \"type\":\"User\",\n" + - " \"site_admin\":false\n" + - " },\n" + - " \"open_issues\":21,\n" + - " \"closed_issues\":23,\n" + - " \"state\":\"open\",\n" + - " \"created_at\":\"2020-09-16T13:28:03Z\",\n" + - " \"updated_at\":\"2021-04-06T23:47:10Z\",\n" + - " \"due_on\":\"2021-04-12T07:00:00Z\",\n" + - " \"closed_at\":null\n" + - " }\n" + - "]"; - this.server.enqueue(new MockResponse().setBody(responseJson)); - - long milestoneNumberByTitle = this.github.findMilestoneNumberByTitle(this.repositoryRef, "5.5.0-RC1"); - - RecordedRequest recordedRequest = this.server.takeRequest(1, TimeUnit.SECONDS); - assertThat(recordedRequest.getMethod()).isEqualToIgnoringCase("get"); - assertThat(recordedRequest.getRequestUrl().toString()).isEqualTo(this.baseUrl + "/repos/spring-projects/spring-security/milestones?per_page=100"); - - assertThat(milestoneNumberByTitle).isEqualTo(191); - } - - @Test - public void findMilestoneNumberByTitleWhenNotFoundThenException() throws Exception { - String responseJson = "[\n" + - " {\n" + - " \"url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/207\",\n" + - " \"html_url\":\"https://github.com/spring-projects/spring-security/milestone/207\",\n" + - " \"labels_url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/207/labels\",\n" + - " \"id\":6611880,\n" + - " \"node_id\":\"MDk6TWlsZXN0b25lNjYxMTg4MA==\",\n" + - " \"number\":207,\n" + - " \"title\":\"5.6.x\",\n" + - " \"description\":\"\",\n" + - " \"creator\":{\n" + - " \"login\":\"jgrandja\",\n" + - " \"id\":10884212,\n" + - " \"node_id\":\"MDQ6VXNlcjEwODg0MjEy\",\n" + - " \"avatar_url\":\"https://avatars.githubusercontent.com/u/10884212?v=4\",\n" + - " \"gravatar_id\":\"\",\n" + - " \"url\":\"https://api.github.com/users/jgrandja\",\n" + - " \"html_url\":\"https://github.com/jgrandja\",\n" + - " \"followers_url\":\"https://api.github.com/users/jgrandja/followers\",\n" + - " \"following_url\":\"https://api.github.com/users/jgrandja/following{/other_user}\",\n" + - " \"gists_url\":\"https://api.github.com/users/jgrandja/gists{/gist_id}\",\n" + - " \"starred_url\":\"https://api.github.com/users/jgrandja/starred{/owner}{/repo}\",\n" + - " \"subscriptions_url\":\"https://api.github.com/users/jgrandja/subscriptions\",\n" + - " \"organizations_url\":\"https://api.github.com/users/jgrandja/orgs\",\n" + - " \"repos_url\":\"https://api.github.com/users/jgrandja/repos\",\n" + - " \"events_url\":\"https://api.github.com/users/jgrandja/events{/privacy}\",\n" + - " \"received_events_url\":\"https://api.github.com/users/jgrandja/received_events\",\n" + - " \"type\":\"User\",\n" + - " \"site_admin\":false\n" + - " },\n" + - " \"open_issues\":1,\n" + - " \"closed_issues\":0,\n" + - " \"state\":\"open\",\n" + - " \"created_at\":\"2021-03-31T11:29:17Z\",\n" + - " \"updated_at\":\"2021-03-31T11:30:47Z\",\n" + - " \"due_on\":null,\n" + - " \"closed_at\":null\n" + - " },\n" + - " {\n" + - " \"url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/191\",\n" + - " \"html_url\":\"https://github.com/spring-projects/spring-security/milestone/191\",\n" + - " \"labels_url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/191/labels\",\n" + - " \"id\":5884208,\n" + - " \"node_id\":\"MDk6TWlsZXN0b25lNTg4NDIwOA==\",\n" + - " \"number\":191,\n" + - " \"title\":\"5.5.0-RC1\",\n" + - " \"description\":\"\",\n" + - " \"creator\":{\n" + - " \"login\":\"jzheaux\",\n" + - " \"id\":3627351,\n" + - " \"node_id\":\"MDQ6VXNlcjM2MjczNTE=\",\n" + - " \"avatar_url\":\"https://avatars.githubusercontent.com/u/3627351?v=4\",\n" + - " \"gravatar_id\":\"\",\n" + - " \"url\":\"https://api.github.com/users/jzheaux\",\n" + - " \"html_url\":\"https://github.com/jzheaux\",\n" + - " \"followers_url\":\"https://api.github.com/users/jzheaux/followers\",\n" + - " \"following_url\":\"https://api.github.com/users/jzheaux/following{/other_user}\",\n" + - " \"gists_url\":\"https://api.github.com/users/jzheaux/gists{/gist_id}\",\n" + - " \"starred_url\":\"https://api.github.com/users/jzheaux/starred{/owner}{/repo}\",\n" + - " \"subscriptions_url\":\"https://api.github.com/users/jzheaux/subscriptions\",\n" + - " \"organizations_url\":\"https://api.github.com/users/jzheaux/orgs\",\n" + - " \"repos_url\":\"https://api.github.com/users/jzheaux/repos\",\n" + - " \"events_url\":\"https://api.github.com/users/jzheaux/events{/privacy}\",\n" + - " \"received_events_url\":\"https://api.github.com/users/jzheaux/received_events\",\n" + - " \"type\":\"User\",\n" + - " \"site_admin\":false\n" + - " },\n" + - " \"open_issues\":21,\n" + - " \"closed_issues\":23,\n" + - " \"state\":\"open\",\n" + - " \"created_at\":\"2020-09-16T13:28:03Z\",\n" + - " \"updated_at\":\"2021-04-06T23:47:10Z\",\n" + - " \"due_on\":\"2021-04-12T07:00:00Z\",\n" + - " \"closed_at\":null\n" + - " }\n" + - "]"; - this.server.enqueue(new MockResponse().setBody(responseJson)); - - assertThatExceptionOfType(RuntimeException.class) - .isThrownBy(() -> this.github.findMilestoneNumberByTitle(this.repositoryRef, "missing")); - } - - @Test - public void isOpenIssuesForMilestoneNumberWhenAllClosedThenFalse() throws Exception { - String responseJson = "[]"; - long milestoneNumber = 202; - this.server.enqueue(new MockResponse().setBody(responseJson)); - - assertThat(this.github.isOpenIssuesForMilestoneNumber(this.repositoryRef, milestoneNumber)).isFalse(); - - RecordedRequest recordedRequest = this.server.takeRequest(1, TimeUnit.SECONDS); - assertThat(recordedRequest.getMethod()).isEqualToIgnoringCase("get"); - assertThat(recordedRequest.getRequestUrl().toString()).isEqualTo(this.baseUrl + "/repos/spring-projects/spring-security/issues?per_page=1&milestone=" + milestoneNumber); - } - - @Test - public void isOpenIssuesForMilestoneNumberWhenOpenIssuesThenTrue() throws Exception { - String responseJson = "[\n" + - " {\n" + - " \"url\":\"https://api.github.com/repos/spring-projects/spring-security/issues/9562\",\n" + - " \"repository_url\":\"https://api.github.com/repos/spring-projects/spring-security\",\n" + - " \"labels_url\":\"https://api.github.com/repos/spring-projects/spring-security/issues/9562/labels{/name}\",\n" + - " \"comments_url\":\"https://api.github.com/repos/spring-projects/spring-security/issues/9562/comments\",\n" + - " \"events_url\":\"https://api.github.com/repos/spring-projects/spring-security/issues/9562/events\",\n" + - " \"html_url\":\"https://github.com/spring-projects/spring-security/pull/9562\",\n" + - " \"id\":851886504,\n" + - " \"node_id\":\"MDExOlB1bGxSZXF1ZXN0NjEwMjMzMDcw\",\n" + - " \"number\":9562,\n" + - " \"title\":\"Add package-list\",\n" + - " \"user\":{\n" + - " \"login\":\"jzheaux\",\n" + - " \"id\":3627351,\n" + - " \"node_id\":\"MDQ6VXNlcjM2MjczNTE=\",\n" + - " \"avatar_url\":\"https://avatars.githubusercontent.com/u/3627351?v=4\",\n" + - " \"gravatar_id\":\"\",\n" + - " \"url\":\"https://api.github.com/users/jzheaux\",\n" + - " \"html_url\":\"https://github.com/jzheaux\",\n" + - " \"followers_url\":\"https://api.github.com/users/jzheaux/followers\",\n" + - " \"following_url\":\"https://api.github.com/users/jzheaux/following{/other_user}\",\n" + - " \"gists_url\":\"https://api.github.com/users/jzheaux/gists{/gist_id}\",\n" + - " \"starred_url\":\"https://api.github.com/users/jzheaux/starred{/owner}{/repo}\",\n" + - " \"subscriptions_url\":\"https://api.github.com/users/jzheaux/subscriptions\",\n" + - " \"organizations_url\":\"https://api.github.com/users/jzheaux/orgs\",\n" + - " \"repos_url\":\"https://api.github.com/users/jzheaux/repos\",\n" + - " \"events_url\":\"https://api.github.com/users/jzheaux/events{/privacy}\",\n" + - " \"received_events_url\":\"https://api.github.com/users/jzheaux/received_events\",\n" + - " \"type\":\"User\",\n" + - " \"site_admin\":false\n" + - " },\n" + - " \"labels\":[\n" + - " {\n" + - " \"id\":322225043,\n" + - " \"node_id\":\"MDU6TGFiZWwzMjIyMjUwNDM=\",\n" + - " \"url\":\"https://api.github.com/repos/spring-projects/spring-security/labels/in:%20build\",\n" + - " \"name\":\"in: build\",\n" + - " \"color\":\"e8f9de\",\n" + - " \"default\":false,\n" + - " \"description\":\"An issue in the build\"\n" + - " },\n" + - " {\n" + - " \"id\":322225079,\n" + - " \"node_id\":\"MDU6TGFiZWwzMjIyMjUwNzk=\",\n" + - " \"url\":\"https://api.github.com/repos/spring-projects/spring-security/labels/type:%20bug\",\n" + - " \"name\":\"type: bug\",\n" + - " \"color\":\"e3d9fc\",\n" + - " \"default\":false,\n" + - " \"description\":\"A general bug\"\n" + - " }\n" + - " ],\n" + - " \"state\":\"open\",\n" + - " \"locked\":false,\n" + - " \"assignee\":{\n" + - " \"login\":\"rwinch\",\n" + - " \"id\":362503,\n" + - " \"node_id\":\"MDQ6VXNlcjM2MjUwMw==\",\n" + - " \"avatar_url\":\"https://avatars.githubusercontent.com/u/362503?v=4\",\n" + - " \"gravatar_id\":\"\",\n" + - " \"url\":\"https://api.github.com/users/rwinch\",\n" + - " \"html_url\":\"https://github.com/rwinch\",\n" + - " \"followers_url\":\"https://api.github.com/users/rwinch/followers\",\n" + - " \"following_url\":\"https://api.github.com/users/rwinch/following{/other_user}\",\n" + - " \"gists_url\":\"https://api.github.com/users/rwinch/gists{/gist_id}\",\n" + - " \"starred_url\":\"https://api.github.com/users/rwinch/starred{/owner}{/repo}\",\n" + - " \"subscriptions_url\":\"https://api.github.com/users/rwinch/subscriptions\",\n" + - " \"organizations_url\":\"https://api.github.com/users/rwinch/orgs\",\n" + - " \"repos_url\":\"https://api.github.com/users/rwinch/repos\",\n" + - " \"events_url\":\"https://api.github.com/users/rwinch/events{/privacy}\",\n" + - " \"received_events_url\":\"https://api.github.com/users/rwinch/received_events\",\n" + - " \"type\":\"User\",\n" + - " \"site_admin\":false\n" + - " },\n" + - " \"assignees\":[\n" + - " {\n" + - " \"login\":\"rwinch\",\n" + - " \"id\":362503,\n" + - " \"node_id\":\"MDQ6VXNlcjM2MjUwMw==\",\n" + - " \"avatar_url\":\"https://avatars.githubusercontent.com/u/362503?v=4\",\n" + - " \"gravatar_id\":\"\",\n" + - " \"url\":\"https://api.github.com/users/rwinch\",\n" + - " \"html_url\":\"https://github.com/rwinch\",\n" + - " \"followers_url\":\"https://api.github.com/users/rwinch/followers\",\n" + - " \"following_url\":\"https://api.github.com/users/rwinch/following{/other_user}\",\n" + - " \"gists_url\":\"https://api.github.com/users/rwinch/gists{/gist_id}\",\n" + - " \"starred_url\":\"https://api.github.com/users/rwinch/starred{/owner}{/repo}\",\n" + - " \"subscriptions_url\":\"https://api.github.com/users/rwinch/subscriptions\",\n" + - " \"organizations_url\":\"https://api.github.com/users/rwinch/orgs\",\n" + - " \"repos_url\":\"https://api.github.com/users/rwinch/repos\",\n" + - " \"events_url\":\"https://api.github.com/users/rwinch/events{/privacy}\",\n" + - " \"received_events_url\":\"https://api.github.com/users/rwinch/received_events\",\n" + - " \"type\":\"User\",\n" + - " \"site_admin\":false\n" + - " }\n" + - " ],\n" + - " \"milestone\":{\n" + - " \"url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/191\",\n" + - " \"html_url\":\"https://github.com/spring-projects/spring-security/milestone/191\",\n" + - " \"labels_url\":\"https://api.github.com/repos/spring-projects/spring-security/milestones/191/labels\",\n" + - " \"id\":5884208,\n" + - " \"node_id\":\"MDk6TWlsZXN0b25lNTg4NDIwOA==\",\n" + - " \"number\":191,\n" + - " \"title\":\"5.5.0-RC1\",\n" + - " \"description\":\"\",\n" + - " \"creator\":{\n" + - " \"login\":\"jzheaux\",\n" + - " \"id\":3627351,\n" + - " \"node_id\":\"MDQ6VXNlcjM2MjczNTE=\",\n" + - " \"avatar_url\":\"https://avatars.githubusercontent.com/u/3627351?v=4\",\n" + - " \"gravatar_id\":\"\",\n" + - " \"url\":\"https://api.github.com/users/jzheaux\",\n" + - " \"html_url\":\"https://github.com/jzheaux\",\n" + - " \"followers_url\":\"https://api.github.com/users/jzheaux/followers\",\n" + - " \"following_url\":\"https://api.github.com/users/jzheaux/following{/other_user}\",\n" + - " \"gists_url\":\"https://api.github.com/users/jzheaux/gists{/gist_id}\",\n" + - " \"starred_url\":\"https://api.github.com/users/jzheaux/starred{/owner}{/repo}\",\n" + - " \"subscriptions_url\":\"https://api.github.com/users/jzheaux/subscriptions\",\n" + - " \"organizations_url\":\"https://api.github.com/users/jzheaux/orgs\",\n" + - " \"repos_url\":\"https://api.github.com/users/jzheaux/repos\",\n" + - " \"events_url\":\"https://api.github.com/users/jzheaux/events{/privacy}\",\n" + - " \"received_events_url\":\"https://api.github.com/users/jzheaux/received_events\",\n" + - " \"type\":\"User\",\n" + - " \"site_admin\":false\n" + - " },\n" + - " \"open_issues\":21,\n" + - " \"closed_issues\":23,\n" + - " \"state\":\"open\",\n" + - " \"created_at\":\"2020-09-16T13:28:03Z\",\n" + - " \"updated_at\":\"2021-04-06T23:47:10Z\",\n" + - " \"due_on\":\"2021-04-12T07:00:00Z\",\n" + - " \"closed_at\":null\n" + - " },\n" + - " \"comments\":0,\n" + - " \"created_at\":\"2021-04-06T23:47:10Z\",\n" + - " \"updated_at\":\"2021-04-07T17:00:00Z\",\n" + - " \"closed_at\":null,\n" + - " \"author_association\":\"MEMBER\",\n" + - " \"active_lock_reason\":null,\n" + - " \"pull_request\":{\n" + - " \"url\":\"https://api.github.com/repos/spring-projects/spring-security/pulls/9562\",\n" + - " \"html_url\":\"https://github.com/spring-projects/spring-security/pull/9562\",\n" + - " \"diff_url\":\"https://github.com/spring-projects/spring-security/pull/9562.diff\",\n" + - " \"patch_url\":\"https://github.com/spring-projects/spring-security/pull/9562.patch\"\n" + - " },\n" + - " \"body\":\"Closes gh-9528\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\",\n" + - " \"performed_via_github_app\":null\n" + - " }\n" + - "]"; - long milestoneNumber = 191; - this.server.enqueue(new MockResponse().setBody(responseJson)); - - assertThat(this.github.isOpenIssuesForMilestoneNumber(this.repositoryRef, milestoneNumber)).isTrue(); - - RecordedRequest recordedRequest = this.server.takeRequest(1, TimeUnit.SECONDS); - assertThat(recordedRequest.getMethod()).isEqualToIgnoringCase("get"); - assertThat(recordedRequest.getRequestUrl().toString()).isEqualTo(this.baseUrl + "/repos/spring-projects/spring-security/issues?per_page=1&milestone=" + milestoneNumber); - } - -} diff --git a/buildSrc/src/test/java/org/springframework/gradle/github/release/GitHubReleaseApiTests.java b/buildSrc/src/test/java/org/springframework/gradle/github/release/GitHubReleaseApiTests.java deleted file mode 100644 index 439bf4878..000000000 --- a/buildSrc/src/test/java/org/springframework/gradle/github/release/GitHubReleaseApiTests.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright 2006-present the original author or 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.springframework.gradle.github.release; - -import java.util.concurrent.TimeUnit; - -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Test; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; - -import org.springframework.gradle.github.RepositoryRef; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * @author Steve Riesenberg - */ -public class GitHubReleaseApiTests { - private GitHubReleaseApi github; - - private RepositoryRef repository = new RepositoryRef("spring-projects", "spring-security"); - - private MockWebServer server; - - private String baseUrl; - - @BeforeEach - public void setup() throws Exception { - this.server = new MockWebServer(); - this.server.start(); - this.github = new GitHubReleaseApi("mock-oauth-token"); - this.baseUrl = this.server.url("/api").toString(); - this.github.setBaseUrl(this.baseUrl); - } - - @AfterEach - public void cleanup() throws Exception { - this.server.shutdown(); - } - - @Test - public void publishReleaseWhenValidParametersThenSuccess() throws Exception { - String responseJson = "{\n" + - " \"url\": \"https://api.github.com/spring-projects/spring-security/releases/1\",\n" + - " \"html_url\": \"https://github.com/spring-projects/spring-security/releases/tags/v1.0.0\",\n" + - " \"assets_url\": \"https://api.github.com/spring-projects/spring-security/releases/1/assets\",\n" + - " \"upload_url\": \"https://uploads.github.com/spring-projects/spring-security/releases/1/assets{?name,label}\",\n" + - " \"tarball_url\": \"https://api.github.com/spring-projects/spring-security/tarball/v1.0.0\",\n" + - " \"zipball_url\": \"https://api.github.com/spring-projects/spring-security/zipball/v1.0.0\",\n" + - " \"discussion_url\": \"https://github.com/spring-projects/spring-security/discussions/90\",\n" + - " \"id\": 1,\n" + - " \"node_id\": \"MDc6UmVsZWFzZTE=\",\n" + - " \"tag_name\": \"v1.0.0\",\n" + - " \"target_commitish\": \"main\",\n" + - " \"name\": \"v1.0.0\",\n" + - " \"body\": \"Description of the release\",\n" + - " \"draft\": false,\n" + - " \"prerelease\": false,\n" + - " \"created_at\": \"2013-02-27T19:35:32Z\",\n" + - " \"published_at\": \"2013-02-27T19:35:32Z\",\n" + - " \"author\": {\n" + - " \"login\": \"sjohnr\",\n" + - " \"id\": 1,\n" + - " \"node_id\": \"MDQ6VXNlcjE=\",\n" + - " \"avatar_url\": \"https://github.com/images/avatar.gif\",\n" + - " \"gravatar_id\": \"\",\n" + - " \"url\": \"https://api.github.com/users/sjohnr\",\n" + - " \"html_url\": \"https://github.com/sjohnr\",\n" + - " \"followers_url\": \"https://api.github.com/users/sjohnr/followers\",\n" + - " \"following_url\": \"https://api.github.com/users/sjohnr/following{/other_user}\",\n" + - " \"gists_url\": \"https://api.github.com/users/sjohnr/gists{/gist_id}\",\n" + - " \"starred_url\": \"https://api.github.com/users/sjohnr/starred{/owner}{/repo}\",\n" + - " \"subscriptions_url\": \"https://api.github.com/users/sjohnr/subscriptions\",\n" + - " \"organizations_url\": \"https://api.github.com/users/sjohnr/orgs\",\n" + - " \"repos_url\": \"https://api.github.com/users/sjohnr/repos\",\n" + - " \"events_url\": \"https://api.github.com/users/sjohnr/events{/privacy}\",\n" + - " \"received_events_url\": \"https://api.github.com/users/sjohnr/received_events\",\n" + - " \"type\": \"User\",\n" + - " \"site_admin\": false\n" + - " },\n" + - " \"assets\": [\n" + - " {\n" + - " \"url\": \"https://api.github.com/spring-projects/spring-security/releases/assets/1\",\n" + - " \"browser_download_url\": \"https://github.com/spring-projects/spring-security/releases/download/v1.0.0/example.zip\",\n" + - " \"id\": 1,\n" + - " \"node_id\": \"MDEyOlJlbGVhc2VBc3NldDE=\",\n" + - " \"name\": \"example.zip\",\n" + - " \"label\": \"short description\",\n" + - " \"state\": \"uploaded\",\n" + - " \"content_type\": \"application/zip\",\n" + - " \"size\": 1024,\n" + - " \"download_count\": 42,\n" + - " \"created_at\": \"2013-02-27T19:35:32Z\",\n" + - " \"updated_at\": \"2013-02-27T19:35:32Z\",\n" + - " \"uploader\": {\n" + - " \"login\": \"sjohnr\",\n" + - " \"id\": 1,\n" + - " \"node_id\": \"MDQ6VXNlcjE=\",\n" + - " \"avatar_url\": \"https://github.com/images/avatar.gif\",\n" + - " \"gravatar_id\": \"\",\n" + - " \"url\": \"https://api.github.com/users/sjohnr\",\n" + - " \"html_url\": \"https://github.com/sjohnr\",\n" + - " \"followers_url\": \"https://api.github.com/users/sjohnr/followers\",\n" + - " \"following_url\": \"https://api.github.com/users/sjohnr/following{/other_user}\",\n" + - " \"gists_url\": \"https://api.github.com/users/sjohnr/gists{/gist_id}\",\n" + - " \"starred_url\": \"https://api.github.com/users/sjohnr/starred{/owner}{/repo}\",\n" + - " \"subscriptions_url\": \"https://api.github.com/users/sjohnr/subscriptions\",\n" + - " \"organizations_url\": \"https://api.github.com/users/sjohnr/orgs\",\n" + - " \"repos_url\": \"https://api.github.com/users/sjohnr/repos\",\n" + - " \"events_url\": \"https://api.github.com/users/sjohnr/events{/privacy}\",\n" + - " \"received_events_url\": \"https://api.github.com/users/sjohnr/received_events\",\n" + - " \"type\": \"User\",\n" + - " \"site_admin\": false\n" + - " }\n" + - " }\n" + - " ]\n" + - "}"; - this.server.enqueue(new MockResponse().setBody(responseJson)); - this.github.publishRelease(this.repository, Release.tag("1.0.0").build()); - - RecordedRequest recordedRequest = this.server.takeRequest(1, TimeUnit.SECONDS); - assertThat(recordedRequest.getMethod()).isEqualToIgnoringCase("post"); - assertThat(recordedRequest.getRequestUrl().toString()).isEqualTo(this.baseUrl + "/repos/spring-projects/spring-security/releases"); - assertThat(recordedRequest.getBody().toString()).isEqualTo("{\"tag_name\":\"1.0.0\"}"); - } - - @Test - public void publishReleaseWhenErrorResponseThenException() throws Exception { - this.server.enqueue(new MockResponse().setResponseCode(400)); - assertThatExceptionOfType(RuntimeException.class) - .isThrownBy(() -> this.github.publishRelease(this.repository, Release.tag("1.0.0").build())); - } -} diff --git a/buildSrc/src/test/resources/samples/showcase/bom/bom.gradle b/buildSrc/src/test/resources/samples/showcase/bom/bom.gradle deleted file mode 100644 index 19aa720c8..000000000 --- a/buildSrc/src/test/resources/samples/showcase/bom/bom.gradle +++ /dev/null @@ -1,2 +0,0 @@ -apply plugin: 'io.spring.convention.bom' -