It has been 2 weeks since I've managed to setup Nexus OSS, Maven and then Gradle to be able to realize the following goals:
Upload files into a corporate Nexus Repository linking them together. So the files must keep a link in order to define a "package" populated by their groupId/artifactId/version.
Download a "package" (set of files) linked together by something (like a POM dependency schema).
Currently, I am able to use Maven and Gradle to upload ONE file on Nexus. Even if I specify dependencies in the POM file or in the build.gradle with Gradle, I am not able to download the file with all of its dependencies at once.
The goal here is only to be able to define a set of component ordered by group/name/version, and be able to download them all at once for one package. This is like version packaging management.
I have look 2 weeks and wasn't able to use Maven or Gradle to achieve these goals. Please can anyone tell me EXACTLY how to use Maven or Gradle to achieve this work ?
This is the POM files i use to link artifactA with artifactB in Maven:
ArtifactA POM file:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groupA</groupId>
<artifactId>artifactA</artifactId>
<version>1.2.4</version>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
</dependencies>
</dependencyManagement>
<distributionManagement>
<repository>
<id>nexus</id>
<name>Nexus Test Repository</name>
<url>http://localhost:7080/repository/content/repositories/releases/</url>
</repository>
</distributionManagement>
</project>
ArtifactB POM file:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groupA</groupId>
<artifactId>artifactB</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>groupA</groupId>
<artifactId>artifactA</artifactId>
<version>1.2.4</version>
<type>jar</type>
</dependency>
</dependencies>
</dependencyManagement>
<distributionManagement>
<repository>
<id>nexus</id>
<name>Nexus Test Repository</name>
<url>http://localhost:7080/repository/content/repositories/releases/</url>
</repository>
</distributionManagement>
</project>
Once I have uploaded A then B using these commands:
mvn deploy:deploy-file \
-Dfile=artifactA_package.jar \
-Dpackaging=jar \
-DpomFile=pomA1.2.4.xml \
-Durl=http://localhost:7080/repository/content/repositories/releases/ \
-DrepositoryId=nexus
mvn deploy:deploy-file \
-Dfile=artifactB_package.jar \
-Dpackaging=jar \
-DpomFile=pomB1.0.0.xml \
-Durl=http://localhost:7080/repository/content/repositories/releases/ \
-DrepositoryId=nexus
The two files are well uploaded on my Nexus repository BUT, even if the artifactB POM file specify a dependency to A, when I download B using this script:
mvn dependency:get \
-Dartifact=groupA:artifactB:1.0.0:jar \
-DremoteRepositories=nexus::default::http://localhost:7080/repository/content/repositories/releases/
Maven only downloads B, but not A. And even if I use this command on B:
mvn dependency:resolve
It tells me something like "dependency: none". So Nexus or Maven is not aware of the dependency from B to A.
Gradle also does not work to achieve my goal when I use this "build.gradle" file:
apply plugin: 'maven'
repositories {
maven {
url "http://localhost:7080/repository/content/groups/public/"
}
}
artifacts {
archives file('artifactB_package.jar')
}
dependencies {
archives files('artifactA_package.jar')
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: "http://localhost:7080/repository/content/repositories/releases/") {
authentication(userName: "deployment", password: "deployment123")
}
pom.project {
groupId "groupA";
artifactId "artifactB";
version "1";
dependencies {
dependency {
groupId "groupA";
artifactId "artifactA";
version "1";
}
}
}
}
}
}
It only uploads B.