Skip to content

SBT plugin that fetches project artifacts, composes jars with source code and aligns sources inside jars for your favorite IDE

License

Notifications You must be signed in to change notification settings

sbt-android-mill/sbt-dependency-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sbt-dependency-manager

Build Status

Short introduction: Simple-build-tool plugin with Eclipse in 5 Minutes on Youtube (demo of one of the first versions) or look at the test project. Please, open test file

What is it? You may fetch SBT project artifacts, compose jars with source code, align sources inside jars for your favorite IDE

It is provide an ability:

  • to fetch all dependency jars (include sbt-dependency-manager itself) to target folder
  • to fetch all dependency jars with sources (include sbt-dependency-manager itself) to target folder
  • to fetch all dependency jars with sources, merge them (include sbt-dependency-manager itself) and save to target folder

If you want to improve it, please send mail to sbt-android-mill at digimead.org. You will be added to the group. Please, feel free to add yourself to authors.

SBT source code is really simple to read and simple to extend :-)

This readme cover all plugin functionality, even if it is written in broken english (would you have preferred well written russian :-) Please, correct it, if you find something inappropriate.

Table of contents

Adding to your project

Create a

  • project/plugins/project/Build.scala - for older simple-build-tool
  • project/project/Build.scala - for newer simple-build-tool

file that looks like the following:

    import sbt._
    object PluginDef extends Build {
      override def projects = Seq(root)
      lazy val root = Project("plugins", file(".")) dependsOn(dm)
      lazy val dm = uri("git://github.com/sbt-android-mill/sbt-dependency-manager.git#0.6.1")
    }

You may find more information about Build.scala at https://github.com/harrah/xsbt/wiki/Plugins

Then in your build.sbt file, simply add:

    sbt.dependency.manager.Plugin.activate

You may find sample project at src/sbt-test/dependency-manager/simple

resolvers += Resolver.url("digimead-ivy", url("http://storage.googleapis.com/ivy.repository.digimead.org/"))(Resolver.defaultIvyPatterns)

resolvers += "digimead-maven" at "http://storage.googleapis.com/maven.repository.digimead.org/"

Usage

By default aligned jars saved to target/deps Change dependenciesPath at your project to something like

    dependenciesPath <<= (target in LocalRootProject) map { _ / "my-align-dir" }

or

    dependenciesPath <<= (baseDirectory) (_ / "my-aling-dir")

Fetch all dependencies

By default sbt-dependency-manager skip "org.scala-lang" and "org.scala-sbt". If you need all dependencies do

    dependencyFilter := Seq()

Filter dependencies

    dependencyFilter <<= (dependencyClasspathNarrow) map { cp =>
      val filter1 = moduleFilter(organization = "org.scala-lang")
      val filter2 = moduleFilter(organization = "org.other")
      val filter3 = moduleFilter(organization = "com.blabla")
      Some(cp.flatMap(_.get(moduleID.key)).filterNot(filter1).filterNot(filter2).filterNot(filter3))
    },

More about module filters look at SBT Wiki

Align project dependencies

  1. Download all project and SBT dependencies, sources, javadocs

  2. Merge code jars with sources

  3. Align sources inside jars

SBT task name

> dependency-fetch-align

It is very useful to develop simple-build-tool plugins. Most SBT source code are unaligned. Original sources saved in root directory of jar, but it binded to different packages. This situation prevent source code lookup in most common situations. This is very annoying. SBT *-sources.jar was mostly useless in development before sbt-dependenc-manager ;-)

Fetch project dependencies with sources to '123' directory

> set dependencyPath <<= baseDirectory map {(f) => f / "123" }
> dependency-fetch-with-sources

Internals

Options

  • dependency-path (dependencyPath) - Target directory for dependency jars
  • dependency-filter (dependencyFilter) - Processing dependencies only with particular sbt.ModuleID
  • dependency-add-custom (dependencyAddCustom) - Add custom(unknown) libraries to results
  • dependency-classpath-narrow (dependencyClasspathNarrow) - Union of dependencyClasspath from Compile and Test configurations
  • dependency-classpath-wide (dependencyClasspathWide) - Union of fullClasspath from Compile and Test configurations
  • dependency-ignore-configurations (dependencyIgnoreConfigurations) - Ignore configurations while lookup, 'test' for example

Tasks

  • dependency-fetch - Fetch project jars. Save result to target directory
  • dependency-fetch-align - Fetch project jars, merge them with source code. Save result to target directory
  • dependency-fetch-with-sources - Fetch project jars, fetch source jars. Save result to target directory

Demonstration

Simple-build-tool plugin with Eclipse in 5 Minutes on Youtube

HD quality Simple-build-tool plugin with Eclipse in 5 Minutes - 60,5Mb

Developing simple SBT plugin in Eclipse IDE with

  • autocomplete
  • sources lookup
  • debug SBT tasks in Eclipse debugger (I asked about debugging in SBT mailing list, but no one can answer. I suspect that others people for debug sbt plugins used print or s.log.debug. lol ;-) )
  • implicit lookup
  • types lookup
  • refactoring support

... and bunch of other standard features

PS sbt-dependency-manager obsoletes capabilities provided by sbt deliver-local + IvyDE or sbteclipse plugin

FAQ

  • I want to fetch artifacts, but SBT try to compile broken code. Process aborted with compilation error.
    sbt> set dependencyClasspathNarrow <<= dependencyClasspath in Compile
    sbt> set dependencyClasspathWide <<= dependencyClasspath in Compile

Authors

  • Alexey Aksenov

License

The sbt-dependency-manager is licensed to you under the terms of the Apache License, version 2.0, a copy of which has been included in the LICENSE file.

Copyright

Copyright © 2012-2013 Alexey B. Aksenov/Ezh. All rights reserved.

About

SBT plugin that fetches project artifacts, composes jars with source code and aligns sources inside jars for your favorite IDE

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages