buildr 1.2.10 → 1.3.0
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 +566 -268
- data/DISCLAIMER +7 -1
- data/KEYS +151 -0
- data/NOTICE +23 -8
- data/README +122 -22
- data/Rakefile +49 -229
- data/{lib → addon}/buildr/antlr.rb +23 -10
- data/addon/buildr/cobertura.rb +232 -0
- data/{lib → addon}/buildr/hibernate.rb +20 -4
- data/{lib → addon}/buildr/javacc.rb +27 -12
- data/addon/buildr/jdepend.rb +60 -0
- data/{lib → addon}/buildr/jetty.rb +34 -18
- data/addon/buildr/nailgun.rb +892 -0
- data/{lib → addon}/buildr/openjpa.rb +23 -6
- 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/{lib/buildr/jetty → addon/buildr/org/apache/buildr}/JettyWrapper.java +19 -0
- data/{lib → addon}/buildr/xmlbeans.rb +39 -14
- data/bin/buildr +21 -7
- data/buildr.gemspec +50 -0
- data/doc/css/default.css +225 -0
- data/doc/css/print.css +95 -0
- data/doc/css/syntax.css +43 -0
- data/doc/images/apache-incubator-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/pages/artifacts.textile +317 -0
- data/doc/pages/building.textile +501 -0
- data/doc/pages/contributing.textile +178 -0
- data/doc/pages/download.textile +25 -0
- data/doc/pages/extending.textile +229 -0
- data/doc/pages/getting_started.textile +337 -0
- data/doc/pages/index.textile +63 -0
- data/doc/pages/mailing_lists.textile +17 -0
- data/doc/pages/more_stuff.textile +367 -0
- data/doc/pages/packaging.textile +592 -0
- data/doc/pages/projects.textile +449 -0
- data/doc/pages/recipes.textile +127 -0
- data/doc/pages/settings_profiles.textile +339 -0
- data/doc/pages/testing.textile +475 -0
- data/doc/pages/troubleshooting.textile +121 -0
- data/doc/pages/whats_new.textile +389 -0
- data/doc/print.haml +52 -0
- data/doc/print.toc.yaml +28 -0
- data/doc/scripts/buildr-git.rb +411 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +64 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/site.haml +55 -0
- data/doc/site.toc.yaml +44 -0
- data/lib/buildr.rb +28 -45
- data/lib/buildr/core.rb +27 -0
- data/lib/buildr/core/application.rb +373 -0
- data/lib/buildr/core/application_cli.rb +134 -0
- data/lib/{core → buildr/core}/build.rb +91 -77
- data/lib/{core → buildr/core}/checks.rb +116 -95
- data/lib/buildr/core/common.rb +155 -0
- data/lib/buildr/core/compile.rb +594 -0
- data/lib/buildr/core/environment.rb +120 -0
- data/lib/buildr/core/filter.rb +258 -0
- data/lib/{core → buildr/core}/generate.rb +22 -5
- data/lib/buildr/core/help.rb +118 -0
- data/lib/buildr/core/progressbar.rb +156 -0
- data/lib/{core → buildr/core}/project.rb +468 -213
- data/lib/buildr/core/test.rb +690 -0
- data/lib/{core → buildr/core}/transports.rb +107 -127
- data/lib/buildr/core/util.rb +235 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/{java → buildr/ide}/eclipse.rb +86 -60
- data/lib/{java → buildr/ide}/idea.ipr.template +16 -0
- data/lib/buildr/ide/idea.rb +194 -0
- data/lib/buildr/ide/idea7x.ipr.template +290 -0
- data/lib/buildr/ide/idea7x.rb +210 -0
- data/lib/buildr/java.rb +26 -0
- data/lib/buildr/java/ant.rb +71 -0
- data/lib/buildr/java/bdd_frameworks.rb +267 -0
- data/lib/buildr/java/commands.rb +210 -0
- data/lib/buildr/java/compilers.rb +432 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/groovyc.rb +137 -0
- data/lib/buildr/java/jruby.rb +99 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail.class +0 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail.java +41 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +116 -0
- data/lib/buildr/java/packaging.rb +706 -0
- data/lib/{java → buildr/java}/pom.rb +20 -4
- data/lib/buildr/java/rjb.rb +142 -0
- data/lib/buildr/java/test_frameworks.rb +290 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +21 -0
- data/lib/{java → buildr/packaging}/artifact.rb +170 -179
- data/lib/buildr/packaging/artifact_namespace.rb +957 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +102 -0
- data/lib/buildr/packaging/package.rb +233 -0
- data/lib/{tasks → buildr/packaging}/tar.rb +18 -1
- data/lib/{tasks → buildr/packaging}/zip.rb +153 -105
- data/rakelib/apache.rake +126 -0
- data/rakelib/changelog.rake +56 -0
- data/rakelib/doc.rake +103 -0
- data/rakelib/package.rake +44 -0
- data/rakelib/release.rake +53 -0
- data/rakelib/rspec.rake +81 -0
- data/rakelib/rubyforge.rake +45 -0
- data/rakelib/scm.rake +49 -0
- data/rakelib/setup.rake +59 -0
- data/rakelib/stage.rake +45 -0
- data/spec/application_spec.rb +316 -0
- data/spec/archive_spec.rb +494 -0
- data/spec/artifact_namespace_spec.rb +635 -0
- data/spec/artifact_spec.rb +738 -0
- data/spec/build_spec.rb +193 -0
- data/spec/checks_spec.rb +537 -0
- data/spec/common_spec.rb +579 -0
- data/spec/compile_spec.rb +561 -0
- data/spec/groovy_compilers_spec.rb +239 -0
- data/spec/java_bdd_frameworks_spec.rb +238 -0
- data/spec/java_compilers_spec.rb +446 -0
- data/spec/java_packaging_spec.rb +1042 -0
- data/spec/java_test_frameworks_spec.rb +414 -0
- data/spec/packaging_helper.rb +63 -0
- data/spec/packaging_spec.rb +589 -0
- data/spec/project_spec.rb +739 -0
- data/spec/sandbox.rb +116 -0
- data/spec/scala_compilers_spec.rb +239 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helpers.rb +283 -0
- data/spec/test_spec.rb +871 -0
- data/spec/transport_spec.rb +300 -0
- data/spec/version_requirement_spec.rb +115 -0
- metadata +188 -77
- data/lib/buildr/cobertura.rb +0 -89
- data/lib/buildr/jdepend.rb +0 -40
- data/lib/buildr/jetty/JettyWrapper$1.class +0 -0
- data/lib/buildr/jetty/JettyWrapper$BuildrHandler.class +0 -0
- data/lib/buildr/jetty/JettyWrapper.class +0 -0
- data/lib/buildr/scala.rb +0 -368
- data/lib/core/application.rb +0 -188
- data/lib/core/common.rb +0 -562
- data/lib/core/help.rb +0 -72
- data/lib/core/rake_ext.rb +0 -81
- data/lib/java/ant.rb +0 -71
- data/lib/java/compile.rb +0 -589
- data/lib/java/idea.rb +0 -159
- data/lib/java/java.rb +0 -432
- data/lib/java/packaging.rb +0 -581
- data/lib/java/test.rb +0 -795
- data/lib/tasks/concat.rb +0 -35
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
|
+
require 'buildr/ide/idea7x'
|
|
@@ -1,18 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
+
|
|
4
20
|
|
|
5
21
|
module Buildr
|
|
22
|
+
module Eclipse #:nodoc:
|
|
6
23
|
|
|
7
|
-
|
|
8
|
-
desc "Generate Eclipse artifacts for all projects"
|
|
9
|
-
Project.local_task "eclipse"=>"artifacts"
|
|
24
|
+
include Extension
|
|
10
25
|
|
|
11
|
-
|
|
12
|
-
|
|
26
|
+
first_time do
|
|
27
|
+
# Global task "eclipse" generates artifacts for all projects.
|
|
28
|
+
desc "Generate Eclipse artifacts for all projects"
|
|
29
|
+
Project.local_task "eclipse"=>"artifacts"
|
|
30
|
+
end
|
|
13
31
|
|
|
14
|
-
|
|
32
|
+
before_define do |project|
|
|
33
|
+
project.recursive_task("eclipse")
|
|
34
|
+
end
|
|
15
35
|
|
|
36
|
+
after_define do |project|
|
|
37
|
+
eclipse = project.task("eclipse")
|
|
16
38
|
# We need paths relative to the top project's base directory.
|
|
17
39
|
root_path = lambda { |p| f = lambda { |p| p.parent ? f[p.parent] : p.base_dir } ; f[p] }[project]
|
|
18
40
|
|
|
@@ -20,14 +42,17 @@ module Buildr
|
|
|
20
42
|
# the Buildfile (buildr.rb, separate file listing dependencies, etc), so we add anything required
|
|
21
43
|
# after the Buildfile. So which don't know where Buildr shows up exactly, ignore files that show
|
|
22
44
|
# in $LOADED_FEATURES that we cannot resolve.
|
|
23
|
-
sources = Buildr.build_files.map { |file| File.expand_path(file) }.select { |file| File.exist?(file) }
|
|
24
|
-
sources << File.expand_path(
|
|
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
|
|
25
47
|
|
|
26
48
|
# Check if project has scala facet
|
|
27
|
-
scala = project.
|
|
28
|
-
|
|
29
|
-
# Only for projects that
|
|
30
|
-
|
|
49
|
+
scala = project.compile.language == :scala
|
|
50
|
+
|
|
51
|
+
# Only for projects that we support
|
|
52
|
+
supported_languages = [:java, :scala]
|
|
53
|
+
supported_packaging = %w(jar war rar mar aar)
|
|
54
|
+
if (supported_languages.include? project.compile.language ||
|
|
55
|
+
project.packages.detect { |pkg| supported_packaging.include?(pkg.type.to_s) })
|
|
31
56
|
eclipse.enhance [ file(project.path_to(".classpath")), file(project.path_to(".project")) ]
|
|
32
57
|
|
|
33
58
|
# The only thing we need to look for is a change in the Buildfile.
|
|
@@ -36,9 +61,10 @@ module Buildr
|
|
|
36
61
|
|
|
37
62
|
# Find a path relative to the project's root directory.
|
|
38
63
|
relative = lambda do |path|
|
|
64
|
+
path or raise "Invalid path '#{path.inspect}'"
|
|
39
65
|
msg = [:to_path, :to_str, :to_s].find { |msg| path.respond_to? msg }
|
|
40
66
|
path = path.__send__(msg)
|
|
41
|
-
|
|
67
|
+
Util.relative_path(File.expand_path(path), project.path_to)
|
|
42
68
|
end
|
|
43
69
|
|
|
44
70
|
m2repo = Buildr::Repositories.instance.local
|
|
@@ -48,12 +74,11 @@ module Buildr
|
|
|
48
74
|
xml = Builder::XmlMarkup.new(:target=>file, :indent=>2)
|
|
49
75
|
xml.classpath do
|
|
50
76
|
# Note: Use the test classpath since Eclipse compiles both "main" and "test" classes using the same classpath
|
|
51
|
-
cp = project.test.compile.
|
|
52
|
-
cp += scala.classpath.map(&:to_s) if scala
|
|
77
|
+
cp = project.test.compile.dependencies.map(&:to_s) - [ project.compile.target.to_s, project.resources.target.to_s ]
|
|
53
78
|
cp = cp.uniq
|
|
54
79
|
|
|
55
80
|
# Convert classpath elements into applicable Project objects
|
|
56
|
-
cp.collect! { |path| projects.detect { |prj| prj.packages.detect { |pkg| pkg.to_s == path } } || path }
|
|
81
|
+
cp.collect! { |path| Buildr.projects.detect { |prj| prj.packages.detect { |pkg| pkg.to_s == path } } || path }
|
|
57
82
|
|
|
58
83
|
# project_libs: artifacts created by other projects
|
|
59
84
|
project_libs, others = cp.partition { |path| path.is_a?(Project) }
|
|
@@ -64,59 +89,54 @@ module Buildr
|
|
|
64
89
|
# Generated: classpath elements in the project are assumed to be generated
|
|
65
90
|
generated, libs = others.partition { |path| path.to_s.index(project.path_to.to_s) == 0 }
|
|
66
91
|
|
|
67
|
-
xml.classpathentry :kind=>'con', :path=>'org.eclipse.jdt.launching.JRE_CONTAINER'
|
|
68
|
-
xml.classpathentry :kind=>'con', :path=>'ch.epfl.lamp.sdt.launching.SCALA_CONTAINER' if scala
|
|
69
|
-
|
|
70
92
|
srcs = project.compile.sources
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
# hack until we have sunit task
|
|
74
|
-
project.path_to("src/test/scala").tap do |dir|
|
|
75
|
-
srcs += dir if scala and File.exist?(dir)
|
|
76
|
-
end
|
|
77
|
-
|
|
93
|
+
|
|
78
94
|
srcs = srcs.map { |src| relative[src] } + generated.map { |src| relative[src] }
|
|
79
95
|
srcs.sort.uniq.each do |path|
|
|
80
96
|
xml.classpathentry :kind=>'src', :path=>path, :excluding=>excludes
|
|
81
97
|
end
|
|
82
98
|
|
|
83
|
-
{ :output => relative[project.compile.target],
|
|
84
|
-
:lib => libs.map(&:to_s),
|
|
85
|
-
:var => m2_libs.map { |path| path.to_s.sub(m2repo, 'M2_REPO') }
|
|
86
|
-
}.each do |kind, paths|
|
|
87
|
-
paths.sort.uniq.each do |path|
|
|
88
|
-
xml.classpathentry :kind=>kind, :path=>path
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# Classpath elements from other projects
|
|
93
|
-
project_libs.map(&:id).sort.uniq.each do |project_id|
|
|
94
|
-
xml.classpathentry :kind=>'src', :combineaccessrules=>"false", :path=>"/#{project_id}"
|
|
95
|
-
end
|
|
96
|
-
|
|
97
99
|
# Main resources implicitly copied into project.compile.target
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
main_resource_sources = project.resources.sources.map { |src| relative[src] }
|
|
101
|
+
main_resource_sources.each do |path|
|
|
100
102
|
if File.exist? project.path_to(path)
|
|
101
103
|
xml.classpathentry :kind=>'src', :path=>path, :excluding=>excludes
|
|
102
104
|
end
|
|
103
105
|
end
|
|
104
106
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
if project.test.compile.target
|
|
108
|
+
# Test classes are generated in a separate output directory
|
|
109
|
+
test_sources = project.test.compile.sources.map { |src| relative[src] }
|
|
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
|
|
110
121
|
end
|
|
111
122
|
end
|
|
112
123
|
|
|
113
|
-
#
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
124
|
+
# Classpath elements from other projects
|
|
125
|
+
project_libs.map(&:id).sort.uniq.each do |project_id|
|
|
126
|
+
xml.classpathentry :kind=>'src', :combineaccessrules=>"false", :path=>"/#{project_id}"
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
{ :output => relative[project.compile.target],
|
|
130
|
+
:lib => libs.map(&:to_s),
|
|
131
|
+
:var => m2_libs.map { |path| path.to_s.sub(m2repo, 'M2_REPO') }
|
|
132
|
+
}.each do |kind, paths|
|
|
133
|
+
paths.sort.uniq.each do |path|
|
|
134
|
+
xml.classpathentry :kind=>kind, :path=>path
|
|
118
135
|
end
|
|
119
136
|
end
|
|
137
|
+
|
|
138
|
+
xml.classpathentry :kind=>'con', :path=>'org.eclipse.jdt.launching.JRE_CONTAINER'
|
|
139
|
+
xml.classpathentry :kind=>'con', :path=>'ch.epfl.lamp.sdt.launching.SCALA_CONTAINER' if scala
|
|
120
140
|
end
|
|
121
141
|
end
|
|
122
142
|
end
|
|
@@ -135,21 +155,27 @@ module Buildr
|
|
|
135
155
|
end
|
|
136
156
|
if scala
|
|
137
157
|
xml.buildCommand do
|
|
138
|
-
|
|
139
|
-
xml.name "scala.plugin.scalabuilder"
|
|
158
|
+
xml.name "ch.epfl.lamp.sdt.core.scalabuilder"
|
|
159
|
+
#xml.name "scala.plugin.scalabuilder"
|
|
140
160
|
end
|
|
141
161
|
end
|
|
142
162
|
end
|
|
143
163
|
xml.natures do
|
|
144
164
|
xml.nature "org.eclipse.jdt.core.javanature"
|
|
145
|
-
|
|
146
|
-
xml.nature "scala.plugin.scalanature" if scala
|
|
165
|
+
xml.nature "ch.epfl.lamp.sdt.core.scalanature" if scala
|
|
166
|
+
#xml.nature "scala.plugin.scalanature" if scala
|
|
147
167
|
end
|
|
148
168
|
end
|
|
149
169
|
end
|
|
150
170
|
end
|
|
151
171
|
end
|
|
172
|
+
|
|
152
173
|
end
|
|
153
|
-
end
|
|
154
174
|
|
|
175
|
+
end
|
|
155
176
|
end # module Buildr
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class Buildr::Project
|
|
180
|
+
include Buildr::Eclipse
|
|
181
|
+
end
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!--
|
|
3
|
+
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
4
|
+
contributor license agreements. See the NOTICE file distributed with this
|
|
5
|
+
work for additional information regarding copyright ownership. The ASF
|
|
6
|
+
licenses this file to you under the Apache License, Version 2.0 (the
|
|
7
|
+
"License"); you may not use this file except in compliance with the License.
|
|
8
|
+
You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
14
|
+
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
15
|
+
License for the specific language governing permissions and limitations under
|
|
16
|
+
the License.
|
|
17
|
+
-->
|
|
2
18
|
<project version="4" relativePaths="false">
|
|
3
19
|
<component name="AntConfiguration">
|
|
4
20
|
<defaultAnt bundledAnt="true" />
|
|
@@ -0,0 +1,194 @@
|
|
|
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
|
+
require 'stringio'
|
|
20
|
+
require 'rexml/document'
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
module Buildr
|
|
24
|
+
module Idea #:nodoc:
|
|
25
|
+
|
|
26
|
+
include Extension
|
|
27
|
+
|
|
28
|
+
first_time do
|
|
29
|
+
# Global task "idea" generates artifacts for all projects.
|
|
30
|
+
desc "Generate Idea artifacts for all projects"
|
|
31
|
+
Project.local_task "idea"=>"artifacts"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
before_define do |project|
|
|
35
|
+
project.recursive_task("idea")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
after_define do |project|
|
|
39
|
+
idea = project.task("idea")
|
|
40
|
+
# We need paths relative to the top project's base directory.
|
|
41
|
+
root_path = lambda { |p| f = lambda { |p| p.parent ? f[p.parent] : p.base_dir }; f[p] }[project]
|
|
42
|
+
# We want the Eclipse files changed every time the Buildfile changes, but also anything loaded by
|
|
43
|
+
# the Buildfile (buildr.rb, separate file listing dependencies, etc), so we add anything required
|
|
44
|
+
# after the Buildfile. So which don't know where Buildr shows up exactly, ignore files that show
|
|
45
|
+
# in $LOADED_FEATURES that we cannot resolve.
|
|
46
|
+
sources = Buildr.application.build_files.map { |file| File.expand_path(file) }.select { |file| File.exist?(file) }
|
|
47
|
+
sources << File.expand_path(Buildr.application.buildfile, root_path) if Buildr.application.buildfile
|
|
48
|
+
|
|
49
|
+
# Find a path relative to the project's root directory.
|
|
50
|
+
relative = lambda { |path| Util.relative_path(path.to_s, project.path_to) }
|
|
51
|
+
|
|
52
|
+
m2repo = Buildr::Repositories.instance.local
|
|
53
|
+
excludes = [ '**/.svn/', '**/CVS/' ].join('|')
|
|
54
|
+
|
|
55
|
+
# Only for projects that are packageable.
|
|
56
|
+
task_name = project.path_to("#{project.name.gsub(':', '-')}.iml")
|
|
57
|
+
idea.enhance [ file(task_name) ]
|
|
58
|
+
|
|
59
|
+
# The only thing we need to look for is a change in the Buildfile.
|
|
60
|
+
file(task_name=>sources) do |task|
|
|
61
|
+
puts "Writing #{task.name}" if verbose
|
|
62
|
+
|
|
63
|
+
# Idea handles modules slightly differently if they're WARs
|
|
64
|
+
idea_types = Hash.new("JAVA_MODULE")
|
|
65
|
+
idea_types["war"] = "J2EE_WEB_MODULE"
|
|
66
|
+
|
|
67
|
+
# Note: Use the test classpath since Eclipse compiles both "main" and "test" classes using the same classpath
|
|
68
|
+
deps = project.test.compile.dependencies.map(&:to_s) - [ project.compile.target.to_s ]
|
|
69
|
+
|
|
70
|
+
# Convert classpath elements into applicable Project objects
|
|
71
|
+
deps.collect! { |path| Buildr.projects.detect { |prj| prj.packages.detect { |pkg| pkg.to_s == path } } || path }
|
|
72
|
+
|
|
73
|
+
# project_libs: artifacts created by other projects
|
|
74
|
+
project_libs, others = deps.partition { |path| path.is_a?(Project) }
|
|
75
|
+
|
|
76
|
+
# Separate artifacts from Maven2 repository
|
|
77
|
+
m2_libs, others = others.partition { |path| path.to_s.index(m2repo) == 0 }
|
|
78
|
+
|
|
79
|
+
# Generated: classpath elements in the project are assumed to be generated
|
|
80
|
+
generated, libs = others.partition { |path| path.to_s.index(project.path_to.to_s) == 0 }
|
|
81
|
+
|
|
82
|
+
# Project type is going to be the first package type
|
|
83
|
+
if package = project.packages.first
|
|
84
|
+
File.open(task.name, "w") do |file|
|
|
85
|
+
xml = Builder::XmlMarkup.new(:target=>file, :indent=>2)
|
|
86
|
+
|
|
87
|
+
xml.module(:version=>"4", :relativePaths=>"false", :type=>idea_types[package.type.to_s]) do
|
|
88
|
+
xml.component :name=>"ModuleRootManager"
|
|
89
|
+
xml.component "name"=>"NewModuleRootManager", "inherit-compiler-output"=>"false" do
|
|
90
|
+
has_compile_sources = project.compile.target.to_s.size > 0
|
|
91
|
+
xml.output :url=>"file://$MODULE_DIR$/#{relative[project.compile.target.to_s]}" if has_compile_sources
|
|
92
|
+
xml.tag! "exclude-output"
|
|
93
|
+
|
|
94
|
+
# TODO project.test.target isn't recognized, what's the proper way to get the test compile path?
|
|
95
|
+
xml.tag! "output-test", :url=>"file://$MODULE_DIR$/target/test-classes"
|
|
96
|
+
|
|
97
|
+
xml.content(:url=>"file://$MODULE_DIR$") do
|
|
98
|
+
if has_compile_sources
|
|
99
|
+
srcs = project.compile.sources.map { |src| relative[src.to_s] } + generated.map { |src| relative[src.to_s] }
|
|
100
|
+
srcs.sort.uniq.each do |path|
|
|
101
|
+
xml.sourceFolder :url=>"file://$MODULE_DIR$/#{path}", :isTestSource=>"false"
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
test_sources = project.test.compile.sources.map { |src| relative[src.to_s] }
|
|
105
|
+
test_sources.each do |paths|
|
|
106
|
+
paths.sort.uniq.each do |path|
|
|
107
|
+
xml.sourceFolder :url=>"file://$MODULE_DIR$/#{path}", :isTestSource=>"true"
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
[project.resources=>false, project.test.resources=>true].each do |resources, test|
|
|
112
|
+
resources.each do |path|
|
|
113
|
+
path[0].sources.each do |srcpath|
|
|
114
|
+
xml.sourceFolder :url=>"file://#{srcpath}", :isTestSource=>path[1].to_s
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
xml.excludeFolder :url=>"file://$MODULE_DIR$/#{relative[project.compile.target.to_s]}" if has_compile_sources
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
xml.orderEntry :type=>"sourceFolder", :forTests=>"false"
|
|
122
|
+
xml.orderEntry :type=>"inheritedJdk"
|
|
123
|
+
|
|
124
|
+
# Classpath elements from other projects
|
|
125
|
+
project_libs.map(&:id).sort.uniq.each do |project_id|
|
|
126
|
+
xml.orderEntry :type=>'module', "module-name"=>project_id
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Libraries
|
|
130
|
+
ext_libs = libs.map {|path| "$MODULE_DIR$/#{path.to_s}" } +
|
|
131
|
+
m2_libs.map { |path| path.to_s.sub(m2repo, "$M2_REPO$") }
|
|
132
|
+
ext_libs.each do |path|
|
|
133
|
+
xml.orderEntry :type=>"module-library" do
|
|
134
|
+
xml.library do
|
|
135
|
+
xml.CLASSES do
|
|
136
|
+
xml.root :url=>"jar://#{path}!/"
|
|
137
|
+
end
|
|
138
|
+
xml.JAVADOC
|
|
139
|
+
xml.SOURCES
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
xml.orderEntryProperties
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Root project aggregates all the subprojects.
|
|
152
|
+
if project.parent == nil
|
|
153
|
+
task_name = project.path_to("#{project.name.gsub(':', '-')}.ipr")
|
|
154
|
+
idea.enhance [ file(task_name) ]
|
|
155
|
+
|
|
156
|
+
file(task_name=>sources) do |task|
|
|
157
|
+
puts "Writing #{task.name}" if verbose
|
|
158
|
+
|
|
159
|
+
# Generating just the little stanza that chanages from one project to another
|
|
160
|
+
partial = StringIO.new
|
|
161
|
+
xml = Builder::XmlMarkup.new(:target=>partial, :indent=>2)
|
|
162
|
+
xml.component(:name=>"ProjectModuleManager") do
|
|
163
|
+
xml.modules do
|
|
164
|
+
project.projects.each do |subp|
|
|
165
|
+
module_name = subp.name.gsub(":", "-")
|
|
166
|
+
module_path = subp.name.split(":"); module_path.shift
|
|
167
|
+
module_path = module_path.join("/")
|
|
168
|
+
path = "#{module_path}/#{module_name}.iml"
|
|
169
|
+
xml.module :fileurl=>"file://$PROJECT_DIR$/#{path}", :filepath=>"$PROJECT_DIR$/#{path}"
|
|
170
|
+
end
|
|
171
|
+
if package = project.packages.first
|
|
172
|
+
xml.module :fileurl=>"file://$PROJECT_DIR$/#{project.name}.iml", :filepath=>"$PROJECT_DIR$/#{project.name}.iml"
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# Loading the whole fairly constant crap
|
|
178
|
+
template_xml = REXML::Document.new(File.open(File.dirname(__FILE__)+"/idea.ipr.template"))
|
|
179
|
+
include_xml = REXML::Document.new(partial.string)
|
|
180
|
+
template_xml.root.add_element(include_xml.root)
|
|
181
|
+
template_xml.write(File.new(task.name, "w"))
|
|
182
|
+
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
end #after define
|
|
187
|
+
|
|
188
|
+
end #module Idea
|
|
189
|
+
end # module Buildr
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
class Buildr::Project
|
|
193
|
+
include Buildr::Idea
|
|
194
|
+
end
|