diff --git a/misc/maven-resolver/build.gradle b/misc/maven-resolver/build.gradle index 1f5adc4f61be..edf2610be998 100644 --- a/misc/maven-resolver/build.gradle +++ b/misc/maven-resolver/build.gradle @@ -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' + diff --git a/misc/maven-resolver/src/main/java/org/ballerinalang/maven/MavenResolver.java b/misc/maven-resolver/src/main/java/org/ballerinalang/maven/MavenResolver.java index ec685cb9e891..3318d4f15199 100644 --- a/misc/maven-resolver/src/main/java/org/ballerinalang/maven/MavenResolver.java +++ b/misc/maven-resolver/src/main/java/org/ballerinalang/maven/MavenResolver.java @@ -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"; diff --git a/misc/maven-resolver/src/test/java/org/ballerinalang/maven/MavenResolverTest.java b/misc/maven-resolver/src/test/java/org/ballerinalang/maven/MavenResolverTest.java index 201e537d0300..7ff8b094e201 100644 --- a/misc/maven-resolver/src/test/java/org/ballerinalang/maven/MavenResolverTest.java +++ b/misc/maven-resolver/src/test/java/org/ballerinalang/maven/MavenResolverTest.java @@ -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); @@ -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());