2018-11-20 13:15:26 +01:00
package coursier.sbtcoursiershared
2018-11-20 17:17:53 +01:00
import coursier.core. { Configuration , Project , Publication }
2018-11-20 17:39:19 +01:00
import coursier.lmcoursier.SbtCoursierCache
2018-11-20 17:17:53 +01:00
import sbt. { AutoPlugin , Compile , Setting , TaskKey , Test , settingKey }
2018-11-20 17:49:20 +01:00
import sbt.Keys. { classpathTypes , clean }
2018-11-20 13:15:26 +01:00
object SbtCoursierShared extends AutoPlugin {
override def trigger = allRequirements
override def requires = sbt . plugins . JvmPlugin
object autoImport {
2018-11-20 17:17:53 +01:00
val coursierGenerateIvyXml = settingKey [ Boolean ] ( "" )
2018-11-20 13:15:26 +01:00
val coursierProject = TaskKey [ Project ] ( "coursier-project" )
val coursierInterProjectDependencies = TaskKey [ Seq [ Project ] ] ( "coursier-inter-project-dependencies" , "Projects the current project depends on, possibly transitively" )
2018-11-20 17:17:53 +01:00
val coursierPublications = TaskKey [ Seq [ ( Configuration , Publication ) ] ] ( "coursier-publications" )
2018-11-20 13:15:26 +01:00
}
import autoImport._
2018-11-20 17:17:53 +01:00
def publicationsSetting ( packageConfigs : Seq [ ( sbt . Configuration , Configuration ) ] ) : Setting [ _ ] =
coursierPublications : = ArtifactsTasks . coursierPublicationsTask ( packageConfigs : _ * ) . value
override def projectSettings =
Seq [ Setting [ _ ] ] (
2018-11-20 17:39:19 +01:00
clean : = {
val noWarningPlz = clean . value
SbtCoursierCache . default . clear ( )
} ,
2018-11-20 17:17:53 +01:00
coursierGenerateIvyXml : = true ,
coursierProject : = InputsTasks . coursierProjectTask . value ,
coursierInterProjectDependencies : = InputsTasks . coursierInterProjectDependenciesTask . value ,
2018-11-20 17:49:20 +01:00
publicationsSetting ( Seq ( Compile , Test ) . map ( c => c -> Configuration ( c . name ) ) ) ,
// Tests artifacts from Maven repositories are given this type.
// Adding it here so that these work straightaway.
classpathTypes += "test-jar"
2018-11-20 17:17:53 +01:00
) ++
IvyXml . generateIvyXmlSettings ( )
2018-11-20 13:15:26 +01:00
}