I want to create dependancy for base project with src/main and src/test in the azure devops artifacts so that all other project use structure within that project. How to create artifact using gradle 7.6 and use it in the other projects ?
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
Step 1: Create the Base Project
Set up your base project:
Create a new directory for your base project and set up the standard Gradle project structure with src/main/java and src/test/java directories.
Apply the Java plugin:
plugins {
id 'java'
}
Create a custom task for building the combined JAR:
task customJar(type: Jar) {
from sourceSets.main.output
from sourceSets.test.output
archiveClassifier.set('all-in-one')
version = '1.0' // Replace with your desired version
}
Configure the publishing to Azure DevOps Artifacts:
publishing {
publications {
mavenJava(MavenPublication) {
groupId = 'com.example.base' // Replace with your desired group ID for the base project
artifactId = 'base-library' // Replace with your desired artifact ID for the base project
version = customJar.version
artifact customJar
}
}
repositories {
maven {
name = "AzureDevOpsArtifacts"
url = uri("https://pkgs.dev.azure.com/your-organization/_packaging/your-feed/maven/v1") // Replace with your Azure DevOps Artifacts feed URL
credentials {
username = project.findProperty("azureArtifactsUsername") ?: System.getenv("AZURE_ARTIFACTS_USERNAME")
password = project.findProperty("azureArtifactsPassword") ?: System.getenv("AZURE_ARTIFACTS_PASSWORD")
}
}
}
}
Publish the base project artifact:
./gradlew publish
Step 2: Use the Base Project as a Dependency in Other Projects
dependencies {
implementation 'com.example.base:base-library:1.0' // Replace with the appropriate version of the base project
}
Build your other projects to resolve the dependency from Azure DevOps Artifacts:
./gradlew build