@@ -4,6 +4,7 @@ plugins {
4
4
id ' signing'
5
5
id ' jacoco'
6
6
id " com.diffplug.spotless" version " 6.25.0"
7
+ id " net.linguica.maven-settings" version " 0.5"
7
8
}
8
9
9
10
allprojects {
@@ -19,6 +20,12 @@ version = rootProject.file('../VERSION_NUMBER').text.trim()
19
20
def cmakeBuildDir = System . properties[' cmakeBuildDir' ]
20
21
def useCUDA = System . properties[' USE_CUDA' ]
21
22
def useROCM = System . properties[' USE_ROCM' ]
23
+
24
+ def adoArtifact = project. findProperty(' adoArtifact' )
25
+ def adoAccessToken = project. findProperty(' adoAccessToken' )
26
+ // Only publish to ADO feed if all two properties are set
27
+ def publishToAdo = adoArtifact != null && adoAccessToken != null
28
+
22
29
boolean enableTrainingApis = (System . properties[' ENABLE_TRAINING_APIS' ] ?: " 0" ) == " 1"
23
30
def cmakeJavaDir = " ${ cmakeBuildDir} /java"
24
31
def cmakeNativeLibDir = " ${ cmakeJavaDir} /native-lib"
@@ -37,6 +44,11 @@ def trainingDescription = 'ONNX Runtime Training is a training and inference pac
37
44
' (Open Neural Network Exchange) models. This package is targeted for Learning on The Edge aka On-Device Training ' +
38
45
' See https://github.com/microsoft/onnxruntime-training-examples/tree/master/on_device_training for more details.'
39
46
47
+ // We need to have a custom settings.xml so codeql can bypass the need for settings.security.xml
48
+ mavenSettings {
49
+ userSettingsFileName = " ${ projectDir} /settings.xml"
50
+ }
51
+
40
52
java {
41
53
sourceCompatibility = JavaVersion . VERSION_1_8
42
54
targetCompatibility = JavaVersion . VERSION_1_8
@@ -206,9 +218,13 @@ publishing {
206
218
publications {
207
219
maven(MavenPublication ) {
208
220
groupId = project. group
209
- artifactId = mavenArtifactId
210
-
211
- from components. java
221
+ if (publishToAdo) {
222
+ artifactId = ' onnxruntime_gpu'
223
+ artifact (adoArtifact)
224
+ } else {
225
+ artifactId = mavenArtifactId
226
+ from components. java
227
+ }
212
228
pom {
213
229
name = enableTrainingApis ? ' onnxruntime-training' : ' onnx-runtime'
214
230
description = enableTrainingApis ? trainingDescription : defaultDescription
@@ -239,24 +255,41 @@ publishing {
239
255
}
240
256
}
241
257
repositories {
242
- maven {
243
- url ' https://oss.sonatype.org/service/local/staging/deploy/maven2/'
244
- credentials {
245
- username mavenUser
246
- password mavenPwd
258
+ if (publishToAdo) {
259
+ maven {
260
+ url " https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/${ System.getenv('ADOFeedName')} /maven/v1"
261
+ name System . getenv(' ADOFeedName' )
262
+ authentication {
263
+ basic(BasicAuthentication )
264
+ }
265
+ credentials {
266
+ username ' aiinfra'
267
+ password " ${ project.findProperty('adoAccessToken')} "
268
+ }
269
+ }
270
+ } else {
271
+ maven {
272
+ url ' https://oss.sonatype.org/service/local/staging/deploy/maven2/'
273
+ credentials {
274
+ username mavenUser
275
+ password mavenPwd
276
+ }
247
277
}
248
278
}
249
279
}
250
280
}
251
-
252
281
// Generates a task signMavenPublication that will
253
282
// build all artifacts.
254
283
signing {
255
284
// Queries env vars:
256
285
// ORG_GRADLE_PROJECT_signingKey
257
286
// ORG_GRADLE_PROJECT_signingPassword but can be changed to properties
258
- def signingKey = findProperty(" signingKey" )
259
- def signingPassword = findProperty(" signingPassword" )
260
- useInMemoryPgpKeys(signingKey, signingPassword)
261
- sign publishing. publications. maven
287
+ def signingKey = findProperty(" signingKey" )
288
+ def signingPassword = findProperty(" signingPassword" )
289
+ // Skip signing if no key is provided
290
+ if (signingKey != null && signingPassword != null ) {
291
+ useInMemoryPgpKeys(signingKey, signingPassword)
292
+ sign publishing. publications. maven
293
+ sign publishing. publications. mavenAdo
294
+ }
262
295
}
0 commit comments