Skip to content

SBuild-org/sbuild-aether-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SBuild Aether Plugin

Download

The SBuild Aether Plugin can be downloaded from Maven Central.

Building from Source

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.

Configuration

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.

Examples

Minimal example, using Aether to transitively resolve a dependency

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"))
  }
}

Using the container equivalent of Maven

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"))
  }
}

Excluding Dependencies

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)
  )

}
  1. Add the "org.testng:testng:6.8" dependency to the "compile" scope, but exclude "com.beust:jcommander" from the transitive dependendies.

  2. Exclude the "com.beust:jcommander" dependency from all "test"-scoped dependencies.

Disable Transitivity

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")("*:*")
)

Adding a Remote Repository

To use an additional repository (in this example repo.spray.io) use the remoteRepo settings.

import org.sbuild.plugins.aether._
Plugin[Aether]("aether") configure (
  _.copy(remoteRepos = Seq(Repository.Central, "spray::default::http://repo.spray.io"))
)

Changelog

SBuild Aether Plugin 0.1.0 - 2014-02-25

  • Initial release.