buildr(2)First Project
1. buildfile
create a directory named killer-app
>sudo buildr
That will generate a buildfile in your current directory. The directory structure is as follow:
src/main/java/
src/main/scala/
src/main/groovy/
src/main/resources/
target/classes/
target/resources/
>sudo buildr compile
error message:
Requesting http://www.ibiblio.org/maven2/org/apache/ant/ant/1.8.0/ant-1.8.0.jar
Buildr aborted!
RuntimeError : Failed to download org.apache.ant:ant:jar:1.8.0, tried the following repositories:
http://www.ibiblio.org/maven2/
solution:
change the repository to our nexus or artifactory:
repositories.remote << "http://server:port/repository" It is right now.
2. Packaging
define 'killer-app' do
project.version = '0.1.0'
package :jar
end
>sudo buildr package
>sudo buildr clean package
3. Dependencies
# Specify Maven 2.0 remote repositories here, like this:
repositories.remote << "http://www.ibiblio.org/maven2/"
This repositories.remote can be a array.
The format of artifact will be groupId:artifactId:packageType:version. The artifacts are as follow:
we can search the artifact at this URL http://www.mvnbrowser.com
...snip...
package :jar
compile.with 'commons-lang:commons-lang:jar:2.4'
compile.with 'commons-logging:commons-logging:jar:1.1.1'
compile.with 'commons-configuration:commons-configuration:jar:1.5'
...snip...
compile with comma.
WICKET = transitive('org.apache.wicket:wicket:jar:1.4-rc6')
SLF4J = 'org.slf4j:slf4j-jdk14:jar:1.5.8'
...snip...
compile.with WICKET, SLF4J
...snip...
buildr can actually download the zip file and dig into the downloaded archive, detect and extract the JAR file, installing it into the local repository just like any other artifact:
DBPOOL = 'net.snaq:dbpool:jar:4.8.3'
download artifact(DBPOOL) => 'http://www.snaq.net/java/DBPool/DBPool_v4.8.3.zip'
4. Testing
Buildr supports auto-magical integration with a number of mainstream testing frameworks.
JAVA Junit4, TestNG
Scala Specs, ScalaTest
Groovy EasyB
The directory for testing is as follow:
src/test/java/
run the test cases with this command
>sudo buildr test
with the dependencies like this as same as compile
...snip...
compile.with 'commons-cli:commons-cli:jar:1.2'
test.with 'commons-collections:commons-collections:jar:3.2'
...snip...
Using testng
...snip...
test.with 'commons-collections:commons-collections:jar:3.2'
test.using :testgn
...snip...
5. Custom Tasks
//TODO
references:
http://buildr.apache.org/quick_start.html#first-project
buildr(2)First Project
猜你喜欢
转载自sillycat.iteye.com/blog/1338949
今日推荐
周排行