├── gradle.properties
├── src
├── functionalTest
│ ├── resources
│ │ ├── _template
│ │ │ ├── groovy
│ │ │ │ ├── build.gradle
│ │ │ │ └── settings.gradle
│ │ │ └── kotlin
│ │ │ │ ├── build.gradle.kts
│ │ │ │ └── settings.gradle.kts
│ │ ├── ApplyTest
│ │ │ ├── onlyUsedInSettings
│ │ │ │ ├── groovy
│ │ │ │ │ ├── build.gradle
│ │ │ │ │ └── settings.gradle
│ │ │ │ └── kotlin
│ │ │ │ │ ├── build.gradle.kts
│ │ │ │ │ └── settings.gradle.kts
│ │ │ ├── onlyUsedInProject
│ │ │ │ ├── groovy
│ │ │ │ │ ├── settings.gradle
│ │ │ │ │ └── build.gradle
│ │ │ │ └── kotlin
│ │ │ │ │ ├── settings.gradle.kts
│ │ │ │ │ └── build.gradle.kts
│ │ │ ├── subprojectTest
│ │ │ │ ├── groovy
│ │ │ │ │ ├── settings.gradle
│ │ │ │ │ ├── build.gradle
│ │ │ │ │ ├── subproject2
│ │ │ │ │ │ └── build.gradle
│ │ │ │ │ └── subproject1
│ │ │ │ │ │ └── build.gradle
│ │ │ │ └── kotlin
│ │ │ │ │ ├── settings.gradle
│ │ │ │ │ ├── build.gradle
│ │ │ │ │ ├── subproject2
│ │ │ │ │ └── build.gradle
│ │ │ │ │ └── subproject1
│ │ │ │ │ └── build.gradle
│ │ │ ├── usedInSettingsAndProjectWithoutApplying
│ │ │ │ ├── groovy
│ │ │ │ │ ├── build.gradle
│ │ │ │ │ └── settings.gradle
│ │ │ │ └── kotlin
│ │ │ │ │ ├── settings.gradle.kts
│ │ │ │ │ └── build.gradle.kts
│ │ │ └── usedInSettingsAndProject
│ │ │ │ ├── groovy
│ │ │ │ ├── settings.gradle
│ │ │ │ └── build.gradle
│ │ │ │ └── kotlin
│ │ │ │ ├── settings.gradle.kts
│ │ │ │ └── build.gradle.kts
│ │ ├── test.xml
│ │ ├── GoogleRecommendationTest
│ │ │ └── test
│ │ │ │ └── groovy
│ │ │ │ ├── app
│ │ │ │ └── build.gradle
│ │ │ │ ├── build.gradle
│ │ │ │ └── settings.gradle
│ │ └── UploadTest
│ │ │ └── uploadtest
│ │ │ ├── groovy
│ │ │ ├── settings.gradle
│ │ │ └── build.gradle
│ │ │ └── kotlin
│ │ │ ├── build.gradle.kts
│ │ │ └── settings.gradle.kts
│ └── groovy
│ │ └── at
│ │ └── schrottner
│ │ └── gradle
│ │ ├── testhelper
│ │ ├── ReadMe.md
│ │ ├── MappedParameterContext.java
│ │ └── AfterBeforeParameterResolver.java
│ │ ├── GoogleRecommendationTest.groovy
│ │ ├── PluginTestParams.java
│ │ ├── TestFileUtils.groovy
│ │ ├── PluginTest.java
│ │ ├── UploadTest.groovy
│ │ ├── AbstractFunctionalTests.groovy
│ │ └── ApplyTest.groovy
├── main
│ └── groovy
│ │ └── at
│ │ └── schrottner
│ │ └── gradle
│ │ ├── Config.groovy
│ │ ├── auths
│ │ ├── Token.groovy
│ │ └── GitLabTokenType.groovy
│ │ ├── GitLabEntityType.groovy
│ │ ├── RepositoryConfiguration.groovy
│ │ ├── GitlabRepositoriesPlugin.groovy
│ │ ├── GitlabRepositoriesExtension.groovy
│ │ └── RepositoryActionHandler.groovy
└── test
│ └── groovy
│ └── at
│ └── schrottner
│ └── gradle
│ └── GitlabRepositoriesPluginTest.groovy
├── .clabot
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── renovate.json
├── .gitignore
├── _config.yml
├── license-header.spotless
├── settings.gradle
├── .github
└── workflows
│ ├── release.yml
│ └── ci.yml
├── gradlew.bat
├── CODE_OF_CONDUCT.md
├── gradlew
├── README.md
└── LICENSE.md
/gradle.properties:
--------------------------------------------------------------------------------
1 | group=at.schrottner.gradle.gitlab-plugin
--------------------------------------------------------------------------------
/src/functionalTest/resources/_template/groovy/build.gradle:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/_template/groovy/settings.gradle:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/_template/kotlin/build.gradle.kts:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/_template/kotlin/settings.gradle.kts:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/ApplyTest/onlyUsedInSettings/groovy/build.gradle:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/ApplyTest/onlyUsedInProject/groovy/settings.gradle:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/ApplyTest/onlyUsedInProject/kotlin/settings.gradle.kts:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/ApplyTest/onlyUsedInSettings/kotlin/build.gradle.kts:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/test.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/.clabot:
--------------------------------------------------------------------------------
1 | {
2 | "contributors": ["aepfli","renovate-bot", "renovate", "renovate[bot]"]
3 | }
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aepfli/gradle-gitlab-repositories/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/renovate.json:
--------------------------------------------------------------------------------
1 |
2 | {
3 | "extends": [
4 | "config:base",
5 | ":disableDependencyDashboard"
6 | ],
7 | "branchConcurrentLimit": 40,
8 | "prHourlyLimit": 0
9 | }
10 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore Gradle project-specific cache directory
2 | .gradle
3 | .idea
4 |
5 | # Ignore Gradle build output directory
6 | build
7 | out
8 | /bin/
9 | /.classpath
10 | /.project
11 | /.settings
12 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-minimal
2 | title: Gradle GitLab Repositories Plugin
3 | description: Handling Maven GitLab dependencies easy. Define multiple tokens and selectively apply them to repositories.
4 |
5 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/GoogleRecommendationTest/test/groovy/app/build.gradle:
--------------------------------------------------------------------------------
1 |
2 | configurations {
3 | testing
4 | }
5 |
6 | dependencies {
7 | testing "at.schrottner.test.gitlab-repositories:test-file:test-SNAPSHOT@xml"
8 | }
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.4-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/GoogleRecommendationTest/test/groovy/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | }
3 |
4 | configurations {
5 | testing
6 | }
7 | task clean(type: Delete) {
8 | delete rootProject.buildDir
9 | }
10 | subprojects {
11 | task allDeps(type: DependencyReportTask) {}
12 | }
--------------------------------------------------------------------------------
/src/functionalTest/groovy/at/schrottner/gradle/testhelper/ReadMe.md:
--------------------------------------------------------------------------------
1 | first implementation in this package is copy pasted from
2 |
3 | https://github.com/lamektomasz/AfterBeforeParameterizedTestExtension/
4 |
5 | Therefore i want to make a big shoutout to @lamektomasz for this nice piece of code.
--------------------------------------------------------------------------------
/license-header.spotless:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2021 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v2.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v20.html
9 | */
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * This file was generated by the Gradle 'init' task.
3 | *
4 | * The settings file is used to specify which projects to include in your build.
5 | *
6 | * Detailed information about configuring a multi-project build in Gradle can be found
7 | * in the user manual at https://docs.gradle.org/5.6.4/userguide/multi_project_builds.html
8 | */
9 |
10 | rootProject.name = 'gitlab-repositories'
11 |
--------------------------------------------------------------------------------
/src/functionalTest/groovy/at/schrottner/gradle/GoogleRecommendationTest.groovy:
--------------------------------------------------------------------------------
1 | package at.schrottner.gradle;
2 |
3 | import org.gradle.testkit.runner.BuildResult;
4 | import org.junit.jupiter.params.ParameterizedTest;
5 | import org.junit.jupiter.params.provider.ValueSource;
6 |
7 | class GoogleRecommendationTest extends AbstractFunctionalTests {
8 |
9 | @ParameterizedTest
10 | @ValueSource(strings = ["groovy"])
11 | void "test"(String primer) {
12 | //given:
13 |
14 | //when:
15 | BuildResult result = runTest("allDeps","-i","--refresh-dependencies")
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/groovy/at/schrottner/gradle/Config.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2021 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v2.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v20.html
9 | */
10 | package at.schrottner.gradle
11 |
12 | class Config {
13 | public static final String LOG_PREFIX = "GitLab Repositories ::"
14 | public static final String GROUP = "Group"
15 | public static final String PROJECT = "Project"
16 | }
17 |
--------------------------------------------------------------------------------
/src/functionalTest/groovy/at/schrottner/gradle/PluginTestParams.java:
--------------------------------------------------------------------------------
1 | package at.schrottner.gradle;
2 |
3 | import org.junit.jupiter.api.extension.ExtensionContext;
4 | import org.junit.jupiter.params.provider.Arguments;
5 | import org.junit.jupiter.params.provider.ArgumentsProvider;
6 |
7 | import java.util.stream.Stream;
8 |
9 | public class PluginTestParams implements ArgumentsProvider {
10 | @Override
11 | public Stream extends Arguments> provideArguments(ExtensionContext context) {
12 | return Stream.of(
13 | Arguments.of("groovy"),
14 | Arguments.of("kotlin")
15 | );
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/ApplyTest/subprojectTest/groovy/settings.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | dependencies {
3 | classpath files(pluginClasspath.split(','))
4 | }
5 | }
6 | apply plugin: at.schrottner.gradle.GitlabRepositoriesPlugin
7 |
8 | gitLab {
9 | token(PrivateToken) {
10 | it.key = 'tokenIgnoredNoValue'
11 | it.value = ''
12 | }
13 | token(DeployToken) {
14 | it.key = 'token0'
15 | it.value = 'test'
16 | }
17 | token(DeployToken) {
18 | it.key = 'token1'
19 | it.value = 'test'
20 | }
21 | }
22 |
23 | pluginManagement.repositories {
24 | realms.split(',').each { realm ->
25 | maven gitLab."$realm"("$existingId")
26 | }
27 | }
28 |
29 | include 'subproject1', 'subproject2'
--------------------------------------------------------------------------------
/src/functionalTest/resources/ApplyTest/subprojectTest/kotlin/settings.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | dependencies {
3 | classpath files(pluginClasspath.split(','))
4 | }
5 | }
6 | apply plugin: at.schrottner.gradle.GitlabRepositoriesPlugin
7 |
8 | gitLab {
9 | token(PrivateToken) {
10 | it.key = 'tokenIgnoredNoValue'
11 | it.value = ''
12 | }
13 | token(DeployToken) {
14 | it.key = 'token0'
15 | it.value = 'test'
16 | }
17 | token(DeployToken) {
18 | it.key = 'token1'
19 | it.value = 'test'
20 | }
21 | }
22 |
23 | pluginManagement.repositories {
24 | realms.split(',').each { realm ->
25 | maven gitLab."$realm"("$existingId")
26 | }
27 | }
28 |
29 | include 'subproject1', 'subproject2'
--------------------------------------------------------------------------------
/src/main/groovy/at/schrottner/gradle/auths/Token.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2021 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v2.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v20.html
9 | */
10 | package at.schrottner.gradle.auths
11 |
12 | /**
13 | * TODO:
14 | * - rework tokens - this subclassing is ridiculous and should be reflected by a enum
15 | */
16 | public class Token {
17 | GitLabTokenType type
18 | String value
19 | String key
20 |
21 | Token(GitLabTokenType type) {
22 | this.type = type
23 | }
24 | }
--------------------------------------------------------------------------------
/src/functionalTest/resources/ApplyTest/subprojectTest/groovy/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | dependencies {
3 | classpath files(pluginClasspath.split(','))
4 | }
5 | }
6 | apply plugin: at.schrottner.gradle.GitlabRepositoriesPlugin
7 |
8 | gitLab {
9 | token(PrivateToken) {
10 | it.key = 'tokenIgnoredNoValue'
11 | it.value = ''
12 | }
13 | token(PrivateToken) {
14 | it.key = 'token0'
15 | it.value = 'test'
16 | }
17 | token(PrivateToken) {
18 | it.key = 'token1'
19 | it.value = 'test'
20 | }
21 | token(DeployToken) {
22 | it.key = 'tokenAdded'
23 | it.value = 'test'
24 | }
25 | }
26 | repositories {
27 | realms.split(',').each { realm ->
28 |
29 | maven gitLab."$realm"("$existingId")
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/ApplyTest/subprojectTest/kotlin/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | dependencies {
3 | classpath files(pluginClasspath.split(','))
4 | }
5 | }
6 | apply plugin: at.schrottner.gradle.GitlabRepositoriesPlugin
7 |
8 | gitLab {
9 | token(PrivateToken) {
10 | it.key = 'tokenIgnoredNoValue'
11 | it.value = ''
12 | }
13 | token(PrivateToken) {
14 | it.key = 'token0'
15 | it.value = 'test'
16 | }
17 | token(PrivateToken) {
18 | it.key = 'token1'
19 | it.value = 'test'
20 | }
21 | token(DeployToken) {
22 | it.key = 'tokenAdded'
23 | it.value = 'test'
24 | }
25 | }
26 | repositories {
27 | realms.split(',').each { realm ->
28 |
29 | maven gitLab."$realm"("$existingId")
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/ApplyTest/subprojectTest/groovy/subproject2/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | dependencies {
3 | classpath files(pluginClasspath.split(','))
4 | }
5 | }
6 | apply plugin: at.schrottner.gradle.GitlabRepositoriesPlugin
7 |
8 | gitLab {
9 | token(DeployToken) {
10 | it.key = 'tokenAdded'
11 | it.value = 'test'
12 | }
13 | token(DeployToken) {
14 | it.key = 'tokenAdded1'
15 | it.value = ''
16 | }
17 | token(DeployToken) {
18 | it.key = 'token0'
19 | it.value = 'test'
20 | }
21 | }
22 | repositories {
23 | realms.split(',').each { realm ->
24 | maven gitLab."$realm"("tokentest") {
25 | tokenSelector = "tokenAdded"
26 | }
27 | maven gitLab."$realm"("tokentest1") {
28 | tokenSelector = "tokenAdded1"
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/ApplyTest/subprojectTest/kotlin/subproject2/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | dependencies {
3 | classpath files(pluginClasspath.split(','))
4 | }
5 | }
6 | apply plugin: at.schrottner.gradle.GitlabRepositoriesPlugin
7 |
8 | gitLab {
9 | token(DeployToken) {
10 | it.key = 'tokenAdded'
11 | it.value = 'test'
12 | }
13 | token(DeployToken) {
14 | it.key = 'tokenAdded1'
15 | it.value = ''
16 | }
17 | token(DeployToken) {
18 | it.key = 'token0'
19 | it.value = 'test'
20 | }
21 | }
22 | repositories {
23 | realms.split(',').each { realm ->
24 | maven gitLab."$realm"("tokentest") {
25 | tokenSelector = "tokenAdded"
26 | }
27 | maven gitLab."$realm"("tokentest1") {
28 | tokenSelector = "tokenAdded1"
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/groovy/at/schrottner/gradle/GitLabEntityType.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2021 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v2.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v20.html
9 | */
10 | package at.schrottner.gradle
11 |
12 | enum GitLabEntityType {
13 | GROUP("Group", "groups"),
14 | PROJECT("Project", "projects")
15 |
16 | String name
17 | String endpoint
18 |
19 | GitLabEntityType(String name, String endpoint) {
20 | this.name = name
21 | this.endpoint = endpoint
22 | }
23 |
24 | @Override
25 | String toString() {
26 | return name
27 | }
28 | }
--------------------------------------------------------------------------------
/src/functionalTest/resources/ApplyTest/subprojectTest/groovy/subproject1/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | dependencies {
3 | classpath files(pluginClasspath.split(','))
4 | }
5 | }
6 | apply plugin: at.schrottner.gradle.GitlabRepositoriesPlugin
7 |
8 | gitLab {
9 | token(DeployToken) {
10 | it.key = 'tokenAdded'
11 | it.value = ''
12 | }
13 | token(DeployToken) {
14 | it.key = 'tokenAdded1'
15 | it.value = 'project1'
16 | }
17 | token(DeployToken) {
18 | it.key = 'token0'
19 | it.value = 'test'
20 | }
21 | }
22 |
23 | repositories {
24 | realms.split(',').each { realm ->
25 | maven gitLab."$realm"("tokentest") {
26 | tokenSelector = "tokenAdded"
27 | }
28 | maven gitLab."$realm"("tokentest1") {
29 | tokenSelector = "tokenAdded1"
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/ApplyTest/subprojectTest/kotlin/subproject1/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | dependencies {
3 | classpath files(pluginClasspath.split(','))
4 | }
5 | }
6 | apply plugin: at.schrottner.gradle.GitlabRepositoriesPlugin
7 |
8 | gitLab {
9 | token(DeployToken) {
10 | it.key = 'tokenAdded'
11 | it.value = ''
12 | }
13 | token(DeployToken) {
14 | it.key = 'tokenAdded1'
15 | it.value = 'project1'
16 | }
17 | token(DeployToken) {
18 | it.key = 'token0'
19 | it.value = 'test'
20 | }
21 | }
22 |
23 | repositories {
24 | realms.split(',').each { realm ->
25 | maven gitLab."$realm"("tokentest") {
26 | tokenSelector = "tokenAdded"
27 | }
28 | maven gitLab."$realm"("tokentest1") {
29 | tokenSelector = "tokenAdded1"
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/groovy/at/schrottner/gradle/GitlabRepositoriesPluginTest.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * This Groovy source file was generated by the Gradle 'init' task.
3 | */
4 | package at.schrottner.gradle
5 |
6 | import org.gradle.testfixtures.ProjectBuilder
7 | import spock.lang.Specification
8 |
9 | public class GitlabRepositoriesPluginTest extends Specification {
10 | def "apply to Project"() {
11 | given:
12 | def project = ProjectBuilder.builder().build()
13 |
14 | when:
15 | project.plugins.apply("at.schrottner.gitlab-repositories")
16 |
17 | then:
18 | project.tasks.findByName("gitLabTask") != null
19 | project.extensions.findByName(GitlabRepositoriesExtension.NAME) != null
20 | project.extensions.findByName(GitlabRepositoriesExtension.NAME).tokens.size() > 0
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/groovy/at/schrottner/gradle/auths/GitLabTokenType.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2021 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v2.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v20.html
9 | */
10 | package at.schrottner.gradle.auths;
11 |
12 | enum GitLabTokenType {
13 | JOB("job", "Job-Token"),
14 | PRIVATE("private", "Private-Token"),
15 | DEPLOY("deploy", "Deploy-Token"),
16 | NO_VALUE("no value", "NO-VALUE")
17 |
18 | String name
19 | String headerName
20 |
21 | GitLabTokenType(String name, String headerName) {
22 | this.name = name
23 | this.headerName = headerName
24 | }
25 |
26 | @Override
27 | String toString() {
28 | return headerName
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/functionalTest/groovy/at/schrottner/gradle/TestFileUtils.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2021 the original author or authors.
3 | *
4 | * All rights reserved. This program and the accompanying materials are
5 | * made available under the terms of the Eclipse Public License v2.0 which
6 | * accompanies this distribution and is available at
7 | *
8 | * http://www.eclipse.org/legal/epl-v20.html
9 | */
10 | package at.schrottner.gradle
11 |
12 | class TestFileUtils {
13 | static File getTestResource(String filePath, String resourcePath) {
14 | File file = new File(filePath)
15 | getTestResource(file, resourcePath)
16 | }
17 |
18 | static File getTestResource(File file, String resourcePath) {
19 | ClassLoader.getSystemClassLoader().getResource(resourcePath).withInputStream { inputStream ->
20 | file.withOutputStream { outputStream ->
21 | outputStream << inputStream
22 | }
23 | }
24 | file
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | on:
2 | push:
3 | # Sequence of patterns matched against refs/tags
4 | tags:
5 | - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
6 |
7 | name: Create Release
8 |
9 | jobs:
10 | # This workflow contains a single job called "build"
11 | build:
12 | # The type of runner that the job will run on
13 | runs-on: ubuntu-latest
14 |
15 | # Steps represent a sequence of tasks that will be executed as part of the job
16 | steps:
17 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
18 | - uses: actions/checkout@v3
19 |
20 | - name: Build
21 | uses: eskatos/gradle-command-action@v2.10.0
22 | env:
23 | TEST_UPLOAD_TOKEN: ${{secrets.TEST_UPLOAD_TOKEN}}
24 | with:
25 | arguments: build publishPlugins -Pgradle.publish.key=${{secrets.GRADLE_PUBLISH_KEY}} -Pgradle.publish.secret=${{secrets.GRADLE_PUBLISH_SECRET}}
--------------------------------------------------------------------------------
/src/functionalTest/groovy/at/schrottner/gradle/PluginTest.java:
--------------------------------------------------------------------------------
1 | package at.schrottner.gradle;
2 |
3 | import org.apiguardian.api.API;
4 | import org.gradle.plugin.devel.tasks.internal.ValidateAction;
5 | import org.junit.jupiter.api.DisplayName;
6 | import org.junit.jupiter.params.ParameterizedTest;
7 | import org.junit.jupiter.params.provider.ArgumentsSource;
8 | import org.junit.platform.commons.annotation.Testable;
9 |
10 | import java.lang.annotation.Documented;
11 | import java.lang.annotation.ElementType;
12 | import java.lang.annotation.Retention;
13 | import java.lang.annotation.RetentionPolicy;
14 | import java.lang.annotation.Target;
15 |
16 | import static org.apiguardian.api.API.Status.STABLE;
17 |
18 | @Target({ ElementType.ANNOTATION_TYPE, ElementType.METHOD })
19 | @Retention(RetentionPolicy.RUNTIME)
20 | @Documented
21 | @API(status = STABLE, since = "5.0")
22 | @ParameterizedTest(name = "{index} Running test for *.{0}")
23 | @ArgumentsSource(PluginTestParams.class)
24 | public @interface PluginTest {
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/ApplyTest/usedInSettingsAndProjectWithoutApplying/groovy/build.gradle:
--------------------------------------------------------------------------------
1 | gitLab {
2 | token(PrivateToken) {
3 | it.key = 'tokenIgnoredNoValue'
4 | it.value = ''
5 | }
6 | token(PrivateToken) {
7 | it.key = 'token0'
8 | it.value = 'test'
9 | }
10 | token(PrivateToken) {
11 | it.key = 'token1'
12 | it.value = 'test'
13 | }
14 | token(DeployToken) {
15 | it.key = 'tokenAdded'
16 | it.value = 'test'
17 | }
18 | }
19 | repositories {
20 | realms.split(',').each { realm ->
21 |
22 | maven gitLab."$realm"("$existingId")
23 | maven gitLab."$realm"("$renamedId") { name = "$realm-renamed" }
24 | maven gitLab."$realm"("specialToken") {
25 | tokenSelector = "token0"
26 | }
27 | maven gitLab."$realm"("specialToken1") {
28 | tokenSelector = "token1"
29 | }
30 | maven gitLab."$realm"("specialTokenSelection") {
31 | tokenSelectors = ["jobToken", "token1"]
32 | }
33 | maven gitLab."$realm"("ignoredNoValue") {
34 | tokenSelector = "tokenIgnoredNoValue"
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/src/functionalTest/resources/UploadTest/uploadtest/groovy/settings.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | dependencies {
3 | classpath files(pluginClasspath.split(','))
4 | }
5 | }
6 | apply plugin: at.schrottner.gradle.GitlabRepositoriesPlugin
7 |
8 | gitLab {
9 | token(PrivateToken) {
10 | it.key = 'tokenIgnoredNoValue'
11 | it.value = ''
12 | }
13 | token(DeployToken) {
14 | it.key = 'token0'
15 | it.value = 'test'
16 | }
17 | token(DeployToken) {
18 | it.key = 'token1'
19 | it.value = 'test'
20 | }
21 | }
22 |
23 | pluginManagement.repositories {
24 | realms.split(',').each { realm ->
25 |
26 | maven gitLab."$realm"("$existingId")
27 | maven gitLab."$realm"("$renamedId") { name = "$realm-renamed" }
28 | maven gitLab."$realm"("specialToken") {
29 | tokenSelector = "token0"
30 | }
31 | maven gitLab."$realm"("specialToken1") {
32 | tokenSelector = "token1"
33 | }
34 | maven gitLab."$realm"("specialTokenSelection") {
35 | tokenSelectors = ["jobToken", "token1"]
36 | }
37 | maven gitLab."$realm"("ignoredNoValue") {
38 | tokenSelector = "tokenIgnoredNoValue"
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/ApplyTest/onlyUsedInSettings/groovy/settings.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | dependencies {
3 | classpath files(pluginClasspath.split(','))
4 | }
5 | }
6 | apply plugin: at.schrottner.gradle.GitlabRepositoriesPlugin
7 |
8 | gitLab {
9 | token(PrivateToken) {
10 | it.key = 'tokenIgnoredNoValue'
11 | it.value = ''
12 | }
13 | token(DeployToken) {
14 | it.key = 'token0'
15 | it.value = 'test'
16 | }
17 | token(DeployToken) {
18 | it.key = 'token1'
19 | it.value = 'test'
20 | }
21 | }
22 |
23 | pluginManagement.repositories {
24 | realms.split(',').each { realm ->
25 |
26 | maven gitLab."$realm"("$existingId")
27 | maven gitLab."$realm"("$renamedId") { name = "$realm-renamed" }
28 | maven gitLab."$realm"("specialToken") {
29 | tokenSelector = "token0"
30 | }
31 | maven gitLab."$realm"("specialToken1") {
32 | tokenSelector = "token1"
33 | }
34 | maven gitLab."$realm"("specialTokenSelection") {
35 | tokenSelectors = ["jobToken", "token1"]
36 | }
37 | maven gitLab."$realm"("ignoredNoValue") {
38 | tokenSelector = "tokenIgnoredNoValue"
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/ApplyTest/usedInSettingsAndProject/groovy/settings.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | dependencies {
3 | classpath files(pluginClasspath.split(','))
4 | }
5 | }
6 | apply plugin: at.schrottner.gradle.GitlabRepositoriesPlugin
7 |
8 | gitLab {
9 | token(PrivateToken) {
10 | it.key = 'tokenIgnoredNoValue'
11 | it.value = ''
12 | }
13 | token(DeployToken) {
14 | it.key = 'token0'
15 | it.value = 'test'
16 | }
17 | token(DeployToken) {
18 | it.key = 'token1'
19 | it.value = 'test'
20 | }
21 | }
22 |
23 | pluginManagement.repositories {
24 | realms.split(',').each { realm ->
25 |
26 | maven gitLab."$realm"("$existingId")
27 | maven gitLab."$realm"("$renamedId") { name = "$realm-renamed" }
28 | maven gitLab."$realm"("specialToken") {
29 | tokenSelector = "token0"
30 | }
31 | maven gitLab."$realm"("specialToken1") {
32 | tokenSelector = "token1"
33 | }
34 | maven gitLab."$realm"("specialTokenSelection") {
35 | tokenSelectors = ["jobToken", "token1"]
36 | }
37 | maven gitLab."$realm"("ignoredNoValue") {
38 | tokenSelector = "tokenIgnoredNoValue"
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/ApplyTest/usedInSettingsAndProjectWithoutApplying/groovy/settings.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | dependencies {
3 | classpath files(pluginClasspath.split(','))
4 | }
5 | }
6 | apply plugin: at.schrottner.gradle.GitlabRepositoriesPlugin
7 |
8 | gitLab {
9 | token(PrivateToken) {
10 | it.key = 'tokenIgnoredNoValue'
11 | it.value = ''
12 | }
13 | token(DeployToken) {
14 | it.key = 'token0'
15 | it.value = 'test'
16 | }
17 | token(DeployToken) {
18 | it.key = 'token1'
19 | it.value = 'test'
20 | }
21 | }
22 |
23 | pluginManagement.repositories {
24 | realms.split(',').each { realm ->
25 |
26 | maven gitLab."$realm"("$existingId")
27 | maven gitLab."$realm"("$renamedId") { name = "$realm-renamed" }
28 | maven gitLab."$realm"("specialToken") {
29 | tokenSelector = "token0"
30 | }
31 | maven gitLab."$realm"("specialToken1") {
32 | tokenSelector = "token1"
33 | }
34 | maven gitLab."$realm"("specialTokenSelection") {
35 | tokenSelectors = ["jobToken", "token1"]
36 | }
37 | maven gitLab."$realm"("ignoredNoValue") {
38 | tokenSelector = "tokenIgnoredNoValue"
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | # This is a basic workflow to help you get started with Actions
2 |
3 | name: CI
4 |
5 | # Controls when the action will run.
6 | on:
7 | # Triggers the workflow on push or pull request events but only for the main branch
8 | push:
9 | branches: [ main ]
10 | pull_request:
11 | branches: [ main ]
12 |
13 | # Allows you to run this workflow manually from the Actions tab
14 | workflow_dispatch:
15 |
16 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel
17 | jobs:
18 | # This workflow contains a single job called "build"
19 | build:
20 | # The type of runner that the job will run on
21 | runs-on: ubuntu-latest
22 |
23 | # Steps represent a sequence of tasks that will be executed as part of the job
24 | steps:
25 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
26 | - uses: actions/checkout@v3
27 |
28 | - name: Build
29 | uses: eskatos/gradle-command-action@v2.10.0
30 | env:
31 | TEST_UPLOAD_TOKEN: ${{secrets.TEST_UPLOAD_TOKEN}}
32 | with:
33 | arguments: build -i
34 |
--------------------------------------------------------------------------------
/src/main/groovy/at/schrottner/gradle/RepositoryConfiguration.groovy:
--------------------------------------------------------------------------------
1 | package at.schrottner.gradle
2 |
3 | import org.gradle.api.Action
4 | import org.gradle.api.artifacts.repositories.RepositoryContentDescriptor
5 | import org.gradle.api.internal.CollectionCallbackActionDecorator
6 | import org.gradle.api.internal.artifacts.BaseRepositoryFactory
7 | import org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler
8 | import org.gradle.api.provider.Property
9 | import org.gradle.api.provider.SetProperty
10 | import org.gradle.internal.reflect.Instantiator
11 |
12 | import javax.inject.Inject
13 |
14 | /**
15 | * Representation of the actual configuration done within the gradle definition
16 | *
17 | * TODO:
18 | * - add ContentFiltering
19 | */
20 | abstract class RepositoryConfiguration {
21 | String id
22 | GitLabEntityType entityType
23 |
24 | @Inject
25 | RepositoryConfiguration(String id, GitLabEntityType entityType) {
26 | this.id = id
27 | this.entityType = entityType
28 | }
29 |
30 | abstract public Property getTokenSelector()
31 |
32 | abstract public SetProperty getTokenSelectors()
33 |
34 | abstract public Property getName()
35 |
36 | }
--------------------------------------------------------------------------------
/src/functionalTest/resources/UploadTest/uploadtest/groovy/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | dependencies {
3 | classpath files(pluginClasspath.split(','))
4 | }
5 | }
6 |
7 | plugins {
8 | id 'maven-publish'
9 | }
10 |
11 | apply plugin: at.schrottner.gradle.GitlabRepositoriesPlugin
12 |
13 | gitLab {
14 | token(PrivateToken) {
15 | it.key = 'testToken'
16 | it.value = System.getenv('TEST_UPLOAD_TOKEN')
17 | }
18 | }
19 |
20 | publishing {
21 | repositories {
22 | maven gitLab.upload("$existingId")
23 | maven gitLab.upload("specialToken") {
24 | tokenSelector = "token0"
25 | }
26 | maven gitLab.upload("specialToken1") {
27 | tokenSelector = "token1"
28 | }
29 | maven gitLab.upload("specialTokenSelection") {
30 | tokenSelectors = ["jobToken", "token1"]
31 | }
32 | maven gitLab.upload("ignoredNoValue") {
33 | tokenSelector = "tokenIgnoredNoValue"
34 | }
35 | maven gitLab.upload("24974077") {
36 | name = "GitLab"
37 | tokenSelector = "testToken"
38 | }
39 | }
40 |
41 | publications {
42 | test(MavenPublication) {
43 | artifactId 'test-file'
44 | groupId 'at.schrottner.test.gitlab-repositories'
45 | version 'test-SNAPSHOT'
46 | artifact source: 'test.xml', classifier: 'features'
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/functionalTest/resources/ApplyTest/onlyUsedInProject/groovy/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | dependencies {
3 | classpath files(pluginClasspath.split(','))
4 | }
5 | }
6 | apply plugin: at.schrottner.gradle.GitlabRepositoriesPlugin
7 |
8 | gitLab {
9 | token(PrivateToken) {
10 | it.key = 'tokenIgnoredNoValue'
11 | it.value = ''
12 | }
13 | token(PrivateToken) {
14 | it.key = 'token0'
15 | it.value = 'test'
16 | }
17 | token(PrivateToken) {
18 | it.key = 'token1'
19 | it.value = 'test'
20 | }
21 | token(DeployToken) {
22 | it.key = 'tokenAdded'
23 | it.value = 'test'
24 | }
25 | }
26 | repositories {
27 | realms.split(',').each { realm ->
28 |
29 | maven gitLab."$realm"("$existingId")
30 | maven gitLab."$realm"("$renamedId") { name = "$realm-renamed" }
31 | maven gitLab."$realm"("specialToken") {
32 | tokenSelector = "token0"
33 | }
34 | maven gitLab."$realm"("specialToken1") {
35 | tokenSelector = "token1"
36 | }
37 | maven gitLab."$realm"("specialTokenSelection") {
38 | tokenSelectors = ["jobToken", "token1"]
39 | }
40 | maven gitLab."$realm"("ignoredNoValue") {
41 | tokenSelector = "tokenIgnoredNoValue"
42 | }
43 | }
44 | }
45 |
46 | configurations {
47 | testing
48 | }
49 |
50 | dependencies {
51 | testing "at.schrottner.test.gitlab-repositories:test-file:test-SNAPSHOT@xml"
52 | }
--------------------------------------------------------------------------------
/src/functionalTest/resources/ApplyTest/usedInSettingsAndProject/groovy/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | dependencies {
3 | classpath files(pluginClasspath.split(','))
4 | }
5 | }
6 | apply plugin: at.schrottner.gradle.GitlabRepositoriesPlugin
7 |
8 | gitLab {
9 | token(PrivateToken) {
10 | it.key = 'tokenIgnoredNoValue'
11 | it.value = ''
12 | }
13 | token(PrivateToken) {
14 | it.key = 'token0'
15 | it.value = 'test'
16 | }
17 | token(PrivateToken) {
18 | it.key = 'token1'
19 | it.value = 'test'
20 | }
21 | token(DeployToken) {
22 | it.key = 'tokenAdded'
23 | it.value = 'test'
24 | }
25 | }
26 | repositories {
27 | realms.split(',').each { realm ->
28 |
29 | maven gitLab."$realm"("$existingId")
30 | maven gitLab."$realm"("$renamedId") { name = "$realm-renamed" }
31 | maven gitLab."$realm"("specialToken") {
32 | tokenSelector = "token0"
33 | }
34 | maven gitLab."$realm"("specialToken1") {
35 | tokenSelector = "token1"
36 | }
37 | maven gitLab."$realm"("specialTokenSelection") {
38 | tokenSelectors = ["jobToken", "token1"]
39 | }
40 | maven gitLab."$realm"("ignoredNoValue") {
41 | tokenSelector = "tokenIgnoredNoValue"
42 | }
43 | }
44 | }
45 |
46 | configurations {
47 | testing
48 | }
49 |
50 | dependencies {
51 | testing "at.schrottner.test.gitlab-repositories:test-file:test-SNAPSHOT@xml"
52 | }
--------------------------------------------------------------------------------
/src/functionalTest/resources/GoogleRecommendationTest/test/groovy/settings.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | dependencies {
3 | classpath files(pluginClasspath.split(','))
4 | }
5 | }
6 | apply plugin: at.schrottner.gradle.GitlabRepositoriesPlugin
7 |
8 | gitLab {
9 | token(PrivateToken) {
10 | it.key = 'tokenIgnoredNoValue'
11 | it.value = ''
12 | }
13 | token(DeployToken) {
14 | it.key = 'token0'
15 | it.value = 'test'
16 | }
17 | token(DeployToken) {
18 | it.key = 'token1'
19 | it.value = 'test'
20 | }
21 | token(PrivateToken) {
22 | it.key = 'testToken'
23 | it.value = System.getenv('TEST_UPLOAD_TOKEN')
24 | }
25 | }
26 |
27 | dependencyResolutionManagement {
28 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
29 | repositories {
30 | google()
31 | mavenCentral()
32 | maven gitLab.project("24974077"){
33 | tokenSelector = "testToken"
34 | }
35 | realms.split(',').each { realm ->
36 |
37 | maven gitLab."$realm"("$existingId")
38 | maven gitLab."$realm"("$renamedId") { name = "$realm-renamed" }
39 | maven gitLab."$realm"("specialToken") {
40 | tokenSelector = "token0"
41 | }
42 | maven gitLab."$realm"("specialToken1") {
43 | tokenSelector = "token1"
44 | }
45 | maven gitLab."$realm"("specialTokenSelection") {
46 | tokenSelectors = ["jobToken", "token1"]
47 | }
48 | maven gitLab."$realm"("ignoredNoValue") {
49 | tokenSelector = "tokenIgnoredNoValue"
50 | }
51 | }
52 | }
53 | }
54 |
55 | include ':app'
--------------------------------------------------------------------------------
/src/functionalTest/resources/UploadTest/uploadtest/kotlin/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import at.schrottner.gradle.auths.*
2 | import at.schrottner.gradle.*
3 |
4 | buildscript {
5 | val pluginClasspath: String by project
6 | dependencies {
7 | classpath(files(pluginClasspath.split(',')))
8 | }
9 | }
10 | plugins {
11 | `maven-publish`
12 | }
13 | apply(plugin = "at.schrottner.gitlab-repositories")
14 |
15 | configure {
16 | token("private", {
17 | key = "testToken"
18 | value = System.getenv("TEST_UPLOAD_TOKEN")
19 | })
20 | }
21 |
22 | publishing {
23 | repositories {
24 | val existingId: String by project
25 | val gitLab = the()
26 | maven(gitLab.upload("$existingId"))
27 | maven(gitLab.upload("specialToken") { tokenSelector.set("token0") })
28 | maven(gitLab.upload("specialToken1") { tokenSelector.set("token1") })
29 | maven(gitLab.upload("specialTokenSelection") { tokenSelectors.addAll("jobToken", "token1") })
30 | maven(gitLab.upload("ignoredNoValue") { tokenSelector.set("tokenIgnoredNoValue") })
31 | maven(gitLab.upload("24974077") {
32 | name.set("GitLab")
33 | tokenSelector.set("testToken")
34 | })
35 | }
36 |
37 | publications {
38 | create("test") {
39 | artifactId = "test-file"
40 | groupId = "at.schrottner.test.gitlab-repositories"
41 | version = "test-kotlin-SNAPSHOT"
42 | artifact("test.xml", {
43 | classifier = "features"
44 | })
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/functionalTest/groovy/at/schrottner/gradle/testhelper/MappedParameterContext.java:
--------------------------------------------------------------------------------
1 | package at.schrottner.gradle.testhelper;
2 |
3 | import org.junit.jupiter.api.extension.ParameterContext;
4 | import org.junit.platform.commons.util.AnnotationUtils;
5 |
6 | import java.lang.annotation.Annotation;
7 | import java.lang.reflect.Parameter;
8 | import java.util.List;
9 | import java.util.Optional;
10 |
11 | public class MappedParameterContext implements ParameterContext {
12 |
13 | private final int index;
14 | private final Parameter parameter;
15 | private final Optional