Skip to content

Commit

Permalink
Merge pull request ballerina-platform#41757 from ShammiL/nexus-repo
Browse files Browse the repository at this point in the history
Add WSO2 nexus repo as a remote repository in maven resolver
  • Loading branch information
ShammiL authored Dec 11, 2023
2 parents 4455839 + cad6f09 commit 8b95225
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions misc/maven-resolver/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ dependencies {
implementation "org.apache.maven.resolver:maven-resolver-transport-file:${project.apacheMavenTransportFileVersion}"
implementation "org.apache.maven.resolver:maven-resolver-transport-http:${project.apacheMavenTransportHttpVersion}"
implementation 'me.tongfei:progressbar'

testImplementation 'org.testng:testng'
}

description = 'Ballerina - Maven dependency resolver'

Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public MavenResolver(String targetLocation) {
repositories = new ArrayList<>();
repositories.add(new RemoteRepository.Builder(
"central", "default", "https://repo.maven.apache.org/maven2/").build());
repositories.add(new RemoteRepository.Builder(
"wso2-nexus", "default", "https://maven.wso2.org/nexus/content/groups/public/").build());

String localRepoPath = System.getProperty("user.home") + File.separator + ".m2"
+ File.separator + "repository";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public class MavenResolverTest {
String targetRepo = Paths.get("build").toAbsolutePath().toString() + File.separator + "platform-libs";
String mavenArtifactVersion = "3.6.3";
String cassandraVersion = "0.8.3";
String ballerinaMysqlVersion = "1.2.47";
String commandDistVersion = "0.8.5";
MavenResolver resolver = new MavenResolver(targetRepo);

Expand All @@ -57,13 +57,24 @@ public void testTransitiveDependency() {
}
}

@Test
public void testDependencyFromNexus() {
try {
Dependency dependency = resolver.resolve("io.ballerina.stdlib", "persist.sql-native", "1.2.1", true);
String jarPath = Utils.getJarPath(targetRepo, dependency);
Assert.assertTrue(new File(jarPath).exists());
} catch (MavenResolverException e) {
Assert.fail(e.getMessage());
}
}

@Test
public void testAddRemoteRepository() {
try {
resolver.addRepository("wso2-releases", "http://maven.wso2.org/nexus/content/repositories/releases/");
Dependency dependency = resolver.resolve("org.ballerinalang", "wso2-cassandra",
cassandraVersion, true);
String jarPath = Utils.getJarPath(targetRepo, dependency.getDepedencies().get(0));
Dependency dependency = resolver.resolve("org.ballerinalang", "ballerina-mysql",
ballerinaMysqlVersion, true);
String jarPath = Utils.getJarPath(targetRepo, dependency);
Assert.assertTrue(new File(jarPath).exists());
} catch (MavenResolverException e) {
Assert.fail(e.getMessage());
Expand Down

0 comments on commit 8b95225

Please sign in to comment.