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,20 @@
|
|
|
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'
|
|
19
|
+
require 'buildr/groovy/doc'
|
|
20
|
+
require 'buildr/groovy/shell'
|
|
@@ -0,0 +1,106 @@
|
|
|
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
|
+
# EasyB is a Groovy based BDD framework.
|
|
20
|
+
# To use in your project:
|
|
21
|
+
#
|
|
22
|
+
# test.using :easyb
|
|
23
|
+
#
|
|
24
|
+
# This framework will search in your project for:
|
|
25
|
+
# src/spec/groovy/**/*Story.groovy
|
|
26
|
+
# src/spec/groovy/**/*Specification.groovy
|
|
27
|
+
#
|
|
28
|
+
# Support the following options:
|
|
29
|
+
# * :format -- Report format :txt or :xml, default is :txt
|
|
30
|
+
# * :properties -- Hash of properties passed to the test suite.
|
|
31
|
+
# * :java_args -- Arguments passed to the JVM.
|
|
32
|
+
class EasyB < TestFramework::JavaBDD
|
|
33
|
+
@lang = :groovy
|
|
34
|
+
@bdd_dir = :spec
|
|
35
|
+
|
|
36
|
+
VERSION = "0.9"
|
|
37
|
+
TESTS_PATTERN = [ /(Story|Specification).groovy$/ ]
|
|
38
|
+
OPTIONS = [:format, :properties, :java_args]
|
|
39
|
+
|
|
40
|
+
class << self
|
|
41
|
+
def version
|
|
42
|
+
Buildr.settings.build['jbehave'] || VERSION
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def dependencies
|
|
46
|
+
@dependencies ||= ["org.easyb:easyb:jar:#{version}",
|
|
47
|
+
'org.codehaus.groovy:groovy:jar:1.5.3','asm:asm:jar:2.2.3',
|
|
48
|
+
'commons-cli:commons-cli:jar:1.0','antlr:antlr:jar:2.7.7']
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def applies_to?(project) #:nodoc:
|
|
52
|
+
%w{
|
|
53
|
+
**/*Specification.groovy **/*Story.groovy
|
|
54
|
+
}.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
def const_missing(const)
|
|
59
|
+
return super unless const == :REQUIRES # TODO: remove in 1.5
|
|
60
|
+
Buildr.application.deprecated "Please use JBehave.dependencies/.version instead of JBehave::REQUIRES/VERSION"
|
|
61
|
+
dependencies
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def tests(dependencies) #:nodoc:
|
|
66
|
+
Dir[task.project.path_to(:source, bdd_dir, lang, "**/*.groovy")].
|
|
67
|
+
select { |name| TESTS_PATTERN.any? { |pat| pat === name } }
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def run(tests, dependencies) #:nodoc:
|
|
71
|
+
options = { :format => :txt }.merge(self.options).only(*OPTIONS)
|
|
72
|
+
|
|
73
|
+
if :txt == options[:format]
|
|
74
|
+
easyb_format, ext = 'txtstory', '.txt'
|
|
75
|
+
elsif :xml == options[:format]
|
|
76
|
+
easyb_format, ext = 'xmlbehavior', '.xml'
|
|
77
|
+
else
|
|
78
|
+
raise "Invalid format #{options[:format]} expected one of :txt :xml"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
cmd_args = [ 'org.disco.easyb.BehaviorRunner' ]
|
|
82
|
+
cmd_options = { :properties => options[:properties],
|
|
83
|
+
:java_args => options[:java_args],
|
|
84
|
+
:classpath => dependencies }
|
|
85
|
+
|
|
86
|
+
tests.inject([]) do |passed, test|
|
|
87
|
+
name = test.sub(/.*?groovy[\/\\]/, '').pathmap('%X')
|
|
88
|
+
report = File.join(task.report_to.to_s, name + ext)
|
|
89
|
+
mkpath report.pathmap('%d')
|
|
90
|
+
begin
|
|
91
|
+
Java::Commands.java cmd_args,
|
|
92
|
+
"-#{easyb_format}", report,
|
|
93
|
+
test, cmd_options.merge(:name => name)
|
|
94
|
+
rescue => e
|
|
95
|
+
passed
|
|
96
|
+
else
|
|
97
|
+
passed << test
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
end # EasyB
|
|
103
|
+
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
Buildr::TestFramework << Buildr::Groovy::EasyB
|
|
@@ -0,0 +1,153 @@
|
|
|
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
|
+
REQUIRES = ArtifactNamespace.for(self) do |ns|
|
|
20
|
+
ns.jansi! 'org.fusesource.jansi:jansi:jar:1.2.1'
|
|
21
|
+
ns.jline! 'jline:jline:jar:0.9.94'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class << self
|
|
25
|
+
def dependencies #:nodoc:
|
|
26
|
+
REQUIRES.artifacts + Groovyc.dependencies
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Groovyc compiler:
|
|
31
|
+
# compile.using(:groovyc)
|
|
32
|
+
#
|
|
33
|
+
# You need to require 'buildr/groovy/compiler' if you need to use this compiler.
|
|
34
|
+
#
|
|
35
|
+
# Used by default if .groovy files are found in the src/main/groovy directory (or src/test/groovy)
|
|
36
|
+
# and sets the target directory to target/classes (or target/test/classes).
|
|
37
|
+
#
|
|
38
|
+
# Groovyc is a joint compiler, this means that when selected for a project, this compiler is used
|
|
39
|
+
# to compile both groovy and java sources. It's recommended that Groovy sources are placed in the
|
|
40
|
+
# src/main/groovy directory, even though this compiler also looks in src/main/java
|
|
41
|
+
#
|
|
42
|
+
# Groovyc accepts the following options:
|
|
43
|
+
#
|
|
44
|
+
# * :encoding -- Encoding of source files
|
|
45
|
+
# * :verbose -- Asks the compiler for verbose output, true when running in verbose mode.
|
|
46
|
+
# * :fork -- Whether to execute groovyc using a spawned instance of the JVM; defaults to no
|
|
47
|
+
# * :memoryInitialSize -- The initial size of the memory for the underlying VM, if using fork mode; ignored otherwise.
|
|
48
|
+
# Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
|
|
49
|
+
# * :memoryMaximumSize -- The maximum size of the memory for the underlying VM, if using fork mode; ignored otherwise.
|
|
50
|
+
# Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
|
|
51
|
+
# * :listfiles -- Indicates whether the source files to be compiled will be listed; defaults to no
|
|
52
|
+
# * :stacktrace -- If true each compile error message will contain a stacktrace
|
|
53
|
+
# * :warnings -- Issue warnings when compiling. True when running in verbose mode.
|
|
54
|
+
# * :debug -- Generates bytecode with debugging information. Set from the debug
|
|
55
|
+
# environment variable/global option.
|
|
56
|
+
# * :deprecation -- If true, shows deprecation messages. False by default.
|
|
57
|
+
# * :optimise -- Generates faster bytecode by applying optimisations to the program.
|
|
58
|
+
# * :source -- Source code compatibility.
|
|
59
|
+
# * :target -- Bytecode compatibility.
|
|
60
|
+
# * :javac -- Hash of options passed to the ant javac task
|
|
61
|
+
#
|
|
62
|
+
class Groovyc < Compiler::Base
|
|
63
|
+
|
|
64
|
+
# The groovyc compiler jars are added to classpath at load time,
|
|
65
|
+
# if you want to customize artifact versions, you must set them on the
|
|
66
|
+
#
|
|
67
|
+
# artifact_ns(Buildr::Groovy::Groovyc).groovy = '1.7.1'
|
|
68
|
+
#
|
|
69
|
+
# namespace before this file is required.
|
|
70
|
+
REQUIRES = ArtifactNamespace.for(self) do |ns|
|
|
71
|
+
ns.groovy! 'org.codehaus.groovy:groovy:jar:>=1.7.5'
|
|
72
|
+
ns.commons_cli! 'commons-cli:commons-cli:jar:>=1.2'
|
|
73
|
+
ns.asm! 'asm:asm:jar:>=3.2'
|
|
74
|
+
ns.antlr! 'antlr:antlr:jar:>=2.7.7'
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
ANT_TASK = 'org.codehaus.groovy.ant.Groovyc'
|
|
78
|
+
GROOVYC_OPTIONS = [:encoding, :verbose, :fork, :memoryInitialSize, :memoryMaximumSize, :listfiles, :stacktrace]
|
|
79
|
+
JAVAC_OPTIONS = [:optimise, :warnings, :debug, :deprecation, :source, :target, :javac]
|
|
80
|
+
OPTIONS = GROOVYC_OPTIONS + JAVAC_OPTIONS
|
|
81
|
+
|
|
82
|
+
class << self
|
|
83
|
+
def dependencies #:nodoc:
|
|
84
|
+
REQUIRES.artifacts
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def applies_to?(project, task) #:nodoc:
|
|
88
|
+
paths = task.sources + [sources].flatten.map { |src| Array(project.path_to(:source, task.usage, src.to_sym)) }
|
|
89
|
+
paths.flatten!
|
|
90
|
+
# Just select if we find .groovy files
|
|
91
|
+
paths.any? { |path| !Dir["#{path}/**/*.groovy"].empty? }
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Groovy dependencies don't need to go into JVM's system classpath.
|
|
96
|
+
# In fact, if they end up there it causes trouble because Groovy has issues
|
|
97
|
+
# loading other classes such as test frameworks (e.g. JUnit).
|
|
98
|
+
#
|
|
99
|
+
# Java.classpath << lambda { dependencies }
|
|
100
|
+
|
|
101
|
+
specify :language => :groovy, :sources => [:groovy, :java], :source_ext => [:groovy, :java],
|
|
102
|
+
:target => 'classes', :target_ext => 'class', :packaging => :jar
|
|
103
|
+
|
|
104
|
+
def initialize(project, options) #:nodoc:
|
|
105
|
+
super
|
|
106
|
+
options[:debug] = Buildr.options.debug if options[:debug].nil?
|
|
107
|
+
options[:deprecation] ||= false
|
|
108
|
+
options[:optimise] ||= false
|
|
109
|
+
options[:verbose] ||= trace?(:groovyc) if options[:verbose].nil?
|
|
110
|
+
options[:warnings] = verbose if options[:warnings].nil?
|
|
111
|
+
options[:javac] = OpenObject.new if options[:javac].nil?
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# http://groovy.codehaus.org/The+groovyc+Ant+Task
|
|
115
|
+
def compile(sources, target, dependencies) #:nodoc:
|
|
116
|
+
return if Buildr.application.options.dryrun
|
|
117
|
+
Buildr.ant 'groovyc' do |ant|
|
|
118
|
+
classpath = dependencies
|
|
119
|
+
ant.taskdef :name => 'groovyc', :classname => ANT_TASK, :classpath => classpath.join(File::PATH_SEPARATOR)
|
|
120
|
+
ant.groovyc groovyc_options(sources, target) do
|
|
121
|
+
sources.each { |src| ant.src :path => src }
|
|
122
|
+
ant.classpath do
|
|
123
|
+
classpath.each { |dep| ant.pathelement :path => dep }
|
|
124
|
+
end
|
|
125
|
+
ant.javac(javac_options)
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
private
|
|
131
|
+
def groovyc_options(sources, target)
|
|
132
|
+
check_options options, OPTIONS
|
|
133
|
+
groovyc_options = options.to_hash.only(*GROOVYC_OPTIONS)
|
|
134
|
+
groovyc_options[:destdir] = File.expand_path(target)
|
|
135
|
+
groovyc_options
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def javac_options
|
|
139
|
+
check_options options, OPTIONS
|
|
140
|
+
javac_options = options.to_hash.only(*JAVAC_OPTIONS)
|
|
141
|
+
javac_options[:optimize] = (javac_options.delete(:optimise) || false)
|
|
142
|
+
javac_options[:nowarn] = (javac_options.delete(:warnings) || verbose).to_s !~ /^(true|yes|on)$/i
|
|
143
|
+
other = javac_options.delete(:javac) || {}
|
|
144
|
+
javac_options.merge!(other)
|
|
145
|
+
javac_options
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Groovy compiler comes first, ahead of Javac, this allows it to pick
|
|
152
|
+
# projects that mix Groovy and Java code by spotting Groovy code first.
|
|
153
|
+
Buildr::Compiler.compilers.unshift Buildr::Groovy::Groovyc
|
|
@@ -0,0 +1,76 @@
|
|
|
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 'buildr/core/doc'
|
|
17
|
+
require 'buildr/groovy/compiler' # ensure Groovy dependencies are ready
|
|
18
|
+
|
|
19
|
+
module Buildr
|
|
20
|
+
module Doc
|
|
21
|
+
|
|
22
|
+
module GroovydocDefaults
|
|
23
|
+
include Extension
|
|
24
|
+
|
|
25
|
+
# Default groovydoc -doc-title to project's comment or name
|
|
26
|
+
after_define(:groovydoc => :doc) do |project|
|
|
27
|
+
if project.doc.engine? Groovydoc
|
|
28
|
+
options = project.doc.options
|
|
29
|
+
options[:windowtitle] = (project.comment || project.name) unless options[:windowtitle]
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class Groovydoc < Base
|
|
35
|
+
specify :language => :groovy, :source_ext => ['java', 'groovy']
|
|
36
|
+
|
|
37
|
+
def generate(sources, target, options = {})
|
|
38
|
+
mkdir_p target
|
|
39
|
+
cmd_args = [ '-d', target, trace?(:groovydoc) ? '-verbose' : nil ].compact
|
|
40
|
+
options.reject { |key, value| [:sourcepath, :classpath].include?(key) }.
|
|
41
|
+
each { |key, value| value.invoke if value.respond_to?(:invoke) }.
|
|
42
|
+
each do |key, value|
|
|
43
|
+
case value
|
|
44
|
+
when true, nil
|
|
45
|
+
cmd_args << "-#{key}"
|
|
46
|
+
when false
|
|
47
|
+
cmd_args << "-no#{key}"
|
|
48
|
+
when Hash
|
|
49
|
+
value.each { |k,v| cmd_args << "-#{key}" << k.to_s << v.to_s }
|
|
50
|
+
else
|
|
51
|
+
cmd_args += Array(value).map { |item| ["-#{key}", item.to_s] }.flatten
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
[:sourcepath, :classpath].each do |option|
|
|
55
|
+
Array(options[option]).flatten.tap do |paths|
|
|
56
|
+
cmd_args << "-#{option}" << paths.flatten.map(&:to_s).join(File::PATH_SEPARATOR) unless paths.empty?
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
cmd_args += sources.flatten.uniq
|
|
60
|
+
unless Buildr.application.options.dryrun
|
|
61
|
+
info "Generating Groovydoc for #{project.name}"
|
|
62
|
+
trace (['groovydoc'] + cmd_args).join(' ')
|
|
63
|
+
result = Java::Commands.java('org.codehaus.groovy.tools.groovydoc.Main', cmd_args,
|
|
64
|
+
:classpath => Buildr::Groovy.dependencies)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
class Project
|
|
71
|
+
include GroovydocDefaults
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
Buildr::Doc.engines << Buildr::Doc::Groovydoc
|
|
76
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
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 'buildr/shell'
|
|
17
|
+
|
|
18
|
+
module Buildr
|
|
19
|
+
module Groovy
|
|
20
|
+
class GroovySH < Buildr::Shell::Base
|
|
21
|
+
include JRebel
|
|
22
|
+
|
|
23
|
+
SUFFIX = if Util.win_os? then '.bat' else '' end
|
|
24
|
+
|
|
25
|
+
specify :name => :groovy, :languages => [:groovy]
|
|
26
|
+
|
|
27
|
+
def launch(task)
|
|
28
|
+
cp = Groovy.dependencies +
|
|
29
|
+
project.compile.dependencies +
|
|
30
|
+
[ project.path_to(:target, :classes) ] +
|
|
31
|
+
task.classpath
|
|
32
|
+
props = jrebel_props(project).merge(task.properties)
|
|
33
|
+
java_args = jrebel_args + task.java_args
|
|
34
|
+
|
|
35
|
+
groovy_home = nil
|
|
36
|
+
if groovy_home
|
|
37
|
+
cmd_args = " -classpath '#{cp.join(File::SEPARATOR)}'"
|
|
38
|
+
trace "groovysh #{cmd_args}"
|
|
39
|
+
system(File.expand_path("bin#{File::SEPARATOR}groovysh#{SUFFIX}", groovy_home) + cmd_args)
|
|
40
|
+
else
|
|
41
|
+
Java::Commands.java 'org.codehaus.groovy.tools.shell.Main', {
|
|
42
|
+
:properties => props,
|
|
43
|
+
:classpath => cp,
|
|
44
|
+
:java_args => java_args
|
|
45
|
+
}
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
def groovy_home
|
|
51
|
+
@home ||= ENV['GROOVY_HOME']
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
Buildr::Shell.providers << Buildr::Groovy::GroovySH
|
data/lib/buildr/ide.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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/ide/eclipse'
|
|
18
|
+
require 'buildr/ide/idea'
|
|
19
|
+
|
|
@@ -0,0 +1,427 @@
|
|
|
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/core/project'
|
|
18
|
+
require 'buildr/packaging'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
module Buildr
|
|
22
|
+
module Eclipse #:nodoc:
|
|
23
|
+
include Extension
|
|
24
|
+
|
|
25
|
+
class Eclipse
|
|
26
|
+
|
|
27
|
+
attr_reader :options
|
|
28
|
+
attr_writer :name
|
|
29
|
+
|
|
30
|
+
def initialize(project)
|
|
31
|
+
@project = project
|
|
32
|
+
@options = Options.new(project)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def name
|
|
36
|
+
return @name if @name
|
|
37
|
+
return @project.id.split('-').last if @options.short_names
|
|
38
|
+
@project.id
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# :call-seq:
|
|
42
|
+
# classpath_variables :VAR => '/path/to/location'
|
|
43
|
+
# Sets classpath variables to be used for library path substitution
|
|
44
|
+
# on the project.
|
|
45
|
+
#
|
|
46
|
+
def classpath_variables(*values)
|
|
47
|
+
fail "eclipse.classpath_variables expects a single hash argument" if values.size > 1
|
|
48
|
+
if values.size == 1
|
|
49
|
+
fail "eclipse.classpath_variables expects a Hash argument" unless values[0].is_a? Hash
|
|
50
|
+
# convert keys to strings
|
|
51
|
+
values = values[0].inject({}) { |h, (k,v)| h[k.to_s] = @project.path_to(v); h }
|
|
52
|
+
@variables = values.merge(@variables || {})
|
|
53
|
+
end
|
|
54
|
+
@variables || (@project.parent ? @project.parent.eclipse.classpath_variables : default_classpath_variables)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def default_classpath_variables
|
|
58
|
+
vars = {}
|
|
59
|
+
vars[:SCALA_HOME] = ENV['SCALA_HOME'] if ENV['SCALA_HOME']
|
|
60
|
+
vars[:JAVA_HOME] = ENV['JAVA_HOME'] if ENV['JAVA_HOME']
|
|
61
|
+
vars
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# :call-seq:
|
|
65
|
+
# natures=(natures)
|
|
66
|
+
# Sets the Eclipse project natures on the project.
|
|
67
|
+
#
|
|
68
|
+
def natures=(var)
|
|
69
|
+
@natures = arrayfy(var)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# :call-seq:
|
|
73
|
+
# natures() => [n1, n2]
|
|
74
|
+
# Returns the Eclipse project natures on the project.
|
|
75
|
+
# They may be derived from the parent project if no specific natures have been set
|
|
76
|
+
# on the project.
|
|
77
|
+
#
|
|
78
|
+
# An Eclipse project nature is used internally by Eclipse to determine the aspects of a project.
|
|
79
|
+
def natures(*values)
|
|
80
|
+
if values.size > 0
|
|
81
|
+
@natures ||= []
|
|
82
|
+
@natures += values.flatten
|
|
83
|
+
else
|
|
84
|
+
@natures || (@project.parent ? @project.parent.eclipse.natures : [])
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# :call-seq:
|
|
89
|
+
# classpath_containers=(cc)
|
|
90
|
+
# Sets the Eclipse project classpath containers on the project.
|
|
91
|
+
#
|
|
92
|
+
def classpath_containers=(var)
|
|
93
|
+
@classpath_containers = arrayfy(var)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# :call-seq:
|
|
97
|
+
# classpath_containers() => [con1, con2]
|
|
98
|
+
# Returns the Eclipse project classpath containers on the project.
|
|
99
|
+
# They may be derived from the parent project if no specific classpath containers have been set
|
|
100
|
+
# on the project.
|
|
101
|
+
#
|
|
102
|
+
# A classpath container is an Eclipse pre-determined ensemble of dependencies made available to
|
|
103
|
+
# the project classpath.
|
|
104
|
+
def classpath_containers(*values)
|
|
105
|
+
if values.size > 0
|
|
106
|
+
@classpath_containers ||= []
|
|
107
|
+
@classpath_containers += values.flatten
|
|
108
|
+
else
|
|
109
|
+
@classpath_containers || (@project.parent ? @project.parent.eclipse.classpath_containers : [])
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# :call-seq:
|
|
114
|
+
# exclude_libs() => [lib1, lib2]
|
|
115
|
+
# Returns the an array of libraries to be excluded from the generated Eclipse classpath
|
|
116
|
+
def exclude_libs(*values)
|
|
117
|
+
if values.size > 0
|
|
118
|
+
@exclude_libs ||= []
|
|
119
|
+
@exclude_libs += values.flatten
|
|
120
|
+
else
|
|
121
|
+
@exclude_libs || (@project.parent ? @project.parent.eclipse.exclude_libs : [])
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# :call-seq:
|
|
126
|
+
# exclude_libs=(lib1, lib2)
|
|
127
|
+
# Sets libraries to be excluded from the generated Eclipse classpath
|
|
128
|
+
#
|
|
129
|
+
def exclude_libs=(libs)
|
|
130
|
+
@exclude_libs = arrayfy(libs)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# :call-seq:
|
|
134
|
+
# builders=(builders)
|
|
135
|
+
# Sets the Eclipse project builders on the project.
|
|
136
|
+
#
|
|
137
|
+
def builders=(var)
|
|
138
|
+
@builders = arrayfy(var)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# :call-seq:
|
|
142
|
+
# builders() => [b1, b2]
|
|
143
|
+
# Returns the Eclipse project builders on the project.
|
|
144
|
+
# They may be derived from the parent project if no specific builders have been set
|
|
145
|
+
# on the project.
|
|
146
|
+
#
|
|
147
|
+
# A builder is an Eclipse background job that parses the source code to produce built artifacts.
|
|
148
|
+
def builders(*values)
|
|
149
|
+
if values.size > 0
|
|
150
|
+
@builders ||= []
|
|
151
|
+
@builders += values.flatten
|
|
152
|
+
else
|
|
153
|
+
@builders || (@project.parent ? @project.parent.eclipse.builders : [])
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
private
|
|
158
|
+
|
|
159
|
+
def arrayfy(obj)
|
|
160
|
+
obj.is_a?(Array) ? obj : [obj]
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
class Options
|
|
165
|
+
|
|
166
|
+
attr_writer :m2_repo_var, :short_names
|
|
167
|
+
|
|
168
|
+
def initialize(project)
|
|
169
|
+
@project = project
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# The classpath variable used to point at the local maven2 repository.
|
|
173
|
+
# Example:
|
|
174
|
+
# eclipse.options.m2_repo_var = 'M2_REPO'
|
|
175
|
+
def m2_repo_var(*values)
|
|
176
|
+
fail "m2_repo_var can only accept one value: #{values}" if values.size > 1
|
|
177
|
+
if values.size > 0
|
|
178
|
+
@m2_repo_var = values[0]
|
|
179
|
+
else
|
|
180
|
+
@m2_repo_var || (@project.parent ? @project.parent.eclipse.options.m2_repo_var : 'M2_REPO')
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def short_names
|
|
185
|
+
@short_names || (@project.parent ? @project.parent.eclipse.options.short_names : false)
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def eclipse
|
|
190
|
+
@eclipse ||= Eclipse.new(self)
|
|
191
|
+
@eclipse
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
first_time do
|
|
195
|
+
# Global task "eclipse" generates artifacts for all projects.
|
|
196
|
+
desc 'Generate Eclipse artifacts for all projects'
|
|
197
|
+
Project.local_task('eclipse'=>'artifacts') { |name| "Generating Eclipse project for #{name}" }
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
before_define do |project|
|
|
201
|
+
project.recursive_task('eclipse')
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
after_define(:eclipse => :package) do |project|
|
|
205
|
+
# Need to enhance because using project.projects during load phase of the
|
|
206
|
+
# buildfile has harmful side-effects on project definition order
|
|
207
|
+
project.enhance do
|
|
208
|
+
eclipse = project.task('eclipse')
|
|
209
|
+
# We don't create the .project and .classpath files if the project contains projects.
|
|
210
|
+
if project.projects.empty?
|
|
211
|
+
|
|
212
|
+
eclipse.enhance [ file(project.path_to('.classpath')), file(project.path_to('.project')) ]
|
|
213
|
+
|
|
214
|
+
# The only thing we need to look for is a change in the Buildfile.
|
|
215
|
+
file(project.path_to('.classpath')=>Buildr.application.buildfile) do |task|
|
|
216
|
+
if (project.eclipse.natures.reject { |x| x.is_a?(Symbol) }.size > 0)
|
|
217
|
+
info "Writing #{task.name}"
|
|
218
|
+
|
|
219
|
+
m2repo = Buildr::Repositories.instance.local
|
|
220
|
+
|
|
221
|
+
File.open(task.name, 'w') do |file|
|
|
222
|
+
classpathentry = ClasspathEntryWriter.new project, file
|
|
223
|
+
classpathentry.write do
|
|
224
|
+
# Note: Use the test classpath since Eclipse compiles both "main" and "test" classes using the same classpath
|
|
225
|
+
cp = project.test.compile.dependencies.map(&:to_s) - [ project.compile.target.to_s, project.resources.target.to_s ]
|
|
226
|
+
cp = cp.uniq
|
|
227
|
+
|
|
228
|
+
# Convert classpath elements into applicable Project objects
|
|
229
|
+
cp.collect! { |path| Buildr.projects.detect { |prj| prj.packages.detect { |pkg| pkg.to_s == path } } || path }
|
|
230
|
+
|
|
231
|
+
# Remove excluded libs
|
|
232
|
+
cp -= project.eclipse.exclude_libs.map(&:to_s)
|
|
233
|
+
|
|
234
|
+
# project_libs: artifacts created by other projects
|
|
235
|
+
project_libs, others = cp.partition { |path| path.is_a?(Project) }
|
|
236
|
+
|
|
237
|
+
# Separate artifacts under known classpath variable paths
|
|
238
|
+
# including artifacts located in local Maven2 repository
|
|
239
|
+
vars = []
|
|
240
|
+
project.eclipse.classpath_variables.merge(project.eclipse.options.m2_repo_var => m2repo).each do |name, path|
|
|
241
|
+
matching, others = others.partition { |f| File.expand_path(f.to_s).index(path) == 0 }
|
|
242
|
+
matching.each do |m|
|
|
243
|
+
vars << [m, name, path]
|
|
244
|
+
end
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
# Generated: Any non-file classpath elements in the project are assumed to be generated
|
|
248
|
+
libs, generated = others.partition { |path| File.file?(path.to_s) }
|
|
249
|
+
|
|
250
|
+
classpathentry.src project.compile.sources + generated
|
|
251
|
+
classpathentry.src project.resources
|
|
252
|
+
|
|
253
|
+
if project.test.compile.target
|
|
254
|
+
classpathentry.src project.test.compile
|
|
255
|
+
classpathentry.src project.test.resources
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
# Classpath elements from other projects
|
|
259
|
+
classpathentry.src_projects project_libs
|
|
260
|
+
|
|
261
|
+
classpathentry.output project.compile.target if project.compile.target
|
|
262
|
+
classpathentry.lib libs
|
|
263
|
+
classpathentry.var vars
|
|
264
|
+
|
|
265
|
+
project.eclipse.classpath_containers.each { |container|
|
|
266
|
+
classpathentry.con container
|
|
267
|
+
}
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
# The only thing we need to look for is a change in the Buildfile.
|
|
274
|
+
file(project.path_to('.project')=>Buildr.application.buildfile) do |task|
|
|
275
|
+
info "Writing #{task.name}"
|
|
276
|
+
File.open(task.name, 'w') do |file|
|
|
277
|
+
xml = Builder::XmlMarkup.new(:target=>file, :indent=>2)
|
|
278
|
+
xml.projectDescription do
|
|
279
|
+
xml.name project.eclipse.name
|
|
280
|
+
xml.projects
|
|
281
|
+
unless project.eclipse.builders.empty?
|
|
282
|
+
xml.buildSpec do
|
|
283
|
+
project.eclipse.builders.each { |builder|
|
|
284
|
+
xml.buildCommand do
|
|
285
|
+
xml.name builder
|
|
286
|
+
end
|
|
287
|
+
}
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
unless project.eclipse.natures.empty?
|
|
291
|
+
xml.natures do
|
|
292
|
+
project.eclipse.natures.each { |nature|
|
|
293
|
+
xml.nature nature unless nature.is_a? Symbol
|
|
294
|
+
}
|
|
295
|
+
end
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
# Writes 'classpathentry' tags in an xml file.
|
|
306
|
+
# It converts tasks to paths.
|
|
307
|
+
# It converts absolute paths to relative paths.
|
|
308
|
+
# It ignores duplicate directories.
|
|
309
|
+
class ClasspathEntryWriter #:nodoc:
|
|
310
|
+
def initialize project, target
|
|
311
|
+
@project = project
|
|
312
|
+
@xml = Builder::XmlMarkup.new(:target=>target, :indent=>2)
|
|
313
|
+
@excludes = [ '**/.svn/', '**/CVS/' ].join('|')
|
|
314
|
+
@paths_written = []
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
def write &block
|
|
318
|
+
@xml.classpath &block
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
def con path
|
|
322
|
+
@xml.classpathentry :kind=>'con', :path=>path
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
def lib libs
|
|
326
|
+
libs.map(&:to_s).sort.uniq.each do |path|
|
|
327
|
+
@xml.classpathentry :kind=>'lib', :path=>relative(path)
|
|
328
|
+
end
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
# Write a classpathentry of kind 'src'.
|
|
332
|
+
# Accept an array of absolute paths or a task.
|
|
333
|
+
def src arg
|
|
334
|
+
if [:sources, :target].all? { |message| arg.respond_to?(message) }
|
|
335
|
+
src_from_task arg
|
|
336
|
+
else
|
|
337
|
+
src_from_absolute_paths arg
|
|
338
|
+
end
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
# Write a classpathentry of kind 'src' for dependent projects.
|
|
342
|
+
# Accept an array of projects.
|
|
343
|
+
def src_projects project_libs
|
|
344
|
+
project_libs.map { |project| project.eclipse.name }.sort.uniq.each do |eclipse_name|
|
|
345
|
+
@xml.classpathentry :kind=>'src', :combineaccessrules=>'false', :path=>"/#{eclipse_name}"
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
def output target
|
|
350
|
+
@xml.classpathentry :kind=>'output', :path=>relative(target)
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
# Write a classpathentry of kind 'var' (variable) for a library in a local repo.
|
|
354
|
+
# * +libs+ is an array of library paths.
|
|
355
|
+
# * +var_name+ is a variable name as defined in Eclipse (e.g., 'M2_REPO').
|
|
356
|
+
# * +var_value+ is the value of this variable (e.g., '/home/me/.m2').
|
|
357
|
+
# E.g., <tt>var([lib1, lib2], 'M2_REPO', '/home/me/.m2/repo')</tt>
|
|
358
|
+
def var(libs)
|
|
359
|
+
libs.each do |lib_path, var_name, var_value|
|
|
360
|
+
lib_artifact = file(lib_path)
|
|
361
|
+
|
|
362
|
+
attribs = { :kind => 'var', :path => lib_path }
|
|
363
|
+
|
|
364
|
+
if lib_artifact.respond_to? :sources_artifact
|
|
365
|
+
attribs[:sourcepath] = lib_artifact.sources_artifact
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
if lib_artifact.respond_to? :javadoc_artifact
|
|
369
|
+
attribs[:javadocpath] = lib_artifact.javadoc_artifact
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
# make all paths relative
|
|
373
|
+
attribs.each_key do |k|
|
|
374
|
+
attribs[k] = attribs[k].to_s.sub(var_value, var_name.to_s) if k.to_s =~ /path/
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
@xml.classpathentry attribs
|
|
378
|
+
end
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
private
|
|
382
|
+
|
|
383
|
+
# Find a path relative to the project's root directory if possible. If the
|
|
384
|
+
# two paths do not share the same root the absolute path is returned. This
|
|
385
|
+
# can happen on Windows, for instance, when the two paths are not on the
|
|
386
|
+
# same drive.
|
|
387
|
+
def relative path
|
|
388
|
+
path or raise "Invalid path '#{path.inspect}'"
|
|
389
|
+
msg = [:to_path, :to_str, :to_s].find { |msg| path.respond_to? msg }
|
|
390
|
+
path = path.__send__(msg)
|
|
391
|
+
begin
|
|
392
|
+
Util.relative_path(File.expand_path(path), @project.path_to)
|
|
393
|
+
rescue ArgumentError
|
|
394
|
+
File.expand_path(path)
|
|
395
|
+
end
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
def src_from_task task
|
|
399
|
+
src_from_absolute_paths task.sources, task.target
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
def src_from_absolute_paths absolute_paths, output=nil
|
|
403
|
+
relative_paths = absolute_paths.map { |src| relative(src) }
|
|
404
|
+
relative_paths.sort.uniq.each do |path|
|
|
405
|
+
unless @paths_written.include?(path)
|
|
406
|
+
attributes = { :kind=>'src', :path=>path, :excluding=>@excludes }
|
|
407
|
+
attributes[:output] = relative(output) if output
|
|
408
|
+
@xml.classpathentry attributes
|
|
409
|
+
@paths_written << path
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
end
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
end # module Buildr
|
|
418
|
+
|
|
419
|
+
class Buildr::Project
|
|
420
|
+
include Buildr::Eclipse
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
# Order is significant for auto-detection, from most specific to least
|
|
424
|
+
require 'buildr/ide/eclipse/plugin'
|
|
425
|
+
require 'buildr/ide/eclipse/scala'
|
|
426
|
+
require 'buildr/ide/eclipse/java'
|
|
427
|
+
|