From 1411baf69c0bd9a84e9f5fe18bff5077f3b7e936 Mon Sep 17 00:00:00 2001 From: Joseph Price Date: Tue, 15 Dec 2020 18:40:19 -0500 Subject: [PATCH] fix warnings --- build.sbt | 6 +- project/build.properties | 3 +- project/plugins.sbt | 4 - src/main/scala/GroovyC.scala | 7 +- src/main/scala/GroovyPlugin.scala | 120 ++++++++++++------------ src/sbt-test/sbt-groovy/basic/build.sbt | 2 + src/sbt-test/sbt-groovy/basic/test | 2 +- 7 files changed, 71 insertions(+), 73 deletions(-) diff --git a/build.sbt b/build.sbt index 453ff03..5e7a08f 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,4 @@ -sbtPlugin := true +enablePlugins(SbtPlugin) name := "sbt-groovy" @@ -6,7 +6,7 @@ organization := "org.softnetwork.sbt.plugins" version := "0.1.4-SNAPSHOT" -scalaVersion := "2.10.6" +scalaVersion := "2.12.11" publishMavenStyle := true @@ -43,8 +43,6 @@ pomExtra := ( ) -ScriptedPlugin.scriptedSettings - scriptedLaunchOpts ++= Seq( "-Xmx2048M", "-XX:MaxMetaspaceSize=512M", diff --git a/project/build.properties b/project/build.properties index 199daa2..7de0a93 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1,2 +1 @@ -sbtVersion=0.13.11 - +sbt.version=1.4.4 diff --git a/project/plugins.sbt b/project/plugins.sbt index ff17afc..8b13789 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1 @@ -addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.3.0") - -libraryDependencies += "org.scala-sbt" % "scripted-plugin" % sbtVersion.value - diff --git a/src/main/scala/GroovyC.scala b/src/main/scala/GroovyC.scala index ef479a5..389cb45 100644 --- a/src/main/scala/GroovyC.scala +++ b/src/main/scala/GroovyC.scala @@ -2,8 +2,7 @@ package org.softnetwork.sbt.plugins import sbt._ import java.io.File - -import sbt.classpath.ClasspathUtilities +import sbt.internal.inc.classpath.ClasspathUtilities class GroovyC(val classpath : Seq[File], val sourceDirectory : File, val stubDirectory : File, val destinationDirectory : File) { @@ -49,8 +48,8 @@ class GroovyC(val classpath : Seq[File], val sourceDirectory : File, val stubDir executeGroovycMethod.invoke(groovyc) } finally{ - //Thread.currentThread.setContextClassLoader(oldContextClassLoader) + //Thread.currentThread.setContextClassLoader(oldContextClassLoader) } } -} \ No newline at end of file +} diff --git a/src/main/scala/GroovyPlugin.scala b/src/main/scala/GroovyPlugin.scala index 98bd46d..428d3c7 100644 --- a/src/main/scala/GroovyPlugin.scala +++ b/src/main/scala/GroovyPlugin.scala @@ -26,8 +26,8 @@ object GroovyPlugin extends AutoPlugin { self => "org.codehaus.groovy" % "groovy-all" % groovyVersion.value % config.name, "org.apache.ant" % "ant" % "1.8.4" % config.name ), - managedClasspath in groovyc <<= (classpathTypes in groovyc, update) map { (ct, report) => - Classpaths.managedJars(config, ct, report) + managedClasspath in groovyc := { + Classpaths.managedJars(config, (classpathTypes in groovyc).value, update.value) } ) @@ -42,38 +42,39 @@ object GroovyPlugin extends AutoPlugin { self => groovySource in Compile := (sourceDirectory in Compile).value / "groovy", unmanagedSourceDirectories in Compile += {(groovySource in Compile).value}, classDirectory in (Groovy , groovyc) := (crossTarget in Compile).value / "groovy-classes", - managedClasspath in groovyc <<= (classpathTypes in groovyc, update) map { (ct, report) => - Classpaths.managedJars(Groovy, ct, report) + managedClasspath in groovyc := { + Classpaths.managedJars(Groovy, (classpathTypes in groovyc).value, update.value) }, - groovyc in Compile := { + groovyc in Compile := Def.taskDyn { val sourceDirectory : File = (groovySource in Compile).value - val nb = (sourceDirectory ** "*.groovy").get.size - if(nb > 0){ - val s: TaskStreams = streams.value - s.log.info(s"Start Compiling Groovy sources : ${sourceDirectory.getAbsolutePath} ") - - val classDirectories: Seq[File] = classDirectory.all(compileFilter).value ++ - classDirectory.all(groovycFilter).value ++ - Seq((classDirectory in Compile).value) - - val classpath : Seq[File] = (managedClasspath in groovyc).value.files ++ classDirectories ++ (managedClasspath in Compile).value.files - s.log.debug(classpath.mkString(";")) - val stubDirectory : File = (sourceManaged in Compile).value - val destinationDirectory : File = (classDirectory in (Groovy, groovyc)).value - - new GroovyC(classpath, sourceDirectory, stubDirectory, destinationDirectory).compile() - - ((destinationDirectory ** "*.class").get pair relativeTo(destinationDirectory)).map{case(k,v) => - IO.copyFile(k, (resourceManaged in Compile).value / v, preserveLastModified = true) - (resourceManaged in Compile).value / v + val s: TaskStreams = streams.value + Def.taskIf { + val nb = (sourceDirectory ** "*.groovy").get.size + if (nb > 0) { + s.log.info(s"Start Compiling Groovy sources : ${sourceDirectory.getAbsolutePath} ") + + val classDirectories: Seq[File] = classDirectory.all(compileFilter).value ++ + classDirectory.all(groovycFilter).value ++ + Seq((classDirectory in Compile).value) + + val classpath : Seq[File] = (managedClasspath in groovyc).value.files ++ classDirectories ++ (managedClasspath in Compile).value.files + s.log.debug(classpath.mkString(";")) + val stubDirectory : File = (sourceManaged in Compile).value + val destinationDirectory : File = (classDirectory in (Groovy, groovyc)).value + + new GroovyC(classpath, sourceDirectory, stubDirectory, destinationDirectory).compile() + + ((destinationDirectory ** "*.class").get pair relativeTo(destinationDirectory)).map{case(k,v) => + IO.copyFile(k, (resourceManaged in Compile).value / v, preserveLastModified = true) + (resourceManaged in Compile).value / v + } + } else { + Seq.empty } } - else{ - Seq.empty - } - }, - resourceGenerators in Compile <+= groovyc in Compile, - groovyc in Compile <<= (groovyc in Compile) dependsOn (compile in Compile) + }.value, + resourceGenerators in Compile += (groovyc in Compile), + groovyc in Compile := (groovyc in Compile).dependsOn(compile in Compile).value ) } @@ -84,48 +85,51 @@ object GroovyPlugin extends AutoPlugin { self => lazy val compileTestFilter : ScopeFilter = ScopeFilter(inDependencies(ThisProject, transitive = true, includeRoot = false), inConfigurations(Test)) lazy val settings = Seq(ivyConfigurations += GroovyTest) ++ inConfig(GroovyTest)(Defaults.testTasks ++ Seq( - definedTests <<= definedTests in Test, - definedTestNames <<= definedTestNames in Test, - fullClasspath <<= fullClasspath in Test)) ++ defaultSettings(GroovyTest) ++ Seq( + definedTests := (definedTests in Test).value, + definedTestNames := (definedTestNames in Test).value, + fullClasspath := (fullClasspath in Test).value + )) ++ defaultSettings(GroovyTest) ++ Seq( groovySource in Test := (sourceDirectory in Test).value / "groovy", unmanagedSourceDirectories in Test += {(groovySource in Test).value}, classDirectory in (GroovyTest, groovyc) := (crossTarget in Test).value / "groovy-test-classes", - managedClasspath in groovyc <<= (classpathTypes in groovyc, update) map { (ct, report) => - Classpaths.managedJars(GroovyTest, ct, report) + managedClasspath in groovyc := { + Classpaths.managedJars(GroovyTest, (classpathTypes in groovyc).value, update.value) }, - groovyc in Test := { + groovyc in Test := Def.taskDyn { val sourceDirectory : File = (groovySource in Test).value - val nb = (sourceDirectory ** "*.groovy").get.size - if(nb > 0){ - val s: TaskStreams = streams.value - s.log.info(s"Start Compiling Test Groovy sources : ${sourceDirectory.getAbsolutePath} ") + val s: TaskStreams = streams.value + Def.taskIf { + val nb = (sourceDirectory ** "*.groovy").get.size + if(nb > 0){ + s.log.info(s"Start Compiling Test Groovy sources : ${sourceDirectory.getAbsolutePath} ") - val classDirectories: Seq[File] = classDirectory.all(groovy.compileFilter).value ++ - classDirectory.all(groovy.groovycFilter).value ++ classDirectory.all(compileTestFilter).value ++ - classDirectory.all(groovycTestFilter).value ++ - Seq((classDirectory in Compile).value, (classDirectory in (Groovy, groovyc)).value) + val classDirectories: Seq[File] = classDirectory.all(groovy.compileFilter).value ++ + classDirectory.all(groovy.groovycFilter).value ++ classDirectory.all(compileTestFilter).value ++ + classDirectory.all(groovycTestFilter).value ++ + Seq((classDirectory in Compile).value, (classDirectory in (Groovy, groovyc)).value) - val classpath : Seq[File] = (managedClasspath in groovyc).value.files ++ classDirectories ++ (managedClasspath in Test).value.files - s.log.debug(classpath.mkString(";")) + val classpath : Seq[File] = (managedClasspath in groovyc).value.files ++ classDirectories ++ (managedClasspath in Test).value.files + s.log.debug(classpath.mkString(";")) - val stubDirectory : File = (sourceManaged in Test).value + val stubDirectory : File = (sourceManaged in Test).value - val destinationDirectory : File = (classDirectory in (GroovyTest, groovyc)).value + val destinationDirectory : File = (classDirectory in (GroovyTest, groovyc)).value - new GroovyC(classpath, sourceDirectory, stubDirectory, destinationDirectory).compile() + new GroovyC(classpath, sourceDirectory, stubDirectory, destinationDirectory).compile() - ((destinationDirectory ** "*.class").get pair relativeTo(destinationDirectory)).map{case(k,v) => - IO.copyFile(k, (resourceManaged in Test).value / v, preserveLastModified = true) - (resourceManaged in Test).value / v + ((destinationDirectory ** "*.class").get pair relativeTo(destinationDirectory)).map{case(k,v) => + IO.copyFile(k, (resourceManaged in Test).value / v, preserveLastModified = true) + (resourceManaged in Test).value / v + } + } + else{ + Seq.empty } } - else{ - Seq.empty - } - }, - resourceGenerators in Test <+= groovyc in Test, - groovyc in Test <<= (groovyc in Test) dependsOn (compile in Test) + }.value, + resourceGenerators in Test += (groovyc in Test), + groovyc in Test := (groovyc in Test).dependsOn(compile in Test).value ) } } diff --git a/src/sbt-test/sbt-groovy/basic/build.sbt b/src/sbt-test/sbt-groovy/basic/build.sbt index 809743a..3022f73 100644 --- a/src/sbt-test/sbt-groovy/basic/build.sbt +++ b/src/sbt-test/sbt-groovy/basic/build.sbt @@ -4,3 +4,5 @@ enablePlugins(GroovyPlugin) configs(Groovy, GroovyTest) +scalaVersion := "2.12.11" + diff --git a/src/sbt-test/sbt-groovy/basic/test b/src/sbt-test/sbt-groovy/basic/test index aa5b81e..b6f8565 100644 --- a/src/sbt-test/sbt-groovy/basic/test +++ b/src/sbt-test/sbt-groovy/basic/test @@ -1,2 +1,2 @@ > groovyc -$ exists target/scala-2.10/groovy-classes/test/SomeClass.class +$ exists target/scala-2.12/groovy-classes/test/SomeClass.class