Giter VIP home page Giter VIP logo

sbt-ant's Introduction

ant4sbt - Calling Ant from within SBT

This SBT plug-in enables you to integrate Ant targets and Ant properties with your sbt build.

It is available for SBT 0.13.

Getting ant4sbt

ant4sbt is hosted at the Typesafe sbt Community Plugin Repository. This repository is automatically available from within SBT. This means that you just have to add ant4sbt as a plug-in to your project (see the next section).

If you want to go bleeding edge, you can also:

git clone http://github.com/sbt/ant4sbt.git
cd ant4sbt
sbt publish-local

Adding ant4sbt as a plug-in to your project

Add the following to your project's build.sbt file:

import de.johoop.ant4sbt.Ant4Sbt._

antSettings

Also, you have to add the plugin dependency to your project's ./project/plugins.sbt or the global .sbt/0.13/plugins/build.sbt:

addSbtPlugin("de.johoop" % "ant4sbt" % "1.1.2")

Using ant4sbt

ant4sbt adds the following tasks by default:

antRun

This is an input task that takes ant targets as arguments. It works exactly like ant would from the command line...

Example: antRun clean compile

antProperty

This is an input task that takes the name of an Ant property as argument and will return the value of this property.

Example: show antProperty os.name

Controlling the Ant Build Server

There are also a few tasks to manually start, stop and restart the embedded "Ant Build Server": They are called antStartServer, antStopServer and antRestartServer.

Whenever you change your Ant build file, you will have to restart the Ant Build Server or reload your SBT project configuration.

The Ant Build Server will automatically shutdown when you leave SBT interactive mode (or when your SBT command task ends).

Importing Ant targets and properties as SBT tasks

Instead of using the input tasks above, you can also import Ant targets and Ant properties into your SBT build, so that they are directly available as SBT tasks. This is especially useful if you want to depend on these tasks, or if you want these tasks to depend on other SBT tasks.

addAntTasks()

Add addAntTasks("targetA", "targetB", "targetC") to your build.sbt to import the ant targets targetA, targetB and targetC into your build.

These targets are then known to SBT as antRunTargetA, antRunTargetB and antRunTargetC, respectively.

In build.sbt, these tasks are known as antTaskKey("targetA") etc.

For example, you could now add stuff like the following to your settings:

TaskKey[Unit]("depends-on-ant-compile") <<= antTaskKey("compile") map { meep => () }

addAntProperties()

Add addAntProperties(propA, propB) to your build.sbt to import the Ant properties propA and propB into your build.

These properties are then known to SBT as antPropertyPropA and antPropertyPropB, respectively.

In build.sbt, these tasks are known as antPropertyKey("propA") etc.

See also above. They work like the imported Ant targets.

Configuration Settings

The following settings are also available in order to configure the plug-in:

antBuildFile

  • Description: Location of the Ant build file (usually named build.xml)
  • Accepts: File
  • Default: baseDirectory / "build.xml"

antBaseDir

  • Description: Base directory for the Ant build.
  • Accepts: File
  • Default: baseDirectory

antOptions

  • Description: Additional JVM options for Ant (ANT_OPTS).
  • Accepts: Seq[String]
  • Default: $ANT_OPTS, split up by spaces

antServerPort

  • Description: Port the Ant Build Server should listen at..
  • Accepts: Int
  • Default: 21345

License

This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html

sbt-ant's People

Contributors

asflierl avatar jmhofer avatar tkmtmkt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sbt-ant's Issues

Ant4sbt plugin breaks Java Play sbt builds

Hi, I am using Java Play framework, which is built on SBT, and wanted to add the ant4sbt to my sbt build. When I try to do that, the sbt build immediately throws errors. Other SBT plugins that I am using are not causing the same problems with Play. I don't know enough about SBT to be able to debug it myself, but I am happy to provide debug information and test.

The minimal example setup is on https://github.com/myrosia/ant4sbt-play-test

Here is my build.sbt

name := """play-with-ant"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayJava)

scalaVersion := "2.11.1"

libraryDependencies ++= Seq(
  javaJdbc,
  javaEbean,
  cache,
  javaWs
)

antSettings

If I comment out the antSettings line, play compilation works:

activator clean compile assets
[info] Loading project definition from /disk/scratch/tmp/play/play-with-ant/project
[info] Set current project to play-with-ant (in build file:/disk/scratch/tmp/play/play-with-ant/)
[success] Total time: 0 s, completed 1 квіт 2015 16:40:46
[info] Updating {file:/disk/scratch/tmp/play/play-with-ant/}root...
[info] Resolving jline#jline;2.11 ...
[info] Done updating.
[info] Compiling 4 Scala sources and 2 Java sources to /disk/scratch/tmp/play/play-with-ant/target/scala-2.11/classes...
[success] Total time: 12 s, completed 1 квіт 2015 16:40:57
[info] JavaScript linting on 1 source(s)
[success] Total time: 2 s, completed 1 квіт 2015 16:41:00

But as soon as I add the antSettings line, I get an error:

activator clean compile assets
[info] Loading project definition from /disk/scratch/tmp/play/play-with-ant/project
[info] Set current project to play-with-ant (in build file:/disk/scratch/tmp/play/play-with-ant/)
[success] Total time: 0 s, completed 1 квіт 2015 16:49:39
[info] Updating {file:/disk/scratch/tmp/play/play-with-ant/}root...
[info] Resolving jline#jline;2.11 ...
[info] Done updating.
[info] Compiling 4 Scala sources and 2 Java sources to /disk/scratch/tmp/play/play-with-ant/target/scala-2.11/classes...
[success] Total time: 12 s, completed 1 квіт 2015 16:49:51
[info] JavaScript linting on 1 source(s)
java.util.NoSuchElementException: None.get
        at scala.None$.get(Option.scala:313)
        at scala.None$.get(Option.scala:311)
        at com.typesafe.sbt.web.SbtWeb$.withActorRefFactory(SbtWeb.scala:441)
        at com.typesafe.sbt.jse.SbtJsTask$$anonfun$jsSourceFileTask$1$$anonfun$9$$anonfun$10.apply(SbtJsTask.scala:285)
        at com.typesafe.sbt.jse.SbtJsTask$$anonfun$jsSourceFileTask$1$$anonfun$9$$anonfun$10.apply(SbtJsTask.scala:284)
        at scala.collection.immutable.Stream.map(Stream.scala:376)
        at com.typesafe.sbt.jse.SbtJsTask$$anonfun$jsSourceFileTask$1$$anonfun$9.apply(SbtJsTask.scala:283)
        at com.typesafe.sbt.jse.SbtJsTask$$anonfun$jsSourceFileTask$1$$anonfun$9.apply(SbtJsTask.scala:272)
        at com.typesafe.sbt.web.incremental.package$.syncIncremental(package.scala:228)
        at com.typesafe.sbt.jse.SbtJsTask$$anonfun$jsSourceFileTask$1.apply(SbtJsTask.scala:271)
        at com.typesafe.sbt.jse.SbtJsTask$$anonfun$jsSourceFileTask$1.apply(SbtJsTask.scala:257)
        at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
        at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)
        at sbt.std.Transform$$anon$4.work(System.scala:64)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
        at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
        at sbt.Execute.work(Execute.scala:244)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
        at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
        at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
[error] (web-assets:jshint) java.util.NoSuchElementException: None.get
[error] Total time: 0 s, completed 1 квіт 2015 16:49:51

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.