From 66e04598b0a653e924bb5c778564b282b8318780 Mon Sep 17 00:00:00 2001 From: ShammiL Date: Thu, 23 Nov 2023 10:21:38 +0530 Subject: [PATCH 1/5] Add new nexus remote repo --- misc/maven-resolver/build.gradle | 10 ++++--- .../ballerinalang/maven/MavenResolver.java | 2 ++ .../maven/MavenResolverTest.java | 21 ++++++++++---- .../src/test/resources/testng.xml | 28 +++++++++++++++++++ 4 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 misc/maven-resolver/src/test/resources/testng.xml diff --git a/misc/maven-resolver/build.gradle b/misc/maven-resolver/build.gradle index 1f5adc4f61be..bbd3f74eefa5 100644 --- a/misc/maven-resolver/build.gradle +++ b/misc/maven-resolver/build.gradle @@ -17,10 +17,6 @@ apply from: "$rootDir/gradle/javaProject.gradle" -configurations { - implementation.exclude group: "org.slf4j" -} - jar { duplicatesStrategy = DuplicatesStrategy.EXCLUDE manifest { @@ -47,4 +43,10 @@ dependencies { testImplementation 'org.testng:testng' } +test { + useTestNG() { + suites 'src/test/resources/testng.xml' + } +} 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..afd55f6cc1a0 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.9"; String commandDistVersion = "0.8.5"; MavenResolver resolver = new MavenResolver(targetRepo); @@ -57,12 +57,23 @@ 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); + Dependency dependency = resolver.resolve("org.ballerinalang", "ballerina-mysql", + ballerinaMysqlVersion, true); String jarPath = Utils.getJarPath(targetRepo, dependency.getDepedencies().get(0)); Assert.assertTrue(new File(jarPath).exists()); } catch (MavenResolverException e) { @@ -72,8 +83,8 @@ public void testAddRemoteRepository() { @Test public void testAddRemoteRepositoryWithCredentials() { - String username = System.getenv("MAVEN_RESOLVER_USERNAME"); - String password = System.getenv("MAVEN_RESOLVER_PASSWORD"); + String username = System.getenv("publishUser"); + String password = System.getenv("publishPAT"); if (username == null && password == null) { return; } diff --git a/misc/maven-resolver/src/test/resources/testng.xml b/misc/maven-resolver/src/test/resources/testng.xml new file mode 100644 index 000000000000..49a0076a72fd --- /dev/null +++ b/misc/maven-resolver/src/test/resources/testng.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + From 326855e71f675b4d73cf66a258a4ce360a0a3dde Mon Sep 17 00:00:00 2001 From: ShammiL Date: Tue, 28 Nov 2023 10:46:11 +0530 Subject: [PATCH 2/5] Enable maven resolver tests --- compiler/ballerina-lang/build.gradle | 3 +- .../src/main/java/module-info.java | 2 + misc/maven-resolver/build.gradle | 44 ++++++++++++++++++- .../maven/MavenResolverTest.java | 26 +++++------ tests/jballerina-benchmark-test/build.gradle | 1 + 5 files changed, 61 insertions(+), 15 deletions(-) diff --git a/compiler/ballerina-lang/build.gradle b/compiler/ballerina-lang/build.gradle index 28cf03d88f29..8a6caf466691 100644 --- a/compiler/ballerina-lang/build.gradle +++ b/compiler/ballerina-lang/build.gradle @@ -37,7 +37,8 @@ dependencies { testImplementation "org.testng:testng:${project.testngVersion}" testImplementation "org.mockito:mockito-core:${project.mockitoCoreVersion}" testImplementation "org.mockito:mockito-testng:${project.mockitoTestNGVersion}" - testImplementation 'org.apache.commons:commons-lang3' + implementation 'org.apache.commons:commons-lang3:+' + implementation 'org.apache.maven:maven-artifact:+' } description = 'Ballerina - Lang' diff --git a/compiler/ballerina-lang/src/main/java/module-info.java b/compiler/ballerina-lang/src/main/java/module-info.java index 89c5534e5d54..59a4510dc60f 100644 --- a/compiler/ballerina-lang/src/main/java/module-info.java +++ b/compiler/ballerina-lang/src/main/java/module-info.java @@ -13,6 +13,8 @@ requires io.ballerina.toml; requires io.ballerina.central.client; requires io.ballerina.identifier; + requires org.apache.commons.lang3; + requires maven.artifact; exports io.ballerina.compiler.api; exports io.ballerina.compiler.api.symbols; exports io.ballerina.compiler.api.symbols.resourcepath; diff --git a/misc/maven-resolver/build.gradle b/misc/maven-resolver/build.gradle index bbd3f74eefa5..6b0d10042d43 100644 --- a/misc/maven-resolver/build.gradle +++ b/misc/maven-resolver/build.gradle @@ -17,6 +17,18 @@ apply from: "$rootDir/gradle/javaProject.gradle" +configurations { +// implementation.exclude group: "org.slf4j" +// mavenJar +// testRuntimeClasspath { +// extendsFrom runtimeClasspath +// } + slf4jExclusion { + exclude group: 'org.slf4j' + } + testWithSlf4j +} + jar { duplicatesStrategy = DuplicatesStrategy.EXCLUDE manifest { @@ -25,8 +37,27 @@ jar { 'Implementation-Version': version ) } +// from { +// configurations.runtimeClasspath.findAll { file -> +// !(file.group == 'org.slf4j' && (file.module == 'slf4j-api' || file.module == 'slf4j-simple')) +// } +// } +// from { +// configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } - configurations.slf4jExclusion +// } + from(configurations.runtimeClasspath - configurations.slf4jExclusion) +} + +task testJar(type: Jar) { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + manifest { + attributes( + 'Implementation-Title': 'Maven Resolver Tests', + 'Implementation-Version': version + ) + } from { - configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } + configurations.testWithSlf4j } } @@ -40,7 +71,18 @@ 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' +// testImplementation 'org.slf4j:slf4j-api' +// testImplementation 'org.slf4j:slf4j-simple' + + // Define SLF4J dependencies for exclusion +// slf4jExclusion 'org.slf4j:slf4j-api' +// slf4jExclusion 'org.slf4j:slf4j-simple' + // Define SLF4J dependencies for TestNG tests + testWithSlf4j 'org.slf4j:slf4j-api' + testWithSlf4j 'org.slf4j:slf4j-simple' + } test { 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 afd55f6cc1a0..85ddd7abaca9 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 ballerinaMysqlVersion = "1.2.9"; + String ballerinaMysqlVersion = "1.2.47"; String commandDistVersion = "0.8.5"; MavenResolver resolver = new MavenResolver(targetRepo); @@ -68,18 +68,18 @@ public void testDependencyFromNexus() { } } - @Test - public void testAddRemoteRepository() { - try { - resolver.addRepository("wso2-releases", "http://maven.wso2.org/nexus/content/repositories/releases/"); - Dependency dependency = resolver.resolve("org.ballerinalang", "ballerina-mysql", - ballerinaMysqlVersion, true); - String jarPath = Utils.getJarPath(targetRepo, dependency.getDepedencies().get(0)); - 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", "ballerina-libs", +// ballerinaMysqlVersion, true); +// String jarPath = Utils.getJarPath(targetRepo, dependency.getDepedencies().get(0)); +// Assert.assertTrue(new File(jarPath).exists()); +// } catch (MavenResolverException e) { +// Assert.fail(e.getMessage()); +// } +// } @Test public void testAddRemoteRepositoryWithCredentials() { diff --git a/tests/jballerina-benchmark-test/build.gradle b/tests/jballerina-benchmark-test/build.gradle index 27087613bd23..79afbeb7e6a8 100644 --- a/tests/jballerina-benchmark-test/build.gradle +++ b/tests/jballerina-benchmark-test/build.gradle @@ -42,6 +42,7 @@ dependencies { implementation project(':ballerina-runtime') implementation 'org.slf4j:slf4j-api' implementation 'com.github.chewiebug:gcviewer' +// testImplementation "org.apache.maven.resolver:maven-resolver-api:${project.apacheMavenApiVersion}" testImplementation project(path: ':ballerina-test-utils', configuration: 'shadow') testImplementation 'org.testng:testng' From c61bb718e307b92f1a607bb9f9ef00e5c181f7e9 Mon Sep 17 00:00:00 2001 From: ShammiL Date: Wed, 29 Nov 2023 11:00:10 +0530 Subject: [PATCH 3/5] Remove test automation changes --- compiler/ballerina-lang/build.gradle | 3 +- .../src/main/java/module-info.java | 2 - misc/maven-resolver/build.gradle | 46 +------------------ .../maven/MavenResolverTest.java | 24 +++++----- tests/jballerina-benchmark-test/build.gradle | 1 - 5 files changed, 15 insertions(+), 61 deletions(-) diff --git a/compiler/ballerina-lang/build.gradle b/compiler/ballerina-lang/build.gradle index 8a6caf466691..28cf03d88f29 100644 --- a/compiler/ballerina-lang/build.gradle +++ b/compiler/ballerina-lang/build.gradle @@ -37,8 +37,7 @@ dependencies { testImplementation "org.testng:testng:${project.testngVersion}" testImplementation "org.mockito:mockito-core:${project.mockitoCoreVersion}" testImplementation "org.mockito:mockito-testng:${project.mockitoTestNGVersion}" - implementation 'org.apache.commons:commons-lang3:+' - implementation 'org.apache.maven:maven-artifact:+' + testImplementation 'org.apache.commons:commons-lang3' } description = 'Ballerina - Lang' diff --git a/compiler/ballerina-lang/src/main/java/module-info.java b/compiler/ballerina-lang/src/main/java/module-info.java index 59a4510dc60f..89c5534e5d54 100644 --- a/compiler/ballerina-lang/src/main/java/module-info.java +++ b/compiler/ballerina-lang/src/main/java/module-info.java @@ -13,8 +13,6 @@ requires io.ballerina.toml; requires io.ballerina.central.client; requires io.ballerina.identifier; - requires org.apache.commons.lang3; - requires maven.artifact; exports io.ballerina.compiler.api; exports io.ballerina.compiler.api.symbols; exports io.ballerina.compiler.api.symbols.resourcepath; diff --git a/misc/maven-resolver/build.gradle b/misc/maven-resolver/build.gradle index 6b0d10042d43..edf2610be998 100644 --- a/misc/maven-resolver/build.gradle +++ b/misc/maven-resolver/build.gradle @@ -18,15 +18,7 @@ apply from: "$rootDir/gradle/javaProject.gradle" configurations { -// implementation.exclude group: "org.slf4j" -// mavenJar -// testRuntimeClasspath { -// extendsFrom runtimeClasspath -// } - slf4jExclusion { - exclude group: 'org.slf4j' - } - testWithSlf4j + implementation.exclude group: "org.slf4j" } jar { @@ -37,27 +29,8 @@ jar { 'Implementation-Version': version ) } -// from { -// configurations.runtimeClasspath.findAll { file -> -// !(file.group == 'org.slf4j' && (file.module == 'slf4j-api' || file.module == 'slf4j-simple')) -// } -// } -// from { -// configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } - configurations.slf4jExclusion -// } - from(configurations.runtimeClasspath - configurations.slf4jExclusion) -} - -task testJar(type: Jar) { - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - manifest { - attributes( - 'Implementation-Title': 'Maven Resolver Tests', - 'Implementation-Version': version - ) - } from { - configurations.testWithSlf4j + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } } @@ -73,22 +46,7 @@ dependencies { implementation 'me.tongfei:progressbar' testImplementation 'org.testng:testng' -// testImplementation 'org.slf4j:slf4j-api' -// testImplementation 'org.slf4j:slf4j-simple' - - // Define SLF4J dependencies for exclusion -// slf4jExclusion 'org.slf4j:slf4j-api' -// slf4jExclusion 'org.slf4j:slf4j-simple' - // Define SLF4J dependencies for TestNG tests - testWithSlf4j 'org.slf4j:slf4j-api' - testWithSlf4j 'org.slf4j:slf4j-simple' - } -test { - useTestNG() { - suites 'src/test/resources/testng.xml' - } -} description = 'Ballerina - Maven dependency resolver' 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 85ddd7abaca9..d26624b1c648 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 @@ -68,18 +68,18 @@ public void testDependencyFromNexus() { } } -// @Test -// public void testAddRemoteRepository() { -// try { -// resolver.addRepository("wso2-releases", "http://maven.wso2.org/nexus/content/repositories/releases/"); -// Dependency dependency = resolver.resolve("org.ballerinalang", "ballerina-libs", -// ballerinaMysqlVersion, true); -// String jarPath = Utils.getJarPath(targetRepo, dependency.getDepedencies().get(0)); -// 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", "ballerina-mysql", + ballerinaMysqlVersion, true); + String jarPath = Utils.getJarPath(targetRepo, dependency); + Assert.assertTrue(new File(jarPath).exists()); + } catch (MavenResolverException e) { + Assert.fail(e.getMessage()); + } + } @Test public void testAddRemoteRepositoryWithCredentials() { diff --git a/tests/jballerina-benchmark-test/build.gradle b/tests/jballerina-benchmark-test/build.gradle index 79afbeb7e6a8..27087613bd23 100644 --- a/tests/jballerina-benchmark-test/build.gradle +++ b/tests/jballerina-benchmark-test/build.gradle @@ -42,7 +42,6 @@ dependencies { implementation project(':ballerina-runtime') implementation 'org.slf4j:slf4j-api' implementation 'com.github.chewiebug:gcviewer' -// testImplementation "org.apache.maven.resolver:maven-resolver-api:${project.apacheMavenApiVersion}" testImplementation project(path: ':ballerina-test-utils', configuration: 'shadow') testImplementation 'org.testng:testng' From 91d5d1df8df8f02c1ee8db334de22d213a8943bb Mon Sep 17 00:00:00 2001 From: ShammiL Date: Wed, 29 Nov 2023 11:09:40 +0530 Subject: [PATCH 4/5] Remove maven resolver testng xml file --- .../src/test/resources/testng.xml | 28 ------------------- 1 file changed, 28 deletions(-) delete mode 100644 misc/maven-resolver/src/test/resources/testng.xml diff --git a/misc/maven-resolver/src/test/resources/testng.xml b/misc/maven-resolver/src/test/resources/testng.xml deleted file mode 100644 index 49a0076a72fd..000000000000 --- a/misc/maven-resolver/src/test/resources/testng.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - From cad6f0914bacda68bad361c4c445b6c65d86ae40 Mon Sep 17 00:00:00 2001 From: ShammiL Date: Wed, 29 Nov 2023 15:00:20 +0530 Subject: [PATCH 5/5] Revert env variable changes --- .../test/java/org/ballerinalang/maven/MavenResolverTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 d26624b1c648..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 @@ -83,8 +83,8 @@ public void testAddRemoteRepository() { @Test public void testAddRemoteRepositoryWithCredentials() { - String username = System.getenv("publishUser"); - String password = System.getenv("publishPAT"); + String username = System.getenv("MAVEN_RESOLVER_USERNAME"); + String password = System.getenv("MAVEN_RESOLVER_PASSWORD"); if (username == null && password == null) { return; }