buildr 1.4.7.pre2-java → 1.4.8-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 +65 -2
- data/Rakefile +3 -6
- data/addon/buildr/bnd.rb +13 -3
- data/addon/buildr/{checkstyle.rake → checkstyle.rb} +1 -1
- data/addon/buildr/{findbugs.rake → findbugs.rb} +0 -0
- data/addon/buildr/git_auto_version.rb +33 -0
- data/addon/buildr/gwt.rb +82 -0
- data/addon/buildr/jacoco.rb +194 -0
- data/addon/buildr/{javancss.rake → javancss.rb} +0 -0
- data/addon/buildr/nailgun.rb +2 -2
- data/addon/buildr/{pmd.rake → pmd.rb} +3 -1
- data/addon/buildr/sonar.rb +142 -0
- data/buildr.buildfile +1 -1
- data/buildr.gemspec +37 -26
- data/doc/_layouts/default.html +0 -2
- data/doc/contributing.textile +47 -0
- data/doc/download.textile +24 -0
- data/doc/index.textile +43 -23
- data/doc/languages.textile +65 -6
- data/doc/more_stuff.textile +43 -0
- data/doc/packaging.textile +2 -0
- data/doc/settings_profiles.textile +1 -1
- data/etc/KEYS +44 -0
- data/lib/buildr.rb +3 -7
- data/lib/buildr/core/application.rb +41 -8
- data/lib/buildr/core/build.rb +102 -1
- data/lib/buildr/core/cc.rb +14 -8
- data/lib/buildr/core/doc.rb +9 -3
- data/lib/buildr/core/generate.rb +150 -9
- data/lib/buildr/core/run.rb +1 -1
- data/lib/buildr/core/shell.rb +1 -1
- data/lib/buildr/core/test.rb +1 -1
- data/lib/buildr/core/util.rb +5 -5
- data/lib/buildr/ide/eclipse.rb +118 -4
- data/lib/buildr/ide/idea.rb +278 -1
- data/lib/buildr/java/ant.rb +2 -3
- data/lib/buildr/java/bdd.rb +4 -4
- data/lib/buildr/java/commands.rb +1 -1
- data/lib/buildr/java/pom.rb +5 -4
- data/lib/buildr/java/rjb.rb +5 -4
- data/lib/buildr/java/test_result.rb +4 -0
- data/lib/buildr/packaging/artifact.rb +1 -1
- data/lib/buildr/packaging/version_requirement.rb +1 -1
- data/lib/buildr/packaging/zip.rb +1 -1
- data/lib/buildr/packaging/ziptask.rb +2 -2
- data/lib/buildr/run.rb +3 -2
- data/lib/buildr/scala.rb +1 -1
- data/lib/buildr/scala/bdd.rb +9 -2
- data/lib/buildr/scala/compiler.rb +94 -4
- data/lib/buildr/scala/doc.rb +17 -5
- data/lib/buildr/scala/org/apache/buildr/Specs2Runner.class +0 -0
- data/lib/buildr/scala/tests.rb +15 -4
- data/lib/buildr/version.rb +1 -1
- data/rakelib/all-in-one.rake +50 -47
- data/rakelib/checks.rake +4 -4
- data/rakelib/doc.rake +84 -87
- data/rakelib/metrics.rake +9 -9
- data/rakelib/package.rake +14 -35
- data/rakelib/release.rake +11 -12
- data/rakelib/rspec.rake +73 -60
- data/rakelib/stage.rake +32 -54
- data/spec/addon/bnd_spec.rb +61 -7
- data/spec/core/application_spec.rb +1 -1
- data/spec/core/build_spec.rb +117 -0
- data/spec/core/cc_spec.rb +37 -15
- data/spec/core/common_spec.rb +3 -2
- data/spec/core/compile_spec.rb +3 -3
- data/spec/core/doc_spec.rb +1 -1
- data/spec/core/generate_from_eclipse_spec.rb +280 -0
- data/spec/core/run_spec.rb +17 -4
- data/spec/core/test_spec.rb +5 -3
- data/spec/ide/idea_spec.rb +2 -2
- data/spec/java/bdd_spec.rb +2 -2
- data/spec/java/cobertura_spec.rb +4 -0
- data/spec/java/emma_spec.rb +4 -1
- data/spec/java/java_spec.rb +1 -1
- data/spec/java/packaging_spec.rb +2 -1
- data/spec/java/pom_spec.rb +125 -0
- data/spec/packaging/archive_spec.rb +25 -2
- data/spec/packaging/artifact_spec.rb +3 -3
- data/spec/sandbox.rb +7 -2
- data/spec/scala/compiler_spec.rb +41 -0
- data/spec/scala/doc_spec.rb +22 -3
- data/spec/scala/scala.rb +2 -2
- data/spec/scala/tests_spec.rb +2 -2
- data/spec/spec_helpers.rb +6 -1
- data/spec/version_requirement_spec.rb +2 -0
- metadata +651 -480
- data/lib/buildr/ide/eclipse/java.rb +0 -49
- data/lib/buildr/ide/eclipse/plugin.rb +0 -67
- data/lib/buildr/ide/eclipse/scala.rb +0 -64
data/lib/buildr/core/cc.rb
CHANGED
@@ -53,21 +53,27 @@ module Buildr
|
|
53
53
|
build_failed(project, ex)
|
54
54
|
end
|
55
55
|
|
56
|
-
|
56
|
+
srcs = []
|
57
57
|
each_project do |p|
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
srcs += p.compile.sources.map(&:to_s)
|
59
|
+
srcs += p.test.compile.sources.map(&:to_s)
|
60
|
+
srcs += p.resources.sources.map(&:to_s)
|
61
61
|
end
|
62
|
-
if
|
63
|
-
info "Monitoring directory: #{
|
62
|
+
if srcs.length == 1
|
63
|
+
info "Monitoring directory: #{srcs.first}"
|
64
64
|
else
|
65
|
-
info "Monitoring directories: [#{
|
65
|
+
info "Monitoring directories: [#{srcs.join ', '}]"
|
66
66
|
end
|
67
67
|
|
68
68
|
timestamps = lambda do
|
69
69
|
times = {}
|
70
|
-
|
70
|
+
srcs.each do |a|
|
71
|
+
if File.directory? a
|
72
|
+
Dir.glob("#{a}/**/*").map { |f| times[f] = File.mtime f }
|
73
|
+
elsif File.exist? a
|
74
|
+
times[a] = File.mtime a
|
75
|
+
end
|
76
|
+
end
|
71
77
|
times
|
72
78
|
end
|
73
79
|
|
data/lib/buildr/core/doc.rb
CHANGED
@@ -112,7 +112,13 @@ module Buildr
|
|
112
112
|
# Includes additional source files and directories when generating the documentation
|
113
113
|
# and returns self. When specifying a directory, includes all source files in that directory.
|
114
114
|
def include(*files)
|
115
|
-
|
115
|
+
files.each do |file|
|
116
|
+
if file.respond_to? :to_ary
|
117
|
+
include(*file.to_ary)
|
118
|
+
else
|
119
|
+
@files.include *files.flatten.compact.collect { |f| File.expand_path(f.to_s) }
|
120
|
+
end
|
121
|
+
end
|
116
122
|
self
|
117
123
|
end
|
118
124
|
|
@@ -121,7 +127,7 @@ module Buildr
|
|
121
127
|
#
|
122
128
|
# Excludes source files and directories from generating the documentation.
|
123
129
|
def exclude(*files)
|
124
|
-
@files.exclude *files
|
130
|
+
@files.exclude *files.collect{|f|File.expand_path(f)}
|
125
131
|
self
|
126
132
|
end
|
127
133
|
|
@@ -205,7 +211,7 @@ module Buildr
|
|
205
211
|
def source_files #:nodoc:
|
206
212
|
@source_files ||= @files.map(&:to_s).map do |file|
|
207
213
|
Array(engine.class.source_ext).map do |ext|
|
208
|
-
File.directory?(file) ? FileList[File.join(file, "**/*.#{ext}")] : file
|
214
|
+
File.directory?(file) ? FileList[File.join(file, "**/*.#{ext}")] : File.expand_path(file)
|
209
215
|
end
|
210
216
|
end.flatten.reject { |file| @files.exclude?(file) }
|
211
217
|
end
|
data/lib/buildr/core/generate.rb
CHANGED
@@ -20,7 +20,7 @@ module Buildr
|
|
20
20
|
script = nil
|
21
21
|
choose do |menu|
|
22
22
|
menu.header = "To use Buildr you need a buildfile. Do you want me to create one?"
|
23
|
-
|
23
|
+
menu.choice("From eclipse .project files") { script = Generate.from_eclipse(Dir.pwd).join("\n") } if has_eclipse_project?
|
24
24
|
menu.choice("From maven2 pom file") { script = Generate.from_maven2_pom('pom.xml').join("\n") } if File.exists?("pom.xml")
|
25
25
|
menu.choice("From directory structure") { script = Generate.from_directory(Dir.pwd).join("\n") }
|
26
26
|
menu.choice("Skip") { }
|
@@ -35,14 +35,40 @@ module Buildr
|
|
35
35
|
|
36
36
|
class << self
|
37
37
|
|
38
|
+
def compatibility_option(path)
|
39
|
+
# compile.options.target = '1.5'
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_project_natures(projectFile)
|
43
|
+
return nil unless File.exists?(projectFile)
|
44
|
+
File.open(projectFile) do |f|
|
45
|
+
root = REXML::Document.new(f).root
|
46
|
+
return nil if root == nil
|
47
|
+
natures = root.elements.collect("natures/nature") { |n| n.text }
|
48
|
+
return natures if natures
|
49
|
+
end
|
50
|
+
return nil
|
51
|
+
end
|
52
|
+
|
53
|
+
def get_build_property(path, propertyName)
|
54
|
+
propertiesFile = File.join(path, 'build.properties')
|
55
|
+
return nil unless File.exists?(propertiesFile)
|
56
|
+
inhalt = Hash.from_java_properties(File.read(propertiesFile))
|
57
|
+
binDef = inhalt[propertyName]
|
58
|
+
end
|
59
|
+
|
60
|
+
def has_eclipse_project?
|
61
|
+
candidates = Dir.glob("**/.project")
|
62
|
+
return false if candidates.size == 0
|
63
|
+
candidates.find { |x| get_project_natures(x) }
|
64
|
+
return candidates.size > 0
|
65
|
+
end
|
66
|
+
|
67
|
+
|
38
68
|
HEADER = "# Generated by Buildr #{Buildr::VERSION}, change to your liking\n\n"
|
39
69
|
|
40
|
-
def
|
41
|
-
|
42
|
-
name = File.basename(path)
|
43
|
-
if root
|
44
|
-
script = HEADER.split("\n")
|
45
|
-
header = <<-EOF
|
70
|
+
def getEclipseBuildfileHeader(path, name)
|
71
|
+
x = <<-EOF
|
46
72
|
#{"require 'buildr/scala'\n" if Dir.glob(path + "/**/*.scala").size > 0}
|
47
73
|
#{"require 'buildr/groovy'\n" if Dir.glob(path + "/**/*.groovy").size > 0}
|
48
74
|
# Version number for this release
|
@@ -52,7 +78,7 @@ GROUP = "#{name}"
|
|
52
78
|
COPYRIGHT = ""
|
53
79
|
|
54
80
|
# Specify Maven 2.0 remote repositories here, like this:
|
55
|
-
repositories.remote << "http://
|
81
|
+
repositories.remote << "http://repo1.maven.org/maven2"
|
56
82
|
|
57
83
|
desc "The #{name.capitalize} project"
|
58
84
|
define "#{name}" do
|
@@ -61,6 +87,121 @@ define "#{name}" do
|
|
61
87
|
project.group = GROUP
|
62
88
|
manifest["Implementation-Vendor"] = COPYRIGHT
|
63
89
|
EOF
|
90
|
+
return x
|
91
|
+
end
|
92
|
+
|
93
|
+
def setLayout(source=nil, output = nil)
|
94
|
+
script = ""
|
95
|
+
if source
|
96
|
+
source = source.sub(/\/$/, '') # remove trailing /
|
97
|
+
script += <<-EOF
|
98
|
+
layout[:source, :main, :java] = "#{source}"
|
99
|
+
layout[:source, :main, :scala] = "#{source}"
|
100
|
+
EOF
|
101
|
+
end
|
102
|
+
if output
|
103
|
+
output = output.sub(/\/$/, '') # remove trailing /
|
104
|
+
script += <<-EOF
|
105
|
+
layout[:target, :main] = "#{output}"
|
106
|
+
layout[:target, :main, :java] = "#{output}"
|
107
|
+
layout[:target, :main, :scala] = "#{output}"
|
108
|
+
EOF
|
109
|
+
end
|
110
|
+
return script
|
111
|
+
end
|
112
|
+
|
113
|
+
# tries to read as much information as needed at the moment from an existing Eclipse workspace
|
114
|
+
# Here are some links to the relevant information
|
115
|
+
# * http://help.eclipse.org/juno/index.jsp?topic=/org.eclipse.pde.doc.user/reference/pde_feature_generating_build.htm
|
116
|
+
# * http://wiki.eclipse.org/FAQ_What_is_the_plug-in_manifest_file_%28plugin.xml%29%3F
|
117
|
+
# * http://help.eclipse.org/juno/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/bundle_manifest.html
|
118
|
+
# * http://help.eclipse.org/juno/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/plugin_manifest.html
|
119
|
+
# * http://help.eclipse.org/juno/index.jsp?topic=/org.eclipse.pde.doc.user/tasks/pde_compilation_env.htm
|
120
|
+
def from_eclipse(path = Dir.pwd, root = true)
|
121
|
+
# We need two passes to be able to determine the dependencies correctly
|
122
|
+
Dir.chdir(path) do
|
123
|
+
name = File.basename(path)
|
124
|
+
dot_projects = []
|
125
|
+
mf = nil # avoid reloading manifest
|
126
|
+
if root
|
127
|
+
@@allProjects = Hash.new
|
128
|
+
@@topDir = File.expand_path(Dir.pwd)
|
129
|
+
script = HEADER.split("\n")
|
130
|
+
script << "require 'buildr/ide/eclipse'"
|
131
|
+
header = getEclipseBuildfileHeader(path, name)
|
132
|
+
script += header.split("\n")
|
133
|
+
script << " # you may see hints about which jars are missing and should resolve them correctly"
|
134
|
+
script << " # dependencies << 'junit should be commented out and replace by correct ARTIFACT definition. Eg"
|
135
|
+
script << " # dependencies << 'junit:junit:jar:3.8.2'"
|
136
|
+
script << setLayout('src', 'bin') # default values for eclipse
|
137
|
+
dot_projects = Dir.glob('**/.project').find_all { |dot_project| get_project_natures(dot_project) }
|
138
|
+
dot_projects.sort.each { |dot_project| from_eclipse(File.dirname(dot_project), false) } if dot_projects
|
139
|
+
else
|
140
|
+
# Skip fragments. Buildr cannot handle it without the help of buildr4osgi
|
141
|
+
return [""] if File.exists?('fragment.xml')
|
142
|
+
projectName = name
|
143
|
+
version = ""
|
144
|
+
mfName = File.join('META-INF', 'MANIFEST.MF')
|
145
|
+
if File.exists?(mfName)
|
146
|
+
mf = Packaging::Java::Manifest.parse(IO.readlines(mfName).join(''))
|
147
|
+
if mf.main['Bundle-SymbolicName']
|
148
|
+
projectName = mf.main['Bundle-SymbolicName'].split(';')[0]
|
149
|
+
bundleVersion = mf.main['Bundle-Version']
|
150
|
+
version = ", :version => \"#{bundleVersion}\"" unless "1.0.0".eql?(bundleVersion)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
# in the first run we just want to know that we exist
|
154
|
+
unless @@allProjects[projectName]
|
155
|
+
@@allProjects[projectName] = Dir.pwd
|
156
|
+
return
|
157
|
+
end
|
158
|
+
base_dir = ""
|
159
|
+
unless File.join(@@topDir, projectName).eql?(File.expand_path(Dir.pwd))
|
160
|
+
base_dir = ", :base_dir => \"#{File.expand_path(Dir.pwd).sub(@@topDir+File::SEPARATOR, '')}\""
|
161
|
+
end
|
162
|
+
script = [%{define "#{projectName}"#{version}#{base_dir} do}]
|
163
|
+
end
|
164
|
+
natures = get_project_natures('.project')
|
165
|
+
if natures && natures.index('org.eclipse.pde.PluginNature')
|
166
|
+
script << " package(:jar)"
|
167
|
+
end
|
168
|
+
if mf && mf.main['Require-Bundle']
|
169
|
+
mf.main['Require-Bundle'].split(',').each do
|
170
|
+
|bundle|
|
171
|
+
requiredName = bundle.split(';')[0]
|
172
|
+
if @@allProjects.has_key?(requiredName)
|
173
|
+
script << " dependencies << projects(\"#{requiredName}\")"
|
174
|
+
else
|
175
|
+
script << " # dependencies << '#{requiredName}'"
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
script << " compile.with dependencies # Add more classpath dependencies" if Dir.glob(File.join('src', '**', '*.java')).size > 0
|
180
|
+
script << " resources" if File.exist?("rsc")
|
181
|
+
sourceProp = get_build_property('.', 'source..')
|
182
|
+
outputProp = get_build_property('.', 'output..')
|
183
|
+
if (sourceProp && !/src\/+/.match(sourceProp)) or (outputProp && !/bin\/+/.match(outputProp))
|
184
|
+
setLayout(sourceProp, outputProp) # default values are overridden in this project
|
185
|
+
end
|
186
|
+
unless dot_projects.empty?
|
187
|
+
script << ""
|
188
|
+
dot_projects.sort.each do |dot_project|
|
189
|
+
next if File.dirname(File.expand_path(dot_project)).eql?(File.expand_path(Dir.pwd))
|
190
|
+
next unless get_project_natures(dot_project)
|
191
|
+
script << from_eclipse(File.dirname(dot_project), false).flatten.map { |line| " " + line } << ""
|
192
|
+
end
|
193
|
+
end
|
194
|
+
script << "end\n\n"
|
195
|
+
script.flatten
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def from_directory(path = Dir.pwd, root = true)
|
200
|
+
Dir.chdir(path) do
|
201
|
+
name = File.basename(path)
|
202
|
+
if root
|
203
|
+
script = HEADER.split("\n")
|
204
|
+
header = getEclipseBuildfileHeader(path, name)
|
64
205
|
script += header.split("\n")
|
65
206
|
else
|
66
207
|
script = [ %{define "#{name}" do} ]
|
@@ -122,7 +263,7 @@ define "#{name}" do
|
|
122
263
|
legacy = repository["layout"].to_s =~ /legacy/
|
123
264
|
!legacy
|
124
265
|
} rescue nil
|
125
|
-
repositories = [{"name" => "Standard maven2 repository", "url" => "http://
|
266
|
+
repositories = [{"name" => "Standard maven2 repository", "url" => "http://repo1.maven.org/maven2"}] if repositories.nil? || repositories.empty?
|
126
267
|
repositories.each do |repository|
|
127
268
|
name, url = repository["name"], repository["url"]
|
128
269
|
script << "# #{name}"
|
data/lib/buildr/core/run.rb
CHANGED
@@ -23,7 +23,7 @@ module Buildr
|
|
23
23
|
|
24
24
|
def run(task)
|
25
25
|
fail "Missing :main option" unless task.options[:main]
|
26
|
-
cp = project.compile.dependencies + [project.path_to(:target, :classes)] + task.classpath
|
26
|
+
cp = project.compile.dependencies + [project.path_to(:target, :classes), project.path_to(:target, :resources)] + task.classpath
|
27
27
|
Java::Commands.java(task.options[:main], {
|
28
28
|
:properties => jrebel_props(project).merge(task.options[:properties] || {}),
|
29
29
|
:classpath => cp,
|
data/lib/buildr/core/shell.rb
CHANGED
@@ -115,7 +115,7 @@ module Buildr
|
|
115
115
|
|
116
116
|
private
|
117
117
|
def jruby_home
|
118
|
-
@jruby_home ||= RUBY_PLATFORM =~ /java/ ?
|
118
|
+
@jruby_home ||= RUBY_PLATFORM =~ /java/ ? RbConfig::CONFIG['prefix'] : ENV['JRUBY_HOME']
|
119
119
|
end
|
120
120
|
|
121
121
|
def jruby_artifact
|
data/lib/buildr/core/test.rb
CHANGED
@@ -139,7 +139,7 @@ module Buildr
|
|
139
139
|
# cases are written in Java, then JUnit is selected as the test framework. You can also select
|
140
140
|
# a specific test framework, for example, to use TestNG instead of JUnit:
|
141
141
|
# test.using :testng
|
142
|
-
class TestTask < Rake::Task
|
142
|
+
class TestTask < ::Rake::Task
|
143
143
|
|
144
144
|
class << self
|
145
145
|
|
data/lib/buildr/core/util.rb
CHANGED
@@ -32,7 +32,7 @@ module Buildr
|
|
32
32
|
# For JRuby, the value for RUBY_PLATFORM will always be 'java'
|
33
33
|
# That's why this function checks on Config::CONFIG['host_os']
|
34
34
|
def win_os?
|
35
|
-
|
35
|
+
RbConfig::CONFIG['host_os'] =~ /windows|cygwin|bccwin|cygwin|djgpp|mingw|mswin|wince/i
|
36
36
|
end
|
37
37
|
|
38
38
|
# Runs Ruby with these command line arguments. The last argument may be a hash,
|
@@ -43,7 +43,7 @@ module Buildr
|
|
43
43
|
def ruby(*args)
|
44
44
|
options = Hash === args.last ? args.pop : {}
|
45
45
|
cmd = []
|
46
|
-
ruby_bin = normalize_path(
|
46
|
+
ruby_bin = normalize_path(RbConfig::CONFIG['ruby_install_name'], RbConfig::CONFIG['bindir'])
|
47
47
|
if options.delete(:sudo) && !(win_os? || Process.uid == File.stat(ruby_bin).uid)
|
48
48
|
cmd << 'sudo' << '-u' << "##{File.stat(ruby_bin).uid}"
|
49
49
|
end
|
@@ -308,7 +308,7 @@ if Buildr::Util.java_platform?
|
|
308
308
|
|
309
309
|
module RakeFileUtils #:nodoc:
|
310
310
|
def rake_merge_option(args, defaults)
|
311
|
-
defaults[:verbose] = false if defaults[:verbose] ==
|
311
|
+
defaults[:verbose] = false if defaults[:verbose] == Rake::FileUtilsExt::DEFAULT
|
312
312
|
|
313
313
|
if Hash === args.last
|
314
314
|
defaults.update(args.last)
|
@@ -396,7 +396,7 @@ if Buildr::Util.java_platform?
|
|
396
396
|
ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
|
397
397
|
}
|
398
398
|
end
|
399
|
-
if RakeFileUtils.verbose_flag ==
|
399
|
+
if RakeFileUtils.verbose_flag == Rake::FileUtilsExt::DEFAULT
|
400
400
|
options[:verbose] = false
|
401
401
|
else
|
402
402
|
options[:verbose] ||= RakeFileUtils.verbose_flag
|
@@ -440,7 +440,7 @@ else
|
|
440
440
|
ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
|
441
441
|
}
|
442
442
|
end
|
443
|
-
if RakeFileUtils.verbose_flag ==
|
443
|
+
if RakeFileUtils.verbose_flag == Rake::FileUtilsExt::DEFAULT
|
444
444
|
options[:verbose] = false
|
445
445
|
else
|
446
446
|
options[:verbose] ||= RakeFileUtils.verbose_flag
|
data/lib/buildr/ide/eclipse.rb
CHANGED
@@ -250,16 +250,16 @@ module Buildr
|
|
250
250
|
classpathentry.src project.test.resources
|
251
251
|
end
|
252
252
|
|
253
|
+
project.eclipse.classpath_containers.each { |container|
|
254
|
+
classpathentry.con container
|
255
|
+
}
|
256
|
+
|
253
257
|
# Classpath elements from other projects
|
254
258
|
classpathentry.src_projects project_libs
|
255
259
|
|
256
260
|
classpathentry.output project.compile.target if project.compile.target
|
257
261
|
classpathentry.lib libs
|
258
262
|
classpathentry.var vars
|
259
|
-
|
260
|
-
project.eclipse.classpath_containers.each { |container|
|
261
|
-
classpathentry.con container
|
262
|
-
}
|
263
263
|
end
|
264
264
|
end
|
265
265
|
end
|
@@ -413,12 +413,126 @@ module Buildr
|
|
413
413
|
end
|
414
414
|
end
|
415
415
|
|
416
|
+
module Plugin
|
417
|
+
include Extension
|
418
|
+
|
419
|
+
NATURE = 'org.eclipse.pde.PluginNature'
|
420
|
+
CONTAINER = 'org.eclipse.pde.core.requiredPlugins'
|
421
|
+
BUILDERS = ['org.eclipse.pde.ManifestBuilder', 'org.eclipse.pde.SchemaBuilder']
|
422
|
+
|
423
|
+
after_define do |project|
|
424
|
+
eclipse = project.eclipse
|
425
|
+
|
426
|
+
# smart defaults
|
427
|
+
if eclipse.natures.empty? && (
|
428
|
+
(File.exists? project.path_to("plugin.xml")) ||
|
429
|
+
(File.exists? project.path_to("OSGI-INF")) ||
|
430
|
+
(File.exists?(project.path_to("META-INF/MANIFEST.MF")) && File.read(project.path_to("META-INF/MANIFEST.MF")).match(/^Bundle-SymbolicName:/)))
|
431
|
+
eclipse.natures = [NATURE, Buildr::Eclipse::Java::NATURE]
|
432
|
+
eclipse.classpath_containers = [CONTAINER, Buildr::Eclipse::Java::CONTAINER] if eclipse.classpath_containers.empty?
|
433
|
+
eclipse.builders = BUILDERS + [Buildr::Eclipse::Java::BUILDER] if eclipse.builders.empty?
|
434
|
+
end
|
435
|
+
|
436
|
+
# :plugin nature explicitly set
|
437
|
+
if eclipse.natures.include? :plugin
|
438
|
+
unless eclipse.natures.include? NATURE
|
439
|
+
# plugin nature must be before java nature
|
440
|
+
eclipse.natures += [Buildr::Eclipse::Java::NATURE] unless eclipse.natures.include? Buildr::Eclipse::Java::NATURE
|
441
|
+
index = eclipse.natures.index(Buildr::Eclipse::Java::NATURE) || -1
|
442
|
+
eclipse.natures = eclipse.natures.insert(index, NATURE)
|
443
|
+
end
|
444
|
+
unless eclipse.classpath_containers.include? CONTAINER
|
445
|
+
# plugin container must be before java container
|
446
|
+
index = eclipse.classpath_containers.index(Buildr::Eclipse::Java::CONTAINER) || -1
|
447
|
+
eclipse.classpath_containers = eclipse.classpath_containers.insert(index, CONTAINER)
|
448
|
+
end
|
449
|
+
unless (eclipse.builders.include?(BUILDERS[0]) && eclipse.builders.include?(BUILDERS[1]))
|
450
|
+
# plugin builder must be before java builder
|
451
|
+
index = eclipse.classpath_containers.index(Buildr::Eclipse::Java::BUILDER) || -1
|
452
|
+
eclipse.builders = eclipse.builders.insert(index, BUILDERS[1]) unless eclipse.builders.include? BUILDERS[1]
|
453
|
+
index = eclipse.classpath_containers.index(BUILDERS[1]) || -1
|
454
|
+
eclipse.builders = eclipse.builders.insert(index, BUILDERS[0]) unless eclipse.builders.include? BUILDERS[0]
|
455
|
+
end
|
456
|
+
end
|
457
|
+
end
|
458
|
+
end
|
459
|
+
|
460
|
+
module Scala
|
461
|
+
include Extension
|
462
|
+
|
463
|
+
NATURE = 'ch.epfl.lamp.sdt.core.scalanature'
|
464
|
+
CONTAINER = 'ch.epfl.lamp.sdt.launching.SCALA_CONTAINER'
|
465
|
+
BUILDER = 'ch.epfl.lamp.sdt.core.scalabuilder'
|
466
|
+
|
467
|
+
after_define :eclipse => :eclipse_scala
|
468
|
+
after_define :eclipse_scala do |project|
|
469
|
+
eclipse = project.eclipse
|
470
|
+
# smart defaults
|
471
|
+
if eclipse.natures.empty? && (project.compile.language == :scala || project.test.compile.language == :scala)
|
472
|
+
eclipse.natures = [NATURE, Buildr::Eclipse::Java::NATURE]
|
473
|
+
eclipse.classpath_containers = [CONTAINER, Buildr::Eclipse::Java::CONTAINER] if eclipse.classpath_containers.empty?
|
474
|
+
eclipse.builders = BUILDER if eclipse.builders.empty?
|
475
|
+
eclipse.exclude_libs += Buildr::Scala::Scalac.dependencies
|
476
|
+
end
|
477
|
+
|
478
|
+
# :scala nature explicitly set
|
479
|
+
if eclipse.natures.include? :scala
|
480
|
+
unless eclipse.natures.include? NATURE
|
481
|
+
# scala nature must be before java nature
|
482
|
+
eclipse.natures += [Buildr::Eclipse::Java::NATURE] unless eclipse.natures.include? Buildr::Eclipse::Java::NATURE
|
483
|
+
index = eclipse.natures.index(Buildr::Eclipse::Java::NATURE) || -1
|
484
|
+
eclipse.natures = eclipse.natures.insert(index, NATURE)
|
485
|
+
end
|
486
|
+
unless eclipse.classpath_containers.include? CONTAINER
|
487
|
+
# scala container must be before java container
|
488
|
+
index = eclipse.classpath_containers.index(Buildr::Eclipse::Java::CONTAINER) || -1
|
489
|
+
eclipse.classpath_containers = eclipse.classpath_containers.insert(index, CONTAINER)
|
490
|
+
end
|
491
|
+
unless eclipse.builders.include? BUILDER
|
492
|
+
# scala builder overrides java builder
|
493
|
+
eclipse.builders -= [Buildr::Eclipse::Java::BUILDER]
|
494
|
+
eclipse.builders += [BUILDER]
|
495
|
+
end
|
496
|
+
eclipse.exclude_libs += Buildr::Scala::Scalac.dependencies
|
497
|
+
end
|
498
|
+
end
|
499
|
+
end
|
500
|
+
|
501
|
+
module Java
|
502
|
+
include Extension
|
503
|
+
|
504
|
+
NATURE = 'org.eclipse.jdt.core.javanature'
|
505
|
+
CONTAINER = 'org.eclipse.jdt.launching.JRE_CONTAINER'
|
506
|
+
BUILDER = 'org.eclipse.jdt.core.javabuilder'
|
507
|
+
|
508
|
+
after_define do |project|
|
509
|
+
eclipse = project.eclipse
|
510
|
+
|
511
|
+
# smart defaults
|
512
|
+
if project.compile.language == :java || project.test.compile.language == :java
|
513
|
+
eclipse.natures = NATURE if eclipse.natures.empty?
|
514
|
+
eclipse.classpath_containers = CONTAINER if eclipse.classpath_containers.empty?
|
515
|
+
eclipse.builders = BUILDER if eclipse.builders.empty?
|
516
|
+
end
|
517
|
+
|
518
|
+
# :java nature explicitly set
|
519
|
+
if eclipse.natures.include? :java
|
520
|
+
eclipse.natures += [NATURE] unless eclipse.natures.include? NATURE
|
521
|
+
eclipse.classpath_containers += [CONTAINER] unless eclipse.classpath_containers.include? CONTAINER
|
522
|
+
eclipse.builders += [BUILDER] unless eclipse.builders.include? BUILDER
|
523
|
+
end
|
524
|
+
end
|
525
|
+
end
|
526
|
+
|
416
527
|
end
|
417
528
|
|
418
529
|
end # module Buildr
|
419
530
|
|
420
531
|
class Buildr::Project
|
421
532
|
include Buildr::Eclipse
|
533
|
+
include Buildr::Eclipse::Plugin
|
534
|
+
include Buildr::Eclipse::Scala
|
535
|
+
include Buildr::Eclipse::Java
|
422
536
|
end
|
423
537
|
|
424
538
|
|