Question

When trying to build this project:

project_layout = Layout.new
project_layout[:source,:main,:java] = 'src'
project_layout[:source,:test,:java] = 'test'

define 'hausaufgaben', :layout => project_layout do
    project.version = '1.0'
    package :jar
end

I'm getting this error:

RuntimeError : Unable to download org.apache.ant:ant:jar:1.8.3. No remote repositories defined.

From this message I gather that buildr uses ant internally (strange, I'd have thought it uses Rake for building). The Quickstart doesn't mention this. What's even more annoying is that I already have ant (1.8.2 rather than 1.8.3, but that shouldn't make such a huge difference), and strangely enough there are no complaints as long as buildr doesn't find any java files (tested this by leaving the layout at its default value).

Now to the actual question: Do I have to add a repository where buildr can find ant, or can I do this otherwise?

For the record: I installed buildr with jruby -S gem install buildr and run it with jruby -S buildr package.

Was it helpful?

Solution 2

Buildr uses Rake to do task dependency evaluation and execution. However, Rake doesn't have any knowledge of how to build Java projects specifically. Rather than re-writing every task it supports in ruby, Buildr uses ant tasks to implement some of its own tasks. (One I can think of off hand is running JUnit tests; I'm sure there are others.) So, Buildr needs Ant.

You can either add the appropriate remote repository or ensure that the correct version of the ant jar is in the m2 cache on every machine that will use your buildfile. For the artifact in your error message, the expected path would be $HOME/.m2/repository/org/apache/ant/ant/1.8.3/ant-1.8.3.jar.

Note that ant is likely not the only dependency that buildr will attempt to download. You'll have to do this manual resolution for each dependency if you don't want to have a remote repository defined.

(Note that if you run buildr in a directory without a buildfile, it will offer to generate one for you. The one it generates will have an appropriate remote repository set up.)

OTHER TIPS

As Rhett idicated, Buildr uses Ant under the covers to implement some of it's tasks and will try to download the required libraries when needed.

I typically register a remote repository in the build file so the build knows where to download the library from if it is not already cached locally. So try adding the following to the top o your build.

repositories.remote << 'http://repo1.maven.org/maven2'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top