Skip to content

Commit 29e1391

Browse files
authored
Resolve Gradle dependencies through the azfunc Azure Artifacts feed (#298)
1 parent f6c9681 commit 29e1391

4 files changed

Lines changed: 48 additions & 2 deletions

File tree

‎azdevops-pipeline/build-release-artifacts.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ steps:
2424
jdkArchitectureOption: 'x64'
2525
publishJUnitResults: false
2626
tasks: clean assemble
27+
options: '--init-script init.gradle'
2728
displayName: Assemble durabletask-client and durabletask-azure-functions
2829

2930
# the secring.gpg file is required to sign the artifacts, it's generated from GnuPG, and it's stored in the library of the durabletaskframework ADO
@@ -42,7 +43,7 @@ steps:
4243
jdkVersionOption: '$(jdkVersion)'
4344
jdkArchitectureOption: 'x64'
4445
tasks: publish
45-
options: '-Psigning.keyId=$(gpgSignKey) -Psigning.password=$(gpgSignPassword) -Psigning.secretKeyRingFile=$(gpgSecretFile.secureFilePath)'
46+
options: '--init-script init.gradle -Psigning.keyId=$(gpgSignKey) -Psigning.password=$(gpgSignPassword) -Psigning.secretKeyRingFile=$(gpgSecretFile.secureFilePath)'
4647
displayName: Publish durabletask-client and durabletask-azure-functions
4748

4849
- task: CopyFiles@2

‎eng/templates/build.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
jdkArchitectureOption: 'x64'
2525
publishJUnitResults: false
2626
tasks: clean assemble
27+
options: '--init-script init.gradle'
2728
displayName: Assemble durabletask-client and durabletask-azure-functions and durabletask-azuremanaged
2829

2930
# the secring.gpg file is required to sign the artifacts, it's generated from GnuPG, and it's stored in the library of the durabletaskframework ADO
@@ -42,7 +43,7 @@ jobs:
4243
jdkVersionOption: 1.11
4344
jdkArchitectureOption: 'x64'
4445
tasks: publish
45-
options: '-Psigning.keyId=$(gpgSignKey) -Psigning.password=$(gpgSignPassword) -Psigning.secretKeyRingFile=$(gpgSecretFile.secureFilePath)'
46+
options: '--init-script init.gradle -Psigning.keyId=$(gpgSignKey) -Psigning.password=$(gpgSignPassword) -Psigning.secretKeyRingFile=$(gpgSecretFile.secureFilePath)'
4647
displayName: Publish durabletask-client and durabletask-azure-functions and durabletask-azuremanaged
4748

4849
- task: CopyFiles@2

‎init.gradle‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
allprojects {
2+
def azfuncFeedUrl = 'https://pkgs.dev.azure.com/azfunc/public/_packaging/upstream-public/maven/v1'
3+
def azfuncFeedToken = System.getenv('AZURE_ARTIFACTS_ENV_ACCESS_TOKEN') ?: findProperty('vstsMavenAccessToken')
4+
repositories {
5+
maven {
6+
url azfuncFeedUrl
7+
if (azfuncFeedToken) {
8+
credentials {
9+
username 'Azure DevOps Services'
10+
password azfuncFeedToken
11+
}
12+
}
13+
}
14+
}
15+
// Keep only the Azure Artifacts feed (and MavenLocal); remove every other Maven repository so no
16+
// public repository can bypass the feed.
17+
afterEvaluate { proj ->
18+
def isNonFeedMaven = { repo ->
19+
repo instanceof MavenArtifactRepository &&
20+
repo.name != 'MavenLocal' &&
21+
!repo.url.toString().startsWith(azfuncFeedUrl)
22+
}
23+
proj.repositories.findAll(isNonFeedMaven).each { proj.repositories.remove(it) }
24+
proj.buildscript.repositories.findAll(isNonFeedMaven).each { proj.buildscript.repositories.remove(it) }
25+
}
26+
}

‎settings.gradle‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
pluginManagement {
2+
// Resolve plugins from the Azure Artifacts feed when its token is available; otherwise the public portal.
3+
def azfuncFeedToken = System.getenv('AZURE_ARTIFACTS_ENV_ACCESS_TOKEN') ?: providers.gradleProperty('vstsMavenAccessToken').orNull
4+
repositories {
5+
if (azfuncFeedToken) {
6+
maven {
7+
url 'https://pkgs.dev.azure.com/azfunc/public/_packaging/upstream-public/maven/v1'
8+
credentials {
9+
username 'Azure DevOps Services'
10+
password azfuncFeedToken
11+
}
12+
}
13+
} else {
14+
gradlePluginPortal()
15+
}
16+
}
17+
}
18+
119
rootProject.name = 'durabletask-java'
220

321
include ":client"

0 commit comments

Comments
 (0)