I want to create jar for my base project with src/main and src/test in the azure devops artifacts so that all other project use code and existing dependacnioes from my base project and we can pramote reusability through base project and avoid code duplication,
I have tried below steps but its not working . I cant see any depedancy added in the based project to another project. Any help highly appreciated. Thanks
task createJar(type: Jar) {
project.logger.lifecycle("Starting Task: createJar")
from sourceSets.test.output
from sourceSets.main.output
}
configurations {
sourcesJar
sourcesTestJar
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
archiveClassifier.set('sources')
}
task sourcesTestJar(type: Jar) {
from sourceSets.test.allSource
archiveClassifier.set('test-sources')
}
artifacts {
sourcesJar sourcesJar
sourcesTestJar sourcesTestJar
}
tasks.withType(Test) {
jvmArgs '-Xmx4096m', '-Xms4096m'
testLogging {
events "FAILED",
"SKIPPED",
"STANDARD_ERROR",
"STANDARD_OUT"
exceptionFormat "FULL"
showCauses true
showExceptions true
showStackTraces true
showStandardStreams true
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourceSets.test.java
groupId = 'com.example'
artifactId = 'your-artifact-id'
version = '1.0.2'
artifact sourcesJar
artifact sourcesTestJar
// Include test sources
}
}
repositories {
maven {
url 'https://pkgs.dev.azure.com/maven/v1'
credentials {
username = ""
password = ""
}
}
}
}