Reputation: 151
Is it possible to conditionally upload jars to artifactory?
I have tried using the Artifactory plugin but that works fine if the case is just to upload a single jar from a build pipeline.
If I also want to upload a test jar, how would that go?
Can I have some configuration specifying which jar should be uploaded? e.g. test jar or the "normal" jar file
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
artifactory {
clientConfig.setIncludeEnvVars(true)
contextUrl = 'https://localhost:8081/artifactory/'
publish {
repository {
repoKey = 'libs-release-local'
username = "${artifactory_user}"
password = "${artifactory_user_password}"
}
defaults {
publications('mavenJava')
publishArtifacts = true
publishPom = true
publishIvy = true
}
}
resolve {
contextUrl = 'https://localhost:8081/artifactory'
repository {
repoKey = 'libs-release-local'
username = "${artifactory_user"
password = "${artifactory_user_password}"
maven = true
}
}
}
Upvotes: 1
Views: 823
Reputation: 23677
To publish classes from your test SourceSet (src/test/
by default), you first need to define a task to create the testJar:
task testJar(type: Jar) {
classifier = 'tests'
from sourceSets.test.output
}
Then add it to your publications
publications {
mavenJava(MavenPublication) {
from components.java
artifact testJar {
classifier "test"
}
}
}
Since you're already publishing publications('mavenJava')
from artifactory, you do not have to make any changes there.
Upvotes: 1