Skip to content

Commit

Permalink
dynamic executions are running. still need to add some.
Browse files Browse the repository at this point in the history
  • Loading branch information
evanchooly committed Aug 28, 2023
1 parent 718f471 commit f2dfa4a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,6 @@ open class MavenTester {
return model.version
}

/*
fun initProject(name: String): File {
val tc = File("target/test-classes/maven")
if (!tc.isDirectory) {
LOG.info("$tc created? ${tc.mkdirs()}")
}
val projectRoot = File(tc, name)
if (!projectRoot.exists()) {
throw RuntimeException("Cannot find directory: " + projectRoot.absolutePath)
}
if (!projectRoot.isDirectory) {
throw RuntimeException("Not a project directory: " + projectRoot.absolutePath)
}
return projectRoot
}
*/

fun getTargetDir(name: String): File {
return File("target/test-projects/$name")
}
Expand Down Expand Up @@ -143,7 +126,7 @@ open class MavenTester {

protected fun setupAndInvoke(
testDir: File,
goals: List<String> = listOf("clean", "compile"),
goals: List<String> = listOf("clean", "test-compile"),
quiet: Boolean = false,
params: Properties = Properties(),
): Pair<InvocationResult, List<String>> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version = 0.1.0-SNAPSHOT
morphia.version = 123
critter.version = 123
testng.version = 123
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<kotlin.version>1.8.10</kotlin.version>
<morphia.version>2.3.5</morphia.version>
<critter.version>4.4.4</critter.version>
<testng.version>7.8.0</testng.version>
<maven.model>3.9.1</maven.model>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.antwerkz.build

class DummyTest {

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,22 @@ class GravenLifecycleParticipant : AbstractMavenLifecycleParticipant(), LogEnabl
val GROUPID = "com.antwerkz.build"
val ARTIFACTID = "graven"
val defaults =
listOf<PluginReplacement>(
// PluginReplacement(
// "org.apache.maven.plugins",
// "maven-compiler-plugin",
// "classes",
// "default-compile"
// ),
// PluginReplacement(
// "org.apache.maven.plugins",
// "maven-compiler-plugin",
// "testClasses",
// "default-testCompile"
// ),
)
listOf(
PluginReplacement(
"org.apache.maven.plugins",
"maven-compiler-plugin",
"testClasses",
"test-compile",
"default-testCompile"
),
PluginReplacement(
"org.apache.maven.plugins",
"maven-compiler-plugin",
"classes",
"compile",
"default-compile"
),
)
}
private var logger: Logger? = null

Expand Down Expand Up @@ -89,14 +91,12 @@ class GravenLifecycleParticipant : AbstractMavenLifecycleParticipant(), LogEnabl
var config = XmlMapper().readValue(configuration.toString(), GravenConfig::class.java)
defaults.forEach { replacement ->
findPluginByGA(model, replacement.groupId, replacement.artifactId)?.let { target ->
var oldExecution = target.executions.first { it.id == replacement.executionId }
target.executions.remove(oldExecution)

target.executions.remove(target.executions.first { it.id == replacement.executionId })
plugin.executions.add(
PluginExecution().also {
it.id = "injected-graven-${target.key}"
it.id = "injected-graven-${replacement.phase}-${target.key}"
it.goals.add(GradleInvocationMojo.MOJO_NAME)
it.phase = oldExecution.phase
it.phase = target.executions.first { it.id == replacement.executionId }.phase
it.configuration =
configure(mapOf("task" to mapOf("name" to replacement.gradleTask)))
}
Expand All @@ -111,10 +111,9 @@ class GravenLifecycleParticipant : AbstractMavenLifecycleParticipant(), LogEnabl
protected fun findGravenPlugin(model: Model) = findPluginByGA(model, GROUPID, ARTIFACTID)

private fun findPluginByGA(model: Model, groupId: String, artifactId: String): Plugin? {
return model.build
?.plugins
?.filter { plugin -> (groupId == plugin.groupId) && (artifactId == plugin.artifactId) }
?.first()
return model.build?.plugins?.firstOrNull { plugin ->
(groupId == plugin.groupId) && (artifactId == plugin.artifactId)
}
}

private fun Xpp3Dom.addChildren(children: Map<*, *>): Xpp3Dom {
Expand Down

0 comments on commit f2dfa4a

Please sign in to comment.