Skip to content

Commit

Permalink
Rename settings to avoid conflicts with ScriptedPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ihostage committed Sep 19, 2023
1 parent 2ad73ac commit db2f051
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/main/scala/com/github/sbt/maven/SbtMavenPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ object SbtMavenPlugin extends AutoPlugin {
val mavenVersion = settingKey[String]("Maven version")
val mavenPluginToolsVersion = settingKey[String]("Maven Plugin Tools version")

val ScriptedConf = Configurations.config("scripted-maven").hide
val scriptedClasspath = taskKey[PathFinder]("")
val scriptedLaunchOpts =
val MavenConf = Configurations.config("scripted-maven").hide
val mavenClasspath = taskKey[PathFinder]("")
val mavenLaunchOpts =
settingKey[Seq[String]]("options to pass to jvm launching Maven tasks")
val scripted = inputKey[Unit]("")
}
Expand All @@ -51,7 +51,7 @@ object SbtMavenPlugin extends AutoPlugin {
override lazy val globalSettings: Seq[Setting[?]] = Seq(
mavenVersion := "3.9.4",
mavenPluginToolsVersion := "3.9.0",
scriptedLaunchOpts := Seq()
mavenLaunchOpts := Seq()
)

override lazy val projectSettings: Seq[Setting[?]] =
Expand All @@ -64,14 +64,14 @@ object SbtMavenPlugin extends AutoPlugin {
)

private def scriptedMavenSettings: Seq[Setting[?]] = Seq(
ivyConfigurations += ScriptedConf,
scriptedClasspath := Def.task {
PathFinder(Classpaths.managedJars(ScriptedConf, classpathTypes.value, Keys.update.value).map(_.data))
ivyConfigurations += MavenConf,
mavenClasspath := Def.task {
PathFinder(Classpaths.managedJars(MavenConf, classpathTypes.value, Keys.update.value).map(_.data))
}.value,
scripted / sourceDirectory := sourceDirectory.value / "maven-test",
scripted := scriptedTask.evaluated,
libraryDependencies ++= Seq(
"org.apache.maven" % "apache-maven" % mavenVersion.value % ScriptedConf
"org.apache.maven" % "apache-maven" % mavenVersion.value % MavenConf
)
)

Expand Down Expand Up @@ -189,10 +189,9 @@ object SbtMavenPlugin extends AutoPlugin {

val results = tests.map { directory =>
runTest(
version.value,
directory,
scriptedClasspath.value.get(),
scriptedLaunchOpts.value,
mavenClasspath.value.get(),
mavenLaunchOpts.value,
streams.value.log
)
}
Expand All @@ -206,7 +205,6 @@ object SbtMavenPlugin extends AutoPlugin {
}

private def runTest(
pluginVersion: String,
directory: File,
classpath: Seq[File],
opts: Seq[String],
Expand All @@ -227,8 +225,7 @@ object SbtMavenPlugin extends AutoPlugin {
val args = Seq(
"-cp",
classpath.map(_.getAbsolutePath).mkString(File.pathSeparator),
s"-Dmaven.multiModuleProjectDirectory=${testDir.getAbsolutePath}",
s"-Dplugin.version=${pluginVersion}"
s"-Dmaven.multiModuleProjectDirectory=${testDir.getAbsolutePath}"
) ++
opts ++
Seq(
Expand Down
1 change: 1 addition & 0 deletions src/sbt-test/sbt-maven/simple/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ lazy val root = project
organization := "com.example",
name := "Simple",
mavenPluginGoalPrefix := "simple",
mavenLaunchOpts += version.apply { v => s"-Dplugin.version=$v" }.value,
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.2.16" % Test,
"org.scalatest" %% "scalatest-wordspec" % "3.2.16" % Test,
Expand Down

0 comments on commit db2f051

Please sign in to comment.