Skip to content

Commit

Permalink
update tests for new GAVs
Browse files Browse the repository at this point in the history
  • Loading branch information
evanchooly committed Aug 30, 2023
1 parent 75490d0 commit 254b241
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>, 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'")
}
}
Original file line number Diff line number Diff line change
@@ -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")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<groupId>com.antwerkz.graven</groupId>
<artifactId>doubleQuotes</artifactId>
<version>infinity</version>
<packaging>pom</packaging>

<properties>
<kotlin.version>1.8.10</kotlin.version>
Expand All @@ -28,7 +29,7 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>${maven.model}</version>
<version>3.9.1</version>
</dependency>
</dependencies>

Expand All @@ -38,16 +39,9 @@
<groupId>com.antwerkz.graven</groupId>
<artifactId>graven</artifactId>
<version>${graven.version}</version>
<executions>
<execution>
<goals>
<goal>sync</goal>
</goals>
</execution>
</executions>
<extensions>true</extensions>
<configuration>
<gradleVersion>7.6.1</gradleVersion>
<files>${project.basedir}/build.gradle.kts, ${project.basedir}/gradle.properties</files>
<gradleVersion>8.0.2</gradleVersion>
<replacements>
<replacement>
<pattern>(kotlin\("jvm"\).*)</pattern>
Expand All @@ -56,22 +50,6 @@
</replacements>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<!-- Replacing default-testCompile as it is treated specially by maven -->
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,13 @@

<build>
<plugins>
<!--
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>11</source>
<target>11</target>
<compilerArgument>-proc:none</compilerArgument>
<compilerArgument>-Xlint:deprecation</compilerArgument>
</configuration>
</plugin>
-->

<plugin>
<groupId>com.antwerkz.graven</groupId>
<artifactId>graven</artifactId>
<version>${graven.version}</version>
<extensions>true</extensions>
<configuration>
<gradleVersion>8.0.2</gradleVersion>
<replacements>
<!--
<replacement>
<pattern>(kotlin\("jvm"\).*)</pattern>
<value>kotlin("jvm") version "${kotlin.version}"</value>
</replacement>
-->
</replacements>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@

<build>
<plugins>
<plugin>
<groupId>com.antwerkz.graven</groupId>
<artifactId>graven-extension</artifactId>
<version>${graven.version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>com.antwerkz.graven</groupId>
<artifactId>graven</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 254b241

Please sign in to comment.