SBuild Aether Plugin

An SBuild Plugin that provides a SchemeHandler based on Eclipse Aether (Maven) to transitively resolve dependencies from Maven repositories.

License

License

GroupId

GroupId

org.sbuild
ArtifactId

ArtifactId

org.sbuild.plugins.aether
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

SBuild Aether Plugin
An SBuild Plugin that provides a SchemeHandler based on Eclipse Aether (Maven) to transitively resolve dependencies from Maven repositories.
Project URL

Project URL

https://github.com/SBuild-org/sbuild-aether-plugin
Source Code Management

Source Code Management

https://github.com/SBuild-org/sbuild-aether-plugin

Download org.sbuild.plugins.aether

How to add to project

<!-- https://jarcasting.com/artifacts/org.sbuild/org.sbuild.plugins.aether/ -->
<dependency>
    <groupId>org.sbuild</groupId>
    <artifactId>org.sbuild.plugins.aether</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.sbuild/org.sbuild.plugins.aether/
implementation 'org.sbuild:org.sbuild.plugins.aether:0.1.0'
// https://jarcasting.com/artifacts/org.sbuild/org.sbuild.plugins.aether/
implementation ("org.sbuild:org.sbuild.plugins.aether:0.1.0")
'org.sbuild:org.sbuild.plugins.aether:jar:0.1.0'
<dependency org="org.sbuild" name="org.sbuild.plugins.aether" rev="0.1.0">
  <artifact name="org.sbuild.plugins.aether" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.sbuild', module='org.sbuild.plugins.aether', version='0.1.0')
)
libraryDependencies += "org.sbuild" % "org.sbuild.plugins.aether" % "0.1.0"
[org.sbuild/org.sbuild.plugins.aether "0.1.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

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.

org.sbuild

SBuild

A magic-free yet powerful Scala-based build tool

Versions

Version
0.1.0