Question

I started using Apache builder for a project and I am surprised how little code I need to build my project. But after the first successes, a problem arose:

I have some required text files stored in a jar file which can be downloaded from a repository. I have included it in my buildfile as an artifact and can download an compile with it.

Now I want to extract the contents of the jar and place it in the root folder of my project. Is there a way that Apache Buildr can do this for me? Just adding it to the classpath is not sufficient.

Was it helpful?

Solution

I believe this is the example you are looking for, from http://buildr.apache.org/artifacts.html

bean_jar = file('target/app/bean.jar'=>unzip('target/app'=>app_zip))   

You can also directly call Buildr's Unzip, just don't forget the extract at the end.

Unzip.new( 'path/to/extra/to' => 'file/to/unzip').extract

OTHER TIPS

A jar file is a zip file. You can use buildr's built-in unzip helper to unzip it wherever you'd like. The unzip helper is documented in the artifacts section of the buildr docs.

If you need to get the filename of an artifact that buildr has downloaded, you can call #to_s on the artifact:

artifact('net.example:text-files:jar:1.0.0').to_s
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top