From 254b2417ed1c6fc297482b4b8565c1470d4663c6 Mon Sep 17 00:00:00 2001 From: evanchooly Date: Tue, 29 Aug 2023 23:03:08 -0400 Subject: [PATCH] update tests for new GAVs --- .../build/maven/ReplacementMojoTest.kt | 51 ++++++++----------- .../projects/doubleQuotes/build.gradle.kts | 4 +- .../maven/projects/doubleQuotes/pom.xml | 30 ++--------- .../maven/projects/gradleInvoke/pom.xml | 21 -------- .../maven/projects/noRegex/build.gradle.kts | 4 +- .../maven/projects/properties/pom.xml | 6 --- .../build/GravenLifecycleParticipant.kt | 2 +- 7 files changed, 33 insertions(+), 85 deletions(-) diff --git a/integration-tests/src/test/kotlin/com/antwerkz/build/maven/ReplacementMojoTest.kt b/integration-tests/src/test/kotlin/com/antwerkz/build/maven/ReplacementMojoTest.kt index 40c5032..e6f6e15 100644 --- a/integration-tests/src/test/kotlin/com/antwerkz/build/maven/ReplacementMojoTest.kt +++ b/integration-tests/src/test/kotlin/com/antwerkz/build/maven/ReplacementMojoTest.kt @@ -9,70 +9,63 @@ import org.testng.annotations.Test class ReplacementMojoTest : MavenTester() { @Test fun doubleQuoteUpdates() { - val testDir = initProject("projects/doubleQuotes") + val testDir = initProject("doubleQuotes") - val (result, output) = setupAndInvoke(testDir) + val (result, output) = setupAndInvoke(testDir, listOf("process-sources")) assertEquals(result.exitCode, 0, output.toLogFormat()) val lines = File(testDir, "build.gradle.kts").readLines(Charset.forName("UTF-8")) - assertTrue(lines.any { it.contains("classpath(\"org.apache.maven:maven-model:3.9.1\")") }) + find(lines, "classpath(\"org.apache.maven:maven-model:3.9.1\")") + find(lines, "classpath(\"com.fasterxml.jackson.core:jackson-databind:2.14.1\")") + find(lines, "kotlin(\"jvm\") version \"1.8.10\"") + } + + private fun find(lines: List, target: String) { assertTrue( - lines.any { - it.contains("classpath(\"com.fasterxml.jackson.core:jackson-databind:2.14.1\")") - } + lines.any { it.contains(target) }, + "Can't find:\n$target \nin \n\n" + lines.joinToString("\n", prefix = "\n") ) - assertTrue(lines.any { it.contains("kotlin(\"jvm\") version \"1.8.10\"") }) } @Test fun noRegex() { - val testDir = initProject("projects/noRegex") + val testDir = initProject("noRegex") val (result, output) = setupAndInvoke(testDir) assertEquals(result.exitCode, 0, output.toLogFormat()) val lines = File(testDir, "build.gradle.kts").readLines(Charset.forName("UTF-8")) - assertTrue(lines.any { it.contains("classpath(\"org.apache.maven:maven-model:2.3.1\")") }) - assertTrue( - lines.any { - it.contains("classpath(\"com.fasterxml.jackson.core:jackson-databind:2.14.1\")") - } - ) - assertTrue(lines.any { it.contains("kotlin(\"jvm\") version \"1.6.0\"") }) + find(lines, "classpath(\"org.apache.maven:maven-model:2.3.1\")") + find(lines, "classpath(\"com.fasterxml.jackson.core:jackson-databind:2.14.1\")") + find(lines, "kotlin(\"jvm\") version \"1.6.0\"") } @Test fun properties() { - val testDir = initProject("projects/properties") + val testDir = initProject("properties") val (result, output) = setupAndInvoke(testDir) - assertEquals(result.exitCode, 0) + assertEquals(result.exitCode, 0, output.joinToString("\n", "\n")) val lines = File(testDir, "gradle.properties").readLines(Charset.forName("UTF-8")) - assertTrue(lines.any { it.contains("guava.version=31.1-jre") }) - assertTrue(lines.any { it.contains("testng.version=7.8.0") }) + find(lines, "guava.version=31.1-jre") + find(lines, "testng.version=7.8.0") } @Test fun singleQuoteUpdates() { - val testDir = initProject("projects/singleQuotes") + val testDir = initProject("singleQuotes") val (result, output) = setupAndInvoke(testDir) assertEquals(result.exitCode, 0, output.toLogFormat()) val lines = File(testDir, "build.gradle").readLines(Charset.forName("UTF-8")) - assertTrue( - lines.any { it.contains("implementation('org.apache.maven:maven-model:2.3.1')") } - ) - assertTrue( - lines.any { - it.contains("classpath('com.fasterxml.jackson.core:jackson-databind:2.14.1')") - } - ) - assertTrue(lines.any { it.contains("kotlin('jvm') version '1.8.10'") }) + find(lines, "implementation('org.apache.maven:maven-model:2.3.1')") + find(lines, "classpath('com.fasterxml.jackson.core:jackson-databind:2.14.1')") + find(lines, "kotlin('jvm') version '1.8.10'") } } diff --git a/integration-tests/src/test/resources/maven/projects/doubleQuotes/build.gradle.kts b/integration-tests/src/test/resources/maven/projects/doubleQuotes/build.gradle.kts index 73f881a..964603c 100644 --- a/integration-tests/src/test/resources/maven/projects/doubleQuotes/build.gradle.kts +++ b/integration-tests/src/test/resources/maven/projects/doubleQuotes/build.gradle.kts @@ -1,7 +1,9 @@ +import jdk.tools.jlink.resources.plugins + buildscript { dependencies { classpath("org.apache.maven:maven-model:2.3.1") - classpath("com.fasterxml.jackson.core:jackson-databind:1.0.0") + classpath("com.fasterxml.jackson.core:jackson-databind:2.14.1") } } diff --git a/integration-tests/src/test/resources/maven/projects/doubleQuotes/pom.xml b/integration-tests/src/test/resources/maven/projects/doubleQuotes/pom.xml index 57dd827..4114b91 100644 --- a/integration-tests/src/test/resources/maven/projects/doubleQuotes/pom.xml +++ b/integration-tests/src/test/resources/maven/projects/doubleQuotes/pom.xml @@ -6,6 +6,7 @@ com.antwerkz.graven doubleQuotes infinity + pom 1.8.10 @@ -28,7 +29,7 @@ org.apache.maven maven-model - ${maven.model} + 3.9.1 @@ -38,16 +39,9 @@ com.antwerkz.graven graven ${graven.version} - - - - sync - - - + true - 7.6.1 - ${project.basedir}/build.gradle.kts, ${project.basedir}/gradle.properties + 8.0.2 (kotlin\("jvm"\).*) @@ -56,22 +50,6 @@ - - org.apache.maven.plugins - maven-compiler-plugin - 3.10.1 - - - default-compile - none - - - - default-testCompile - none - - - diff --git a/integration-tests/src/test/resources/maven/projects/gradleInvoke/pom.xml b/integration-tests/src/test/resources/maven/projects/gradleInvoke/pom.xml index a180443..37d739d 100644 --- a/integration-tests/src/test/resources/maven/projects/gradleInvoke/pom.xml +++ b/integration-tests/src/test/resources/maven/projects/gradleInvoke/pom.xml @@ -38,19 +38,6 @@ - - com.antwerkz.graven graven @@ -58,14 +45,6 @@ true 8.0.2 - - - diff --git a/integration-tests/src/test/resources/maven/projects/noRegex/build.gradle.kts b/integration-tests/src/test/resources/maven/projects/noRegex/build.gradle.kts index 655ea27..c00f4f2 100644 --- a/integration-tests/src/test/resources/maven/projects/noRegex/build.gradle.kts +++ b/integration-tests/src/test/resources/maven/projects/noRegex/build.gradle.kts @@ -1,7 +1,9 @@ +import jdk.tools.jlink.resources.plugins + buildscript { dependencies { classpath("org.apache.maven:maven-model:2.3.1") - classpath("com.fasterxml.jackson.core:jackson-databind:1.0.0") + classpath("com.fasterxml.jackson.core:jackson-databind:2.14.1") } } repositories { diff --git a/integration-tests/src/test/resources/maven/projects/properties/pom.xml b/integration-tests/src/test/resources/maven/projects/properties/pom.xml index fe35c9c..7b88139 100644 --- a/integration-tests/src/test/resources/maven/projects/properties/pom.xml +++ b/integration-tests/src/test/resources/maven/projects/properties/pom.xml @@ -33,12 +33,6 @@ - - com.antwerkz.graven - graven-extension - ${graven.version} - true - com.antwerkz.graven graven diff --git a/mojo/src/main/kotlin/com/antwerkz/build/GravenLifecycleParticipant.kt b/mojo/src/main/kotlin/com/antwerkz/build/GravenLifecycleParticipant.kt index e5ed3b8..5d6673e 100644 --- a/mojo/src/main/kotlin/com/antwerkz/build/GravenLifecycleParticipant.kt +++ b/mojo/src/main/kotlin/com/antwerkz/build/GravenLifecycleParticipant.kt @@ -24,7 +24,7 @@ import org.codehaus.plexus.util.xml.Xpp3Dom @Singleton class GravenLifecycleParticipant : AbstractMavenLifecycleParticipant(), LogEnabled { companion object { - val GROUPID = "com.antwerkz.build" + val GROUPID = "com.antwerkz.graven" val ARTIFACTID = "graven" val defaults = listOf(