buildr 1.3.2-java → 1.3.3-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 +66 -4
- data/{README → README.rdoc} +29 -16
- data/Rakefile +16 -20
- data/_buildr +38 -0
- data/addon/buildr/cobertura.rb +49 -45
- data/addon/buildr/emma.rb +238 -0
- data/addon/buildr/jetty.rb +1 -1
- data/addon/buildr/nailgun.rb +585 -661
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.class +0 -0
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.java +0 -0
- data/bin/buildr +9 -2
- data/buildr.buildfile +53 -0
- data/buildr.gemspec +21 -14
- data/doc/css/default.css +51 -48
- data/doc/css/print.css +60 -55
- data/doc/images/favicon.png +0 -0
- data/doc/images/growl-icon.tiff +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/pages/artifacts.textile +46 -156
- data/doc/pages/building.textile +63 -323
- data/doc/pages/contributing.textile +112 -102
- data/doc/pages/download.textile +19 -27
- data/doc/pages/extending.textile +27 -81
- data/doc/pages/getting_started.textile +44 -119
- data/doc/pages/index.textile +26 -47
- data/doc/pages/languages.textile +407 -0
- data/doc/pages/more_stuff.textile +92 -173
- data/doc/pages/packaging.textile +71 -239
- data/doc/pages/projects.textile +58 -233
- data/doc/pages/recipes.textile +19 -43
- data/doc/pages/settings_profiles.textile +39 -104
- data/doc/pages/testing.textile +41 -304
- data/doc/pages/troubleshooting.textile +29 -47
- data/doc/pages/whats_new.textile +69 -167
- data/doc/print.haml +0 -1
- data/doc/print.toc.yaml +1 -0
- data/doc/scripts/buildr-git.rb +1 -1
- data/doc/site.haml +1 -0
- data/doc/site.toc.yaml +8 -5
- data/{KEYS → etc/KEYS} +0 -0
- data/etc/git-svn-authors +16 -0
- data/lib/buildr.rb +2 -5
- data/lib/buildr/core/application.rb +192 -98
- data/lib/buildr/core/build.rb +140 -91
- data/lib/buildr/core/checks.rb +5 -5
- data/lib/buildr/core/common.rb +1 -1
- data/lib/buildr/core/compile.rb +12 -10
- data/lib/buildr/core/filter.rb +151 -46
- data/lib/buildr/core/generate.rb +9 -9
- data/lib/buildr/core/progressbar.rb +1 -1
- data/lib/buildr/core/project.rb +8 -7
- data/lib/buildr/core/test.rb +51 -26
- data/lib/buildr/core/transports.rb +22 -38
- data/lib/buildr/core/util.rb +78 -26
- data/lib/buildr/groovy.rb +18 -0
- data/lib/buildr/groovy/bdd.rb +105 -0
- data/lib/buildr/groovy/compiler.rb +138 -0
- data/lib/buildr/ide/eclipse.rb +102 -71
- data/lib/buildr/ide/idea.rb +7 -12
- data/lib/buildr/ide/idea7x.rb +7 -8
- data/lib/buildr/java.rb +4 -7
- data/lib/buildr/java/ant.rb +26 -5
- data/lib/buildr/java/bdd.rb +449 -0
- data/lib/buildr/java/commands.rb +9 -9
- data/lib/buildr/java/{compilers.rb → compiler.rb} +8 -90
- data/lib/buildr/java/jruby.rb +29 -11
- data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
- data/lib/buildr/java/packaging.rb +23 -16
- data/lib/buildr/java/pom.rb +1 -1
- data/lib/buildr/java/rjb.rb +21 -8
- data/lib/buildr/java/test_result.rb +308 -0
- data/lib/buildr/java/tests.rb +324 -0
- data/lib/buildr/packaging/artifact.rb +12 -11
- data/lib/buildr/packaging/artifact_namespace.rb +7 -4
- data/lib/buildr/packaging/gems.rb +3 -3
- data/lib/buildr/packaging/zip.rb +13 -10
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala.rb +19 -0
- data/lib/buildr/scala/compiler.rb +109 -0
- data/lib/buildr/scala/tests.rb +203 -0
- data/rakelib/apache.rake +71 -45
- data/rakelib/doc.rake +2 -2
- data/rakelib/package.rake +3 -2
- data/rakelib/rspec.rake +23 -21
- data/rakelib/setup.rake +34 -9
- data/rakelib/stage.rake +4 -1
- data/spec/addon/cobertura_spec.rb +77 -0
- data/spec/addon/emma_spec.rb +120 -0
- data/spec/addon/test_coverage_spec.rb +255 -0
- data/spec/{application_spec.rb → core/application_spec.rb} +82 -4
- data/spec/{artifact_namespace_spec.rb → core/artifact_namespace_spec.rb} +12 -1
- data/spec/core/build_spec.rb +415 -0
- data/spec/{checks_spec.rb → core/checks_spec.rb} +2 -2
- data/spec/{common_spec.rb → core/common_spec.rb} +119 -30
- data/spec/{compile_spec.rb → core/compile_spec.rb} +17 -13
- data/spec/core/generate_spec.rb +33 -0
- data/spec/{project_spec.rb → core/project_spec.rb} +9 -6
- data/spec/{test_spec.rb → core/test_spec.rb} +222 -28
- data/spec/{transport_spec.rb → core/transport_spec.rb} +5 -9
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/{groovy_compilers_spec.rb → groovy/compiler_spec.rb} +1 -1
- data/spec/ide/eclipse_spec.rb +243 -0
- data/spec/{java_spec.rb → java/ant.rb} +7 -17
- data/spec/java/bdd_spec.rb +358 -0
- data/spec/{java_compilers_spec.rb → java/compiler_spec.rb} +1 -1
- data/spec/java/java_spec.rb +88 -0
- data/spec/{java_packaging_spec.rb → java/packaging_spec.rb} +65 -4
- data/spec/{java_test_frameworks_spec.rb → java/tests_spec.rb} +31 -10
- data/spec/{archive_spec.rb → packaging/archive_spec.rb} +12 -2
- data/spec/{artifact_spec.rb → packaging/artifact_spec.rb} +12 -5
- data/spec/{packaging_helper.rb → packaging/packaging_helper.rb} +0 -0
- data/spec/{packaging_spec.rb → packaging/packaging_spec.rb} +1 -1
- data/spec/sandbox.rb +22 -5
- data/spec/{scala_compilers_spec.rb → scala/compiler_spec.rb} +1 -1
- data/spec/{scala_test_frameworks_spec.rb → scala/tests_spec.rb} +11 -12
- data/spec/spec_helpers.rb +38 -17
- metadata +93 -70
- data/lib/buildr/java/bdd_frameworks.rb +0 -265
- data/lib/buildr/java/groovyc.rb +0 -137
- data/lib/buildr/java/test_frameworks.rb +0 -450
- data/spec/build_spec.rb +0 -193
- data/spec/java_bdd_frameworks_spec.rb +0 -238
- data/spec/spec.opts +0 -6
|
@@ -0,0 +1,18 @@
|
|
|
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 'buildr/groovy/compiler'
|
|
18
|
+
require 'buildr/groovy/bdd'
|
|
@@ -0,0 +1,105 @@
|
|
|
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
|
+
module Buildr::Groovy
|
|
17
|
+
|
|
18
|
+
# EasyB is a Groovy based BDD framework.
|
|
19
|
+
# To use in your project:
|
|
20
|
+
#
|
|
21
|
+
# test.using :easyb
|
|
22
|
+
#
|
|
23
|
+
# This framework will search in your project for:
|
|
24
|
+
# src/spec/groovy/**/*Story.groovy
|
|
25
|
+
# src/spec/groovy/**/*Behavior.groovy
|
|
26
|
+
#
|
|
27
|
+
# Support the following options:
|
|
28
|
+
# * :format -- Report format :txt or :xml, default is :txt
|
|
29
|
+
# * :properties -- Hash of properties passed to the test suite.
|
|
30
|
+
# * :java_args -- Arguments passed to the JVM.
|
|
31
|
+
class EasyB < TestFramework::JavaBDD
|
|
32
|
+
@lang = :groovy
|
|
33
|
+
@bdd_dir = :spec
|
|
34
|
+
|
|
35
|
+
VERSION = "0.7"
|
|
36
|
+
TESTS_PATTERN = [ /(Story|Behavior).groovy$/ ]
|
|
37
|
+
OPTIONS = [:format, :properties, :java_args]
|
|
38
|
+
|
|
39
|
+
class << self
|
|
40
|
+
def version
|
|
41
|
+
Buildr.settings.build['jbehave'] || VERSION
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def dependencies
|
|
45
|
+
@dependencies ||= ["org.easyb:easyb:jar:#{version}",
|
|
46
|
+
'org.codehaus.groovy:groovy:jar:1.5.3','asm:asm:jar:2.2.3',
|
|
47
|
+
'commons-cli:commons-cli:jar:1.0','antlr:antlr:jar:2.7.7']
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def applies_to?(project) #:nodoc:
|
|
51
|
+
%w{
|
|
52
|
+
**/*Behaviour.groovy **/*Behavior.groovy **/*Story.groovy
|
|
53
|
+
}.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
def const_missing(const)
|
|
58
|
+
return super unless const == :REQUIRES # TODO: remove in 1.5
|
|
59
|
+
Buildr.application.deprecated "Please use JBehave.dependencies/.version instead of JBehave::REQUIRES/VERSION"
|
|
60
|
+
dependencies
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def tests(dependencies) #:nodoc:
|
|
65
|
+
Dir[task.project.path_to(:source, bdd_dir, lang, "**/*.groovy")].
|
|
66
|
+
select { |name| TESTS_PATTERN.any? { |pat| pat === name } }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def run(tests, dependencies) #:nodoc:
|
|
70
|
+
options = { :format => :txt }.merge(self.options).only(*OPTIONS)
|
|
71
|
+
|
|
72
|
+
if :txt == options[:format]
|
|
73
|
+
easyb_format, ext = 'txtstory', '.txt'
|
|
74
|
+
elsif :xml == options[:format]
|
|
75
|
+
easyb_format, ext = 'xmlbehavior', '.xml'
|
|
76
|
+
else
|
|
77
|
+
raise "Invalid format #{options[:format]} expected one of :txt :xml"
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
cmd_args = [ 'org.disco.easyb.SpecificationRunner' ]
|
|
81
|
+
cmd_options = { :properties => options[:properties],
|
|
82
|
+
:java_args => options[:java_args],
|
|
83
|
+
:classpath => dependencies }
|
|
84
|
+
|
|
85
|
+
tests.inject([]) do |passed, test|
|
|
86
|
+
name = test.sub(/.*?groovy[\/\\]/, '').pathmap('%X')
|
|
87
|
+
report = File.join(task.report_to.to_s, name + ext)
|
|
88
|
+
mkpath report.pathmap('%d'), :verbose => false
|
|
89
|
+
begin
|
|
90
|
+
Java::Commands.java cmd_args,
|
|
91
|
+
"-#{easyb_format}", report,
|
|
92
|
+
test, cmd_options.merge(:name => name)
|
|
93
|
+
rescue => e
|
|
94
|
+
passed
|
|
95
|
+
else
|
|
96
|
+
passed << test
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
end # EasyB
|
|
102
|
+
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
Buildr::TestFramework << Buildr::Groovy::EasyB
|
|
@@ -0,0 +1,138 @@
|
|
|
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
|
+
module Buildr::Groovy
|
|
18
|
+
|
|
19
|
+
# Groovyc compiler:
|
|
20
|
+
# compile.using(:groovyc)
|
|
21
|
+
#
|
|
22
|
+
# You need to require 'buildr/java/groovyc' if you need to use this compiler.
|
|
23
|
+
#
|
|
24
|
+
# Used by default if .groovy files are found in the src/main/groovy directory (or src/test/groovy)
|
|
25
|
+
# and sets the target directory to target/classes (or target/test/classes).
|
|
26
|
+
#
|
|
27
|
+
# Groovyc is a joint compiler, this means that when selected for a project, this compiler is used
|
|
28
|
+
# to compile both groovy and java sources. It's recommended that Groovy sources are placed in the
|
|
29
|
+
# src/main/groovy directory, even though this compiler also looks in src/main/java
|
|
30
|
+
#
|
|
31
|
+
# Groovyc accepts the following options:
|
|
32
|
+
#
|
|
33
|
+
# * :encoding -- Encoding of source files
|
|
34
|
+
# * :verbose -- Asks the compiler for verbose output, true when running in verbose mode.
|
|
35
|
+
# * :fork -- Whether to execute groovyc using a spawned instance of the JVM; defaults to no
|
|
36
|
+
# * :memoryInitialSize -- The initial size of the memory for the underlying VM, if using fork mode; ignored otherwise.
|
|
37
|
+
# Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
|
|
38
|
+
# * :memoryMaximumSize -- The maximum size of the memory for the underlying VM, if using fork mode; ignored otherwise.
|
|
39
|
+
# Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
|
|
40
|
+
# * :listfiles -- Indicates whether the source files to be compiled will be listed; defaults to no
|
|
41
|
+
# * :stacktrace -- If true each compile error message will contain a stacktrace
|
|
42
|
+
# * :warnings -- Issue warnings when compiling. True when running in verbose mode.
|
|
43
|
+
# * :debug -- Generates bytecode with debugging information. Set from the debug
|
|
44
|
+
# environment variable/global option.
|
|
45
|
+
# * :deprecation -- If true, shows deprecation messages. False by default.
|
|
46
|
+
# * :optimise -- Generates faster bytecode by applying optimisations to the program.
|
|
47
|
+
# * :source -- Source code compatibility.
|
|
48
|
+
# * :target -- Bytecode compatibility.
|
|
49
|
+
# * :javac -- Hash of options passed to the ant javac task
|
|
50
|
+
#
|
|
51
|
+
class Groovyc < Compiler::Base
|
|
52
|
+
|
|
53
|
+
# The groovyc compiler jars are added to classpath at load time,
|
|
54
|
+
# if you want to customize artifact versions, you must set them on the
|
|
55
|
+
#
|
|
56
|
+
# artifact_ns['Buildr::Compiler::Groovyc'].groovy = '1.5.4'
|
|
57
|
+
#
|
|
58
|
+
# namespace before this file is required.
|
|
59
|
+
REQUIRES = ArtifactNamespace.for(self) do |ns|
|
|
60
|
+
ns.groovy! 'org.codehaus.groovy:groovy:jar:>=1.5.3'
|
|
61
|
+
ns.commons_cli! 'commons-cli:commons-cli:jar:>=1.0'
|
|
62
|
+
ns.asm! 'asm:asm:jar:>=2.2'
|
|
63
|
+
ns.antlr! 'antlr:antlr:jar:>=2.7.7'
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
ANT_TASK = 'org.codehaus.groovy.ant.Groovyc'
|
|
67
|
+
GROOVYC_OPTIONS = [:encoding, :verbose, :fork, :memoryInitialSize, :memoryMaximumSize, :listfiles, :stacktrace]
|
|
68
|
+
JAVAC_OPTIONS = [:optimise, :warnings, :debug, :deprecation, :source, :target, :javac]
|
|
69
|
+
OPTIONS = GROOVYC_OPTIONS + JAVAC_OPTIONS
|
|
70
|
+
|
|
71
|
+
class << self
|
|
72
|
+
def dependencies #:nodoc:
|
|
73
|
+
REQUIRES.artifacts
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def applies_to?(project, task) #:nodoc:
|
|
77
|
+
paths = task.sources + [sources].flatten.map { |src| Array(project.path_to(:source, task.usage, src.to_sym)) }
|
|
78
|
+
paths.flatten!
|
|
79
|
+
# Just select if we find .groovy files
|
|
80
|
+
paths.any? { |path| !Dir["#{path}/**/*.groovy"].empty? }
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
Java.classpath << dependencies
|
|
85
|
+
|
|
86
|
+
specify :language => :groovy, :sources => [:groovy, :java], :source_ext => [:groovy, :java],
|
|
87
|
+
:target => 'classes', :target_ext => 'class', :packaging => :jar
|
|
88
|
+
|
|
89
|
+
def initialize(project, options) #:nodoc:
|
|
90
|
+
super
|
|
91
|
+
options[:debug] = Buildr.options.debug if options[:debug].nil?
|
|
92
|
+
options[:deprecation] ||= false
|
|
93
|
+
options[:optimise] ||= false
|
|
94
|
+
options[:verbose] ||= Buildr.application.options.trace if options[:verbose].nil?
|
|
95
|
+
options[:warnings] = verbose if options[:warnings].nil?
|
|
96
|
+
options[:javac] = OpenObject.new if options[:javac].nil?
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# http://groovy.codehaus.org/The+groovyc+Ant+Task
|
|
100
|
+
def compile(sources, target, dependencies) #:nodoc:
|
|
101
|
+
return if Buildr.application.options.dryrun
|
|
102
|
+
Buildr.ant 'groovyc' do |ant|
|
|
103
|
+
classpath = dependencies | self.class.dependencies.map(&:to_s)
|
|
104
|
+
ant.taskdef :name => 'groovyc', :classname => ANT_TASK, :classpath => classpath.join(File::PATH_SEPARATOR)
|
|
105
|
+
ant.groovyc groovyc_options(sources, target) do
|
|
106
|
+
sources.each { |src| ant.src :path => src }
|
|
107
|
+
ant.classpath do
|
|
108
|
+
classpath.each { |dep| ant.pathelement :path => dep }
|
|
109
|
+
end
|
|
110
|
+
ant.javac(javac_options)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
private
|
|
116
|
+
def groovyc_options(sources, target)
|
|
117
|
+
check_options options, OPTIONS
|
|
118
|
+
groovyc_options = options.to_hash.only(*GROOVYC_OPTIONS)
|
|
119
|
+
groovyc_options[:destdir] = File.expand_path(target)
|
|
120
|
+
groovyc_options
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def javac_options
|
|
124
|
+
check_options options, OPTIONS
|
|
125
|
+
javac_options = options.to_hash.only(*JAVAC_OPTIONS)
|
|
126
|
+
javac_options[:optimize] = (javac_options.delete(:optimise) || false)
|
|
127
|
+
javac_options[:nowarn] = (javac_options.delete(:warnings) || verbose).to_s !~ /^(true|yes|on)$/i
|
|
128
|
+
other = javac_options.delete(:javac) || {}
|
|
129
|
+
javac_options.merge!(other)
|
|
130
|
+
javac_options
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# Groovy compiler comes first, ahead of Javac, this allows it to pick
|
|
137
|
+
# projects that mix Groovy and Java code by spotting Groovy code first.
|
|
138
|
+
Buildr::Compiler.compilers.unshift Buildr::Groovy::Groovyc
|
data/lib/buildr/ide/eclipse.rb
CHANGED
|
@@ -35,15 +35,6 @@ module Buildr
|
|
|
35
35
|
|
|
36
36
|
after_define do |project|
|
|
37
37
|
eclipse = project.task("eclipse")
|
|
38
|
-
# We need paths relative to the top project's base directory.
|
|
39
|
-
root_path = lambda { |p| f = lambda { |p| p.parent ? f[p.parent] : p.base_dir } ; f[p] }[project]
|
|
40
|
-
|
|
41
|
-
# We want the Eclipse files changed every time the Buildfile changes, but also anything loaded by
|
|
42
|
-
# the Buildfile (buildr.rb, separate file listing dependencies, etc), so we add anything required
|
|
43
|
-
# after the Buildfile. So which don't know where Buildr shows up exactly, ignore files that show
|
|
44
|
-
# in $LOADED_FEATURES that we cannot resolve.
|
|
45
|
-
sources = Buildr.application.build_files.map { |file| File.expand_path(file) }.select { |file| File.exist?(file) }
|
|
46
|
-
sources << File.expand_path(Buildr.application.buildfile, root_path) if Buildr.application.buildfile
|
|
47
38
|
|
|
48
39
|
# Check if project has scala facet
|
|
49
40
|
scala = project.compile.language == :scala
|
|
@@ -56,23 +47,14 @@ module Buildr
|
|
|
56
47
|
eclipse.enhance [ file(project.path_to(".classpath")), file(project.path_to(".project")) ]
|
|
57
48
|
|
|
58
49
|
# The only thing we need to look for is a change in the Buildfile.
|
|
59
|
-
file(project.path_to(".classpath")=>
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
# Find a path relative to the project's root directory.
|
|
63
|
-
relative = lambda do |path|
|
|
64
|
-
path or raise "Invalid path '#{path.inspect}'"
|
|
65
|
-
msg = [:to_path, :to_str, :to_s].find { |msg| path.respond_to? msg }
|
|
66
|
-
path = path.__send__(msg)
|
|
67
|
-
Util.relative_path(File.expand_path(path), project.path_to)
|
|
68
|
-
end
|
|
50
|
+
file(project.path_to(".classpath")=>Buildr.application.buildfile) do |task|
|
|
51
|
+
info "Writing #{task.name}"
|
|
69
52
|
|
|
70
53
|
m2repo = Buildr::Repositories.instance.local
|
|
71
|
-
excludes = [ '**/.svn/', '**/CVS/' ].join('|')
|
|
72
54
|
|
|
73
55
|
File.open(task.name, "w") do |file|
|
|
74
|
-
|
|
75
|
-
|
|
56
|
+
classpathentry = ClasspathEntryWriter.new project, file
|
|
57
|
+
classpathentry.write do
|
|
76
58
|
# Note: Use the test classpath since Eclipse compiles both "main" and "test" classes using the same classpath
|
|
77
59
|
cp = project.test.compile.dependencies.map(&:to_s) - [ project.compile.target.to_s, project.resources.target.to_s ]
|
|
78
60
|
cp = cp.uniq
|
|
@@ -89,81 +71,49 @@ module Buildr
|
|
|
89
71
|
# Generated: classpath elements in the project are assumed to be generated
|
|
90
72
|
generated, libs = others.partition { |path| path.to_s.index(project.path_to.to_s) == 0 }
|
|
91
73
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
srcs = srcs.map { |src| relative[src] } + generated.map { |src| relative[src] }
|
|
95
|
-
srcs.sort.uniq.each do |path|
|
|
96
|
-
xml.classpathentry :kind=>'src', :path=>path, :excluding=>excludes
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
# Main resources implicitly copied into project.compile.target
|
|
100
|
-
main_resource_sources = project.resources.sources.map { |src| relative[src] }
|
|
101
|
-
main_resource_sources.each do |path|
|
|
102
|
-
if File.exist? project.path_to(path)
|
|
103
|
-
xml.classpathentry :kind=>'src', :path=>path, :excluding=>excludes
|
|
104
|
-
end
|
|
105
|
-
end
|
|
74
|
+
classpathentry.src project.compile.sources + generated
|
|
75
|
+
classpathentry.src project.resources
|
|
106
76
|
|
|
107
77
|
if project.test.compile.target
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
test_sources.each do |paths|
|
|
111
|
-
paths.sort.uniq.each do |path|
|
|
112
|
-
xml.classpathentry :kind=>'src', :path=>path, :output => relative[project.test.compile.target], :excluding=>excludes
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
# Test resources go in separate output directory as well
|
|
117
|
-
project.test.resources.sources.each do |path|
|
|
118
|
-
if File.exist? project.path_to(path)
|
|
119
|
-
xml.classpathentry :kind=>'src', :path=>relative[path], :output => relative[project.test.compile.target], :excluding=>excludes
|
|
120
|
-
end
|
|
121
|
-
end
|
|
78
|
+
classpathentry.src project.test.compile
|
|
79
|
+
classpathentry.src project.test.resources
|
|
122
80
|
end
|
|
123
81
|
|
|
124
82
|
# Classpath elements from other projects
|
|
125
|
-
|
|
126
|
-
xml.classpathentry :kind=>'src', :combineaccessrules=>"false", :path=>"/#{project_id}"
|
|
127
|
-
end
|
|
83
|
+
classpathentry.src_projects project_libs
|
|
128
84
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}.each do |kind, paths|
|
|
133
|
-
paths.sort.uniq.each do |path|
|
|
134
|
-
xml.classpathentry :kind=>kind, :path=>path
|
|
135
|
-
end
|
|
136
|
-
end
|
|
85
|
+
classpathentry.output project.compile.target
|
|
86
|
+
classpathentry.lib libs
|
|
87
|
+
classpathentry.var m2_libs, 'M2_REPO', m2repo
|
|
137
88
|
|
|
138
|
-
|
|
139
|
-
|
|
89
|
+
classpathentry.con 'ch.epfl.lamp.sdt.launching.SCALA_CONTAINER' if scala
|
|
90
|
+
classpathentry.con 'org.eclipse.jdt.launching.JRE_CONTAINER'
|
|
140
91
|
end
|
|
141
92
|
end
|
|
142
93
|
end
|
|
143
94
|
|
|
144
95
|
# The only thing we need to look for is a change in the Buildfile.
|
|
145
|
-
file(project.path_to(".project")=>
|
|
146
|
-
|
|
96
|
+
file(project.path_to(".project")=>Buildr.application.buildfile) do |task|
|
|
97
|
+
info "Writing #{task.name}"
|
|
147
98
|
File.open(task.name, "w") do |file|
|
|
148
99
|
xml = Builder::XmlMarkup.new(:target=>file, :indent=>2)
|
|
149
100
|
xml.projectDescription do
|
|
150
101
|
xml.name project.id
|
|
151
102
|
xml.projects
|
|
152
103
|
xml.buildSpec do
|
|
153
|
-
xml.buildCommand do
|
|
154
|
-
xml.name "org.eclipse.jdt.core.javabuilder"
|
|
155
|
-
end
|
|
156
104
|
if scala
|
|
157
105
|
xml.buildCommand do
|
|
158
106
|
xml.name "ch.epfl.lamp.sdt.core.scalabuilder"
|
|
159
|
-
|
|
107
|
+
end
|
|
108
|
+
else
|
|
109
|
+
xml.buildCommand do
|
|
110
|
+
xml.name "org.eclipse.jdt.core.javabuilder"
|
|
160
111
|
end
|
|
161
112
|
end
|
|
162
113
|
end
|
|
163
114
|
xml.natures do
|
|
164
|
-
xml.nature "org.eclipse.jdt.core.javanature"
|
|
165
115
|
xml.nature "ch.epfl.lamp.sdt.core.scalanature" if scala
|
|
166
|
-
|
|
116
|
+
xml.nature "org.eclipse.jdt.core.javanature"
|
|
167
117
|
end
|
|
168
118
|
end
|
|
169
119
|
end
|
|
@@ -172,6 +122,87 @@ module Buildr
|
|
|
172
122
|
|
|
173
123
|
end
|
|
174
124
|
|
|
125
|
+
# Writes 'classpathentry' tags in an xml file.
|
|
126
|
+
# It converts tasks to paths.
|
|
127
|
+
# It converts absolute paths to relative paths.
|
|
128
|
+
# It ignores duplicate directories.
|
|
129
|
+
class ClasspathEntryWriter
|
|
130
|
+
def initialize project, target
|
|
131
|
+
@project = project
|
|
132
|
+
@xml = Builder::XmlMarkup.new(:target=>target, :indent=>2)
|
|
133
|
+
@excludes = [ '**/.svn/', '**/CVS/' ].join('|')
|
|
134
|
+
@paths_written = []
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def write &block
|
|
138
|
+
@xml.classpath &block
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def con path
|
|
142
|
+
@xml.classpathentry :kind=>'con', :path=>path
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def lib libs
|
|
146
|
+
libs.map(&:to_s).sort.uniq.each do |path|
|
|
147
|
+
@xml.classpathentry :kind=>'lib', :path=>path
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Write a classpathentry of kind 'src'.
|
|
152
|
+
# Accepts an array of absolute paths or a task.
|
|
153
|
+
def src arg
|
|
154
|
+
if [:sources, :target].all? { |message| arg.respond_to?(message) }
|
|
155
|
+
src_from_task arg
|
|
156
|
+
else
|
|
157
|
+
src_from_absolute_paths arg
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# Write a classpathentry of kind 'src' for dependent projects.
|
|
162
|
+
# Accepts an array of projects.
|
|
163
|
+
def src_projects project_libs
|
|
164
|
+
project_libs.map(&:id).sort.uniq.each do |project_id|
|
|
165
|
+
@xml.classpathentry :kind=>'src', :combineaccessrules=>"false", :path=>"/#{project_id}"
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def output target
|
|
170
|
+
@xml.classpathentry :kind=>'output', :path=>relative(target)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def var libs, var_name, var_value
|
|
174
|
+
libs.map { |lib| lib.to_s.sub(var_value, var_name) }.sort.uniq.each do |path|
|
|
175
|
+
@xml.classpathentry :kind=>'var', :path=>path
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
private
|
|
180
|
+
|
|
181
|
+
# Find a path relative to the project's root directory.
|
|
182
|
+
def relative path
|
|
183
|
+
path or raise "Invalid path '#{path.inspect}'"
|
|
184
|
+
msg = [:to_path, :to_str, :to_s].find { |msg| path.respond_to? msg }
|
|
185
|
+
path = path.__send__(msg)
|
|
186
|
+
Util.relative_path(File.expand_path(path), @project.path_to)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def src_from_task task
|
|
190
|
+
src_from_absolute_paths task.sources, task.target
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def src_from_absolute_paths absolute_paths, output=nil
|
|
194
|
+
relative_paths = absolute_paths.map { |src| relative(src) }
|
|
195
|
+
relative_paths.sort.uniq.each do |path|
|
|
196
|
+
unless @paths_written.include?(path)
|
|
197
|
+
attributes = { :kind=>'src', :path=>path, :excluding=>@excludes }
|
|
198
|
+
attributes[:output] = relative(output) if output
|
|
199
|
+
@xml.classpathentry attributes
|
|
200
|
+
@paths_written << path
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
175
206
|
end
|
|
176
207
|
end # module Buildr
|
|
177
208
|
|