Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
joprice committed Dec 15, 2020
1 parent b667005 commit 6b06ffe
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ project/plugins/project/
.idea

*.swp

.bsp/
6 changes: 2 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
sbtPlugin := true
enablePlugins(SbtPlugin)

name := "sbt-groovy"

organization := "org.softnetwork.sbt.plugins"

version := "0.1.4-SNAPSHOT"

scalaVersion := "2.10.6"
scalaVersion := "2.12.11"

publishMavenStyle := true

Expand Down Expand Up @@ -43,8 +43,6 @@ pomExtra := (
</developer>
</developers>)

ScriptedPlugin.scriptedSettings

scriptedLaunchOpts ++= Seq(
"-Xmx2048M",
"-XX:MaxMetaspaceSize=512M",
Expand Down
3 changes: 1 addition & 2 deletions project/build.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
sbtVersion=0.13.11

sbt.version=1.4.4
4 changes: 0 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.3.0")

libraryDependencies += "org.scala-sbt" % "scripted-plugin" % sbtVersion.value

7 changes: 3 additions & 4 deletions src/main/scala/GroovyC.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -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)
}
}

}
}
120 changes: 62 additions & 58 deletions src/main/scala/GroovyPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
)

Expand All @@ -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
)
}

Expand All @@ -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
)
}
}
2 changes: 2 additions & 0 deletions src/sbt-test/sbt-groovy/basic/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ enablePlugins(GroovyPlugin)

configs(Groovy, GroovyTest)

scalaVersion := "2.12.11"

2 changes: 1 addition & 1 deletion src/sbt-test/sbt-groovy/basic/test
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6b06ffe

Please sign in to comment.