mguymon-buildr 1.4.5-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +1291 -0
- data/LICENSE +176 -0
- data/NOTICE +26 -0
- data/README.rdoc +134 -0
- data/Rakefile +44 -0
- data/_buildr +35 -0
- data/_jbuildr +35 -0
- data/addon/buildr/antlr.rb +65 -0
- data/addon/buildr/bnd.rb +147 -0
- data/addon/buildr/cobertura.rb +22 -0
- data/addon/buildr/drb.rb +281 -0
- data/addon/buildr/emma.rb +22 -0
- data/addon/buildr/hibernate.rb +149 -0
- data/addon/buildr/javacc.rb +85 -0
- data/addon/buildr/jaxb_xjc.rb +72 -0
- data/addon/buildr/jdepend.rb +60 -0
- data/addon/buildr/jetty.rb +248 -0
- data/addon/buildr/jibx.rb +86 -0
- data/addon/buildr/nailgun.rb +221 -0
- data/addon/buildr/openjpa.rb +88 -0
- data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
- data/addon/buildr/protobuf.rb +88 -0
- data/addon/buildr/xmlbeans.rb +93 -0
- data/bin/buildr +19 -0
- data/buildr.buildfile +58 -0
- data/buildr.gemspec +78 -0
- data/doc/_config.yml +1 -0
- data/doc/_layouts/default.html +90 -0
- data/doc/_layouts/preface.html +22 -0
- data/doc/artifacts.textile +217 -0
- data/doc/building.textile +276 -0
- data/doc/contributing.textile +268 -0
- data/doc/css/default.css +236 -0
- data/doc/css/print.css +101 -0
- data/doc/css/syntax.css +23 -0
- data/doc/download.textile +151 -0
- data/doc/extending.textile +212 -0
- data/doc/images/1442160941-frontcover.jpg +0 -0
- data/doc/images/asf-logo.gif +0 -0
- data/doc/images/asf-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/favicon.png +0 -0
- data/doc/images/growl-icon.tiff +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/index.textile +109 -0
- data/doc/installing.textile +284 -0
- data/doc/languages.textile +599 -0
- data/doc/mailing_lists.textile +29 -0
- data/doc/more_stuff.textile +845 -0
- data/doc/packaging.textile +618 -0
- data/doc/preface.textile +54 -0
- data/doc/projects.textile +276 -0
- data/doc/quick_start.textile +210 -0
- data/doc/releasing.textile +117 -0
- data/doc/scripts/buildr-git.rb +512 -0
- data/doc/scripts/gitflow.rb +296 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +73 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/settings_profiles.textile +287 -0
- data/doc/testing.textile +247 -0
- data/etc/KEYS +189 -0
- data/lib/buildr.rb +44 -0
- data/lib/buildr/clojure.rb +34 -0
- data/lib/buildr/clojure/shell.rb +52 -0
- data/lib/buildr/core.rb +34 -0
- data/lib/buildr/core/application.rb +700 -0
- data/lib/buildr/core/build.rb +516 -0
- data/lib/buildr/core/cc.rb +166 -0
- data/lib/buildr/core/checks.rb +253 -0
- data/lib/buildr/core/common.rb +151 -0
- data/lib/buildr/core/compile.rb +622 -0
- data/lib/buildr/core/doc.rb +276 -0
- data/lib/buildr/core/environment.rb +129 -0
- data/lib/buildr/core/filter.rb +404 -0
- data/lib/buildr/core/generate.rb +197 -0
- data/lib/buildr/core/help.rb +119 -0
- data/lib/buildr/core/jrebel.rb +42 -0
- data/lib/buildr/core/linux.rb +30 -0
- data/lib/buildr/core/osx.rb +46 -0
- data/lib/buildr/core/progressbar.rb +161 -0
- data/lib/buildr/core/project.rb +975 -0
- data/lib/buildr/core/run.rb +43 -0
- data/lib/buildr/core/shell.rb +137 -0
- data/lib/buildr/core/test.rb +843 -0
- data/lib/buildr/core/transports.rb +575 -0
- data/lib/buildr/core/util.rb +537 -0
- data/lib/buildr/groovy.rb +20 -0
- data/lib/buildr/groovy/bdd.rb +106 -0
- data/lib/buildr/groovy/compiler.rb +153 -0
- data/lib/buildr/groovy/doc.rb +76 -0
- data/lib/buildr/groovy/shell.rb +57 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/buildr/ide/eclipse.rb +427 -0
- data/lib/buildr/ide/eclipse/java.rb +53 -0
- data/lib/buildr/ide/eclipse/plugin.rb +71 -0
- data/lib/buildr/ide/eclipse/scala.rb +68 -0
- data/lib/buildr/ide/idea.rb +576 -0
- data/lib/buildr/java.rb +25 -0
- data/lib/buildr/java/ant.rb +94 -0
- data/lib/buildr/java/bdd.rb +460 -0
- data/lib/buildr/java/cobertura.rb +297 -0
- data/lib/buildr/java/commands.rb +223 -0
- data/lib/buildr/java/compiler.rb +135 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/doc.rb +86 -0
- data/lib/buildr/java/ecj.rb +69 -0
- data/lib/buildr/java/emma.rb +244 -0
- data/lib/buildr/java/external.rb +73 -0
- data/lib/buildr/java/jruby.rb +122 -0
- data/lib/buildr/java/jtestr_result.rb +295 -0
- data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +142 -0
- data/lib/buildr/java/packaging.rb +734 -0
- data/lib/buildr/java/pom.rb +178 -0
- data/lib/buildr/java/rjb.rb +154 -0
- data/lib/buildr/java/test_result.rb +101 -0
- data/lib/buildr/java/tests.rb +362 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +25 -0
- data/lib/buildr/packaging/archive.rb +535 -0
- data/lib/buildr/packaging/artifact.rb +904 -0
- data/lib/buildr/packaging/artifact_namespace.rb +984 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +105 -0
- data/lib/buildr/packaging/package.rb +249 -0
- data/lib/buildr/packaging/repository_array.rb +108 -0
- data/lib/buildr/packaging/tar.rb +189 -0
- data/lib/buildr/packaging/version_requirement.rb +192 -0
- data/lib/buildr/packaging/zip.rb +178 -0
- data/lib/buildr/packaging/ziptask.rb +356 -0
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/resources/completed.png +0 -0
- data/lib/buildr/resources/failed.png +0 -0
- data/lib/buildr/resources/icons-license.txt +17 -0
- data/lib/buildr/run.rb +195 -0
- data/lib/buildr/scala.rb +26 -0
- data/lib/buildr/scala/bdd.rb +118 -0
- data/lib/buildr/scala/compiler.rb +242 -0
- data/lib/buildr/scala/doc.rb +142 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
- data/lib/buildr/scala/shell.rb +52 -0
- data/lib/buildr/scala/tests.rb +171 -0
- data/lib/buildr/shell.rb +185 -0
- data/lib/buildr/version.rb +18 -0
- data/rakelib/all-in-one.rake +113 -0
- data/rakelib/checks.rake +57 -0
- data/rakelib/doc.rake +137 -0
- data/rakelib/metrics.rake +39 -0
- data/rakelib/package.rake +73 -0
- data/rakelib/release.rake +160 -0
- data/rakelib/rspec.rake +91 -0
- data/rakelib/setup.rake +66 -0
- data/rakelib/stage.rake +220 -0
- data/spec/addon/bnd_spec.rb +330 -0
- data/spec/addon/drb_spec.rb +328 -0
- data/spec/addon/jaxb_xjc_spec.rb +125 -0
- data/spec/core/application_spec.rb +631 -0
- data/spec/core/build_spec.rb +837 -0
- data/spec/core/cc_spec.rb +224 -0
- data/spec/core/checks_spec.rb +519 -0
- data/spec/core/common_spec.rb +725 -0
- data/spec/core/compile_spec.rb +658 -0
- data/spec/core/doc_spec.rb +195 -0
- data/spec/core/extension_spec.rb +201 -0
- data/spec/core/generate_spec.rb +33 -0
- data/spec/core/project_spec.rb +772 -0
- data/spec/core/run_spec.rb +93 -0
- data/spec/core/shell_spec.rb +146 -0
- data/spec/core/test_spec.rb +1320 -0
- data/spec/core/transport_spec.rb +544 -0
- data/spec/core/util_spec.rb +141 -0
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/groovy/compiler_spec.rb +251 -0
- data/spec/groovy/doc_spec.rb +65 -0
- data/spec/ide/eclipse_spec.rb +739 -0
- data/spec/ide/idea_spec.rb +1145 -0
- data/spec/java/ant_spec.rb +37 -0
- data/spec/java/bdd_spec.rb +374 -0
- data/spec/java/cobertura_spec.rb +112 -0
- data/spec/java/commands_spec.rb +93 -0
- data/spec/java/compiler_spec.rb +252 -0
- data/spec/java/doc_spec.rb +56 -0
- data/spec/java/ecj_spec.rb +115 -0
- data/spec/java/emma_spec.rb +121 -0
- data/spec/java/external_spec.rb +56 -0
- data/spec/java/java_spec.rb +132 -0
- data/spec/java/packaging_spec.rb +1266 -0
- data/spec/java/run_spec.rb +78 -0
- data/spec/java/test_coverage_helper.rb +257 -0
- data/spec/java/tests_spec.rb +497 -0
- data/spec/packaging/archive_spec.rb +775 -0
- data/spec/packaging/artifact_namespace_spec.rb +743 -0
- data/spec/packaging/artifact_spec.rb +1074 -0
- data/spec/packaging/packaging_helper.rb +63 -0
- data/spec/packaging/packaging_spec.rb +719 -0
- data/spec/packaging/repository_array_spec.rb +109 -0
- data/spec/sandbox.rb +165 -0
- data/spec/scala/bdd_spec.rb +124 -0
- data/spec/scala/compiler_spec.rb +289 -0
- data/spec/scala/doc_spec.rb +88 -0
- data/spec/scala/scala.rb +38 -0
- data/spec/scala/tests_spec.rb +283 -0
- data/spec/spec_helpers.rb +369 -0
- data/spec/version_requirement_spec.rb +143 -0
- data/spec/xpath_matchers.rb +121 -0
- metadata +600 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
13
|
+
# License for the specific language governing permissions and limitations under
|
|
14
|
+
# the License.
|
|
15
|
+
|
|
16
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
describe Java::Commands do
|
|
20
|
+
|
|
21
|
+
it "should not be verbose by default" do
|
|
22
|
+
write "build.xml", <<-BUILD
|
|
23
|
+
<project name="MyProject" default="dist" basedir=".">
|
|
24
|
+
<description>
|
|
25
|
+
simple example build file
|
|
26
|
+
</description>
|
|
27
|
+
<target name="dist"/>
|
|
28
|
+
</project>
|
|
29
|
+
BUILD
|
|
30
|
+
lambda { Java::Commands.java("org.apache.tools.ant.Main", :classpath => Buildr::Ant.dependencies) }.should_not show_info(/java/)
|
|
31
|
+
lambda { Java::Commands.java("org.apache.tools.ant.Main", :classpath => Buildr::Ant.dependencies, :verbose => true) }.should show_info(/java/)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe "Java::Commands.javac" do
|
|
35
|
+
|
|
36
|
+
it "should compile java" do
|
|
37
|
+
write "Foo.java", "public class Foo {}"
|
|
38
|
+
lambda { Java::Commands.javac("Foo.java") }.should change {File.exist?("Foo.class")}.to(true)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'should let the user specify an output directory' do
|
|
42
|
+
write "Foo.java", "public class Foo {}"
|
|
43
|
+
lambda { Java::Commands.javac("Foo.java", :output => "classes") }.should change {File.exist?("classes/Foo.class")}.to(true)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should let the user specify a different name" do
|
|
47
|
+
write "Foo.java", "public class Foo {}"
|
|
48
|
+
lambda { Java::Commands.javac("Foo.java", :name => "bar") }.should show_info("Compiling 1 source files in bar")
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should let the user specify a source path" do
|
|
52
|
+
write "ext/org/Bar.java", "package org; public class Bar {}"
|
|
53
|
+
write "Foo.java", "import org.Bar;\n public class Foo {}"
|
|
54
|
+
lambda { Java::Commands.javac("Foo.java", :sourcepath => File.expand_path("ext")) }.should change {File.exist?("Foo.class")}.to(true)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "should let the user specify a classpath" do
|
|
58
|
+
write "ext/org/Bar.java", "package org; public class Bar {}"
|
|
59
|
+
Java::Commands.javac("ext/org/Bar.java", :output => "lib")
|
|
60
|
+
write "Foo.java", "import org.Bar;\n public class Foo {}"
|
|
61
|
+
lambda { Java::Commands.javac("Foo.java", :classpath => File.expand_path("lib")) }.should change {File.exist?("Foo.class")}.to(true)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
describe "Java::Commands.javadoc" do
|
|
66
|
+
|
|
67
|
+
it "should fail if no output is defined" do
|
|
68
|
+
lambda { Java::Commands.javadoc("Foo.java") }.should raise_error(/No output defined for javadoc/)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "should create javadoc" do
|
|
72
|
+
write "Foo.java", "public class Foo {}"
|
|
73
|
+
lambda { Java::Commands.javadoc("Foo.java", :output => "doc") }.should change {File.exist?("doc/Foo.html")}.to(true)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "should accept file tasks as arguments" do
|
|
77
|
+
foo = file("Foo.java") do |file|
|
|
78
|
+
file.enhance do
|
|
79
|
+
write file.to_s, "public class Foo {}"
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
lambda { Java::Commands.javadoc(foo, :output => "doc") }.should change {File.exist?("doc/Foo.html")}.to(true)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "should accept projects as arguments" do
|
|
86
|
+
write "src/main/java/Foo.java", "public class Foo {}"
|
|
87
|
+
write "src/main/java/bar/Foobar.java", "package bar; public class Foobar {}"
|
|
88
|
+
define "foo" do
|
|
89
|
+
end
|
|
90
|
+
lambda { Java::Commands.javadoc(project("foo"), :output => "doc") }.should change {File.exist?("doc/Foo.html") && File.exist?("doc/bar/Foobar.html")}.to(true)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
13
|
+
# License for the specific language governing permissions and limitations under
|
|
14
|
+
# the License.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
describe 'javac compiler' do
|
|
21
|
+
it 'should identify itself from source directories' do
|
|
22
|
+
write 'src/main/java/com/example/Test.java', 'package com.example; class Test {}'
|
|
23
|
+
define('foo').compile.compiler.should eql(:javac)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should identify from source directories using custom layout' do
|
|
27
|
+
write 'src/com/example/Code.java', 'package com.example; class Code {}'
|
|
28
|
+
write 'testing/com/example/Test.java', 'package com.example; class Test {}'
|
|
29
|
+
custom = Layout.new
|
|
30
|
+
custom[:source, :main, :java] = 'src'
|
|
31
|
+
custom[:source, :test, :java] = 'testing'
|
|
32
|
+
define 'foo', :layout=>custom do
|
|
33
|
+
compile.compiler.should eql(:javac)
|
|
34
|
+
test.compile.compiler.should eql(:javac)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'should identify from compile source directories' do
|
|
39
|
+
write 'src/com/example/Code.java', 'package com.example; class Code {}'
|
|
40
|
+
write 'testing/com/example/Test.java', 'package com.example; class Test {}'
|
|
41
|
+
define 'foo' do
|
|
42
|
+
lambda { compile.from 'src' }.should change { compile.compiler }.to(:javac)
|
|
43
|
+
lambda { test.compile.from 'testing' }.should change { test.compile.compiler }.to(:javac)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'should report the language as :java' do
|
|
48
|
+
define('foo').compile.using(:javac).language.should eql(:java)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'should set the target directory to target/classes' do
|
|
52
|
+
define 'foo' do
|
|
53
|
+
lambda { compile.using(:javac) }.should change { compile.target.to_s }.to(File.expand_path('target/classes'))
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'should not override existing target directory' do
|
|
58
|
+
define 'foo' do
|
|
59
|
+
compile.into('classes')
|
|
60
|
+
lambda { compile.using(:javac) }.should_not change { compile.target }
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it 'should not change existing list of sources' do
|
|
65
|
+
define 'foo' do
|
|
66
|
+
compile.from('sources')
|
|
67
|
+
lambda { compile.using(:javac) }.should_not change { compile.sources }
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'should include classpath dependencies' do
|
|
72
|
+
write 'src/dependency/Dependency.java', 'class Dependency {}'
|
|
73
|
+
define 'dependency', :version=>'1.0' do
|
|
74
|
+
compile.from('src/dependency').into('target/dependency')
|
|
75
|
+
package(:jar)
|
|
76
|
+
end
|
|
77
|
+
write 'src/test/DependencyTest.java', 'class DependencyTest { Dependency _var; }'
|
|
78
|
+
define('foo').compile.from('src/test').with(project('dependency')).invoke
|
|
79
|
+
file('target/classes/DependencyTest.class').should exist
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it 'should include tools.jar dependency' do
|
|
83
|
+
write 'src/main/java/UseApt.java', <<-JAVA
|
|
84
|
+
import com.sun.mirror.apt.AnnotationProcessor;
|
|
85
|
+
public class UseApt { }
|
|
86
|
+
JAVA
|
|
87
|
+
define('foo').compile.invoke
|
|
88
|
+
file('target/classes/UseApt.class').should exist
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
describe 'javac compiler options' do
|
|
94
|
+
def compile_task
|
|
95
|
+
@compile_task ||= define('foo').compile.using(:javac)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def javac_args
|
|
99
|
+
compile_task.instance_eval { @compiler }.send(:javac_args)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it 'should set warnings option to false by default' do
|
|
103
|
+
compile_task.options.warnings.should be_false
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it 'should set warnings option to true when running with --verbose option' do
|
|
107
|
+
verbose true
|
|
108
|
+
compile_task.options.warnings.should be_false
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it 'should use -nowarn argument when warnings is false' do
|
|
112
|
+
compile_task.using(:warnings=>false)
|
|
113
|
+
javac_args.should include('-nowarn')
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it 'should not use -nowarn argument when warnings is true' do
|
|
117
|
+
compile_task.using(:warnings=>true)
|
|
118
|
+
javac_args.should_not include('-nowarn')
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it 'should not use -verbose argument by default' do
|
|
122
|
+
javac_args.should_not include('-verbose')
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it 'should use -verbose argument when running with --trace=javac option' do
|
|
126
|
+
Buildr.application.options.trace_categories = [:javac]
|
|
127
|
+
javac_args.should include('-verbose')
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it 'should set debug option to true by default' do
|
|
131
|
+
compile_task.options.debug.should be_true
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it 'should set debug option to false based on Buildr.options' do
|
|
135
|
+
Buildr.options.debug = false
|
|
136
|
+
compile_task.options.debug.should be_false
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it 'should set debug option to false based on debug environment variable' do
|
|
140
|
+
ENV['debug'] = 'no'
|
|
141
|
+
compile_task.options.debug.should be_false
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
it 'should set debug option to false based on DEBUG environment variable' do
|
|
145
|
+
ENV['DEBUG'] = 'no'
|
|
146
|
+
compile_task.options.debug.should be_false
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
it 'should use -g argument when debug option is true' do
|
|
150
|
+
compile_task.using(:debug=>true)
|
|
151
|
+
javac_args.should include('-g')
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
it 'should not use -g argument when debug option is false' do
|
|
155
|
+
compile_task.using(:debug=>false)
|
|
156
|
+
javac_args.should_not include('-g')
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it 'should set deprecation option to false by default' do
|
|
160
|
+
compile_task.options.deprecation.should be_false
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
it 'should use -deprecation argument when deprecation is true' do
|
|
164
|
+
compile_task.using(:deprecation=>true)
|
|
165
|
+
javac_args.should include('-deprecation')
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
it 'should not use -deprecation argument when deprecation is false' do
|
|
169
|
+
compile_task.using(:deprecation=>false)
|
|
170
|
+
javac_args.should_not include('-deprecation')
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
it 'should not set source option by default' do
|
|
174
|
+
compile_task.options.source.should be_nil
|
|
175
|
+
javac_args.should_not include('-source')
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
it 'should not set target option by default' do
|
|
179
|
+
compile_task.options.target.should be_nil
|
|
180
|
+
javac_args.should_not include('-target')
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
it 'should use -source nn argument if source option set' do
|
|
184
|
+
compile_task.using(:source=>'1.5')
|
|
185
|
+
javac_args.should include('-source', '1.5')
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
it 'should use -target nn argument if target option set' do
|
|
189
|
+
compile_task.using(:target=>'1.5')
|
|
190
|
+
javac_args.should include('-target', '1.5')
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
it 'should set lint option to false by default' do
|
|
194
|
+
compile_task.options.lint.should be_false
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
it 'should use -lint argument if lint option is true' do
|
|
198
|
+
compile_task.using(:lint=>true)
|
|
199
|
+
javac_args.should include('-Xlint')
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
it 'should use -lint argument with value of option' do
|
|
203
|
+
compile_task.using(:lint=>'all')
|
|
204
|
+
javac_args.should include('-Xlint:all')
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
it 'should use -lint argument with value of option as array' do
|
|
208
|
+
compile_task.using(:lint=>['path', 'serial'])
|
|
209
|
+
javac_args.should include('-Xlint:path,serial')
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
it 'should not set other option by default' do
|
|
213
|
+
compile_task.options.other.should be_nil
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
it 'should pass other argument if other option is string' do
|
|
217
|
+
compile_task.using(:other=>'-Xprint')
|
|
218
|
+
javac_args.should include('-Xprint')
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
it 'should pass other argument if other option is array' do
|
|
222
|
+
compile_task.using(:other=>['-Xstdout', 'msgs'])
|
|
223
|
+
javac_args.should include('-Xstdout', 'msgs')
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
it 'should complain about options it doesn\'t know' do
|
|
227
|
+
write 'source/Test.java', 'class Test {}'
|
|
228
|
+
compile_task.using(:unknown=>'option')
|
|
229
|
+
lambda { compile_task.from('source').invoke }.should raise_error(ArgumentError, /no such option/i)
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
it 'should inherit options from parent' do
|
|
233
|
+
define 'foo' do
|
|
234
|
+
compile.using(:warnings=>true, :debug=>true, :deprecation=>true, :source=>'1.5', :target=>'1.4')
|
|
235
|
+
define 'bar' do
|
|
236
|
+
compile.using(:javac)
|
|
237
|
+
compile.options.warnings.should be_true
|
|
238
|
+
compile.options.debug.should be_true
|
|
239
|
+
compile.options.deprecation.should be_true
|
|
240
|
+
compile.options.source.should eql('1.5')
|
|
241
|
+
compile.options.target.should eql('1.4')
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
after do
|
|
247
|
+
Buildr.options.debug = nil
|
|
248
|
+
ENV.delete "debug"
|
|
249
|
+
ENV.delete "DEBUG"
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
13
|
+
# License for the specific language governing permissions and limitations under
|
|
14
|
+
# the License.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
|
|
18
|
+
|
|
19
|
+
describe 'Javadoc' do
|
|
20
|
+
def sources
|
|
21
|
+
@sources ||= (1..3).map { |i| "Test#{i}" }.
|
|
22
|
+
each { |name| write "src/main/java/foo/#{name}.java", "package foo; public class #{name}{}" }.
|
|
23
|
+
map { |name| "src/main/java/foo/#{name}.java" }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should pick -windowtitle from project name by default' do
|
|
27
|
+
define 'foo' do
|
|
28
|
+
compile.using(:javac)
|
|
29
|
+
|
|
30
|
+
define 'bar' do
|
|
31
|
+
compile.using(:javac)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
project('foo').doc.options[:windowtitle].should eql('foo')
|
|
36
|
+
project('foo:bar').doc.options[:windowtitle].should eql('foo:bar')
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'should pick -windowtitle from project description by default, if available' do
|
|
40
|
+
desc 'My App'
|
|
41
|
+
define 'foo' do
|
|
42
|
+
compile.using(:javac)
|
|
43
|
+
end
|
|
44
|
+
project('foo').doc.options[:windowtitle].should eql('My App')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'should not override explicit :windowtitle' do
|
|
48
|
+
define 'foo' do
|
|
49
|
+
compile.using(:javac)
|
|
50
|
+
doc.using :windowtitle => 'explicit'
|
|
51
|
+
end
|
|
52
|
+
project('foo').doc.options[:windowtitle].should eql('explicit')
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
13
|
+
# License for the specific language governing permissions and limitations under
|
|
14
|
+
# the License.
|
|
15
|
+
|
|
16
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
describe Buildr::Compiler::Ecj do
|
|
21
|
+
|
|
22
|
+
before(:all) do
|
|
23
|
+
#Make ecj appear as a compiler that applies:
|
|
24
|
+
class Buildr::Compiler::Ecj
|
|
25
|
+
class << self
|
|
26
|
+
|
|
27
|
+
def applies_to?(project, task)
|
|
28
|
+
paths = task.sources + [sources].flatten.map { |src| Array(project.path_to(:source, task.usage, src.to_sym)) }
|
|
29
|
+
paths.flatten!
|
|
30
|
+
ext_glob = Array(source_ext).join(',')
|
|
31
|
+
|
|
32
|
+
paths.each { |path|
|
|
33
|
+
Find.find(path) {|found|
|
|
34
|
+
if (!File.directory?(found)) && found.match(/.*\.#{Array(source_ext).join('|')}/)
|
|
35
|
+
return true
|
|
36
|
+
end
|
|
37
|
+
} if File.exist? path
|
|
38
|
+
}
|
|
39
|
+
false
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "should be the default Java compiler once loaded" do
|
|
46
|
+
write 'src/main/java/Foo.java', 'public class Foo {}'
|
|
47
|
+
foo = define('foo')
|
|
48
|
+
foo.compile.compiler.should == :ecj
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe "should compile a Java project just in the same way javac does" do
|
|
52
|
+
javac_spec = File.read(File.join(File.dirname(__FILE__), "compiler_spec.rb"))
|
|
53
|
+
javac_spec = javac_spec.match(Regexp.escape("require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))\n")).post_match
|
|
54
|
+
javac_spec.gsub!("javac", "ecj")
|
|
55
|
+
javac_spec.gsub!("nowarn", "warn:none")
|
|
56
|
+
eval(javac_spec)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Redirect the java error ouput, yielding so you can do something while it is
|
|
60
|
+
# and returning the content of the error buffer.
|
|
61
|
+
#
|
|
62
|
+
def redirect_java_err
|
|
63
|
+
pending "RJB doesn't support well instantiating a class that has several constructors" unless RUBY_PLATFORM =~ /java/
|
|
64
|
+
err = Java.java.io.ByteArrayOutputStream.new
|
|
65
|
+
original_err = Java.java.lang.System.err
|
|
66
|
+
begin
|
|
67
|
+
printStream = Java.java.io.PrintStream
|
|
68
|
+
print = printStream.new(err)
|
|
69
|
+
Java.java.lang.System.setErr(print)
|
|
70
|
+
yield
|
|
71
|
+
ensure
|
|
72
|
+
Java.java.lang.System.setErr(original_err)
|
|
73
|
+
end
|
|
74
|
+
err.toString
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "should not issue warnings for type casting when warnings are set to warn:none, by default" do
|
|
78
|
+
write "src/main/java/Main.java", "import java.util.List; public class Main {public List get() {return null;}}"
|
|
79
|
+
foo = define("foo") {
|
|
80
|
+
compile.options.source = "1.5"
|
|
81
|
+
compile.options.target = "1.5"
|
|
82
|
+
}
|
|
83
|
+
redirect_java_err { foo.compile.invoke }.should_not match(/WARNING/)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "should issue warnings for type casting when warnings are set" do
|
|
87
|
+
write "src/main/java/Main.java", "import java.util.List; public class Main {public List get() {return null;}}"
|
|
88
|
+
foo = define("foo") {
|
|
89
|
+
compile.options.source = "1.5"
|
|
90
|
+
compile.options.target = "1.5"
|
|
91
|
+
compile.options.warnings = true
|
|
92
|
+
}
|
|
93
|
+
redirect_java_err { foo.compile.invoke }.should match(/WARNING/)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
after(:all) do
|
|
97
|
+
#Make ecj appear as a compiler that doesn't apply:
|
|
98
|
+
module Buildr
|
|
99
|
+
module Compiler
|
|
100
|
+
|
|
101
|
+
class Ecj
|
|
102
|
+
|
|
103
|
+
class << self
|
|
104
|
+
|
|
105
|
+
def applies_to?(project, task)
|
|
106
|
+
false
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
|