This SBuild plugin provides a SchemeHandler which is able to resolve dependencies via Eclipse Aether.
The SBuild Aether Plugin can be downloaded from Maven Central.
You need a recent version of SBuild.
git clone https://github.com/SBuild-org/sbuild-aether-plugin.git cd sbuild-aether-plugin/org.sbuild.plugins.aether sbuild all
You will find the built jar in the directory org.sbuild.plugins.aether/target
.
All configuration classes are located in the org.sbuild.plugins.aether
package.
The main configuration class is Aether
.
For repository configurations, the Repository class is used. For advanced dependency configuration, see the Dependency and Exclude classes.
import de.tototec.sbuild._
@version("0.7.1")
// Add the Aether Plugin to the project.
@classpath("mvn:org.sbuild:org.sbuild.plugins.aether:0.1.0")
class Test(implicit _project: Project) {
import org.sbuild.plugins.aether._
// Enable the Aether Plugin by creating a `"aether"` named instance.
Plugin[Aether]("aether")
// Use the scheme with the same name as the plugin instance.
val dep = "aether:org.testng:testng:6.8"
Target("phony:test-resolve-simple") dependsOn dep exec {
println("Files: " + dep.files.mkString("\n"))
}
}
import de.tototec.sbuild._
@version("0.7.1")
// This adds the Aether plugin to the project
@classpath("org.sbuild.plugins.aether-0.1.0.jar")
class Test(implicit _project: Project) {
import org.sbuild.plugins.aether._
// This enables and configures the Aether plugin
Plugin[Aether]("aether") configure (
_.addDeps("compile")(
// Our compile dependencies
"org.slf4j:slf4j-api:1.7.5",
"org.testng:testng:6.8"
).addDeps("test")(
// Our test dependencies, which also contains the compile deps too
"compile",
"ch.qos.logback:logback-classic:1.0.11"
)
)
Target("phony:test-resolve-compile") dependsOn "aether:compile" exec { ctx: TargetContext =>
println("Files: " + ctx.dependsOn.files.mkString("\n"))
}
Target("phony:test-resolve-test") dependsOn "aether:test" exec { ctx: TargetContext =>
println("Files: " + ctx.dependsOn.files.mkString("\n"))
}
}
You can also exclude dependencies from the transitive dependency graph. Besides the normal exclusions for selective dependencies
known from Maven, you can also
exclude dependencies more generally with the Aether.scopeExcludes
property. That way, you can easily exclude dependencies you have identified to be conflicting, without the need to add the exclude property to each dependency.
import de.tototec.sbuild._
@version("0.7.1")
@classpath("org.sbuild.plugins.aether-0.1.0.jar")
class Test(implicit _project: Project) {
import org.sbuild.plugins.aether._
Plugin[Aether]("aether") configure (
_.addDeps("compile")(
"org.slf4j:slf4j-api:1.7.5",
ArtifactDependency("org.testng", "testng", "6.8", excludes = Seq("com.beust:jcommander")) // (1)
).addDeps("test")(
"compile",
"ch.qos.logback:logback-classic:1.0.11"
).addExcludes("test")("com.beust:jcommander") // (2)
)
}
-
Add the
"org.testng:testng:6.8"
dependency to the"compile"
scope, but exclude"com.beust:jcommander"
from the transitive dependendies. -
Exclude the
"com.beust:jcommander"
dependency from all"test"
-scoped dependencies.
In the Exclude
class, you can use the *
wildcard for the groupId, artifactId or both.
To disable all transitive dependencies of a paritcular dependency:
import org.sbuild.plugins.aether._
Plugin[Aether]("aether") configure (
_.addDeps("compile")(ArtifactDependency("org.testng", "testng", "6.8", excludes = Seq("*:*")))
)
To disable all transitive dependencies for all dependencies of the same scope:
import org.sbuild.plugins.aether._
Plugin[Aether]("aether") configure (
_.addExcludes("compile")("*:*")
)