mguymon-buildr 1.4.5-java
Sign up to get free protection for your applications and to get access to all the features.
- 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,53 @@
|
|
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/core/common'
|
19
|
+
|
20
|
+
module Buildr
|
21
|
+
module Eclipse
|
22
|
+
module Java
|
23
|
+
include Extension
|
24
|
+
|
25
|
+
NATURE = 'org.eclipse.jdt.core.javanature'
|
26
|
+
CONTAINER = 'org.eclipse.jdt.launching.JRE_CONTAINER'
|
27
|
+
BUILDER = 'org.eclipse.jdt.core.javabuilder'
|
28
|
+
|
29
|
+
after_define do |project|
|
30
|
+
eclipse = project.eclipse
|
31
|
+
|
32
|
+
# smart defaults
|
33
|
+
if project.compile.language == :java || project.test.compile.language == :java
|
34
|
+
eclipse.natures = NATURE if eclipse.natures.empty?
|
35
|
+
eclipse.classpath_containers = CONTAINER if eclipse.classpath_containers.empty?
|
36
|
+
eclipse.builders = BUILDER if eclipse.builders.empty?
|
37
|
+
end
|
38
|
+
|
39
|
+
# :java nature explicitly set
|
40
|
+
if eclipse.natures.include? :java
|
41
|
+
eclipse.natures += [NATURE] unless eclipse.natures.include? NATURE
|
42
|
+
eclipse.classpath_containers += [CONTAINER] unless eclipse.classpath_containers.include? CONTAINER
|
43
|
+
eclipse.builders += [BUILDER] unless eclipse.builders.include? BUILDER
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class Buildr::Project
|
52
|
+
include Buildr::Eclipse::Java
|
53
|
+
end
|
@@ -0,0 +1,71 @@
|
|
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/core/common'
|
19
|
+
|
20
|
+
module Buildr
|
21
|
+
module Eclipse
|
22
|
+
module Plugin
|
23
|
+
include Extension
|
24
|
+
|
25
|
+
NATURE = 'org.eclipse.pde.PluginNature'
|
26
|
+
CONTAINER = 'org.eclipse.pde.core.requiredPlugins'
|
27
|
+
BUILDERS = ['org.eclipse.pde.ManifestBuilder', 'org.eclipse.pde.SchemaBuilder']
|
28
|
+
|
29
|
+
after_define do |project|
|
30
|
+
eclipse = project.eclipse
|
31
|
+
|
32
|
+
# smart defaults
|
33
|
+
if eclipse.natures.empty? && (
|
34
|
+
(File.exists? project.path_to("plugin.xml")) ||
|
35
|
+
(File.exists? project.path_to("OSGI-INF")) ||
|
36
|
+
(File.exists?(project.path_to("META-INF/MANIFEST.MF")) && File.read(project.path_to("META-INF/MANIFEST.MF")).match(/^Bundle-SymbolicName:/)))
|
37
|
+
eclipse.natures = [NATURE, Buildr::Eclipse::Java::NATURE]
|
38
|
+
eclipse.classpath_containers = [CONTAINER, Buildr::Eclipse::Java::CONTAINER] if eclipse.classpath_containers.empty?
|
39
|
+
eclipse.builders = BUILDERS + [Buildr::Eclipse::Java::BUILDER] if eclipse.builders.empty?
|
40
|
+
end
|
41
|
+
|
42
|
+
# :plugin nature explicitly set
|
43
|
+
if eclipse.natures.include? :plugin
|
44
|
+
unless eclipse.natures.include? NATURE
|
45
|
+
# plugin nature must be before java nature
|
46
|
+
eclipse.natures += [Buildr::Eclipse::Java::NATURE] unless eclipse.natures.include? Buildr::Eclipse::Java::NATURE
|
47
|
+
index = eclipse.natures.index(Buildr::Eclipse::Java::NATURE) || -1
|
48
|
+
eclipse.natures = eclipse.natures.insert(index, NATURE)
|
49
|
+
end
|
50
|
+
unless eclipse.classpath_containers.include? CONTAINER
|
51
|
+
# plugin container must be before java container
|
52
|
+
index = eclipse.classpath_containers.index(Buildr::Eclipse::Java::CONTAINER) || -1
|
53
|
+
eclipse.classpath_containers = eclipse.classpath_containers.insert(index, CONTAINER)
|
54
|
+
end
|
55
|
+
unless (eclipse.builders.include?(BUILDERS[0]) && eclipse.builders.include?(BUILDERS[1]))
|
56
|
+
# plugin builder must be before java builder
|
57
|
+
index = eclipse.classpath_containers.index(Buildr::Eclipse::Java::BUILDER) || -1
|
58
|
+
eclipse.builders = eclipse.builders.insert(index, BUILDERS[1]) unless eclipse.builders.include? BUILDERS[1]
|
59
|
+
index = eclipse.classpath_containers.index(BUILDERS[1]) || -1
|
60
|
+
eclipse.builders = eclipse.builders.insert(index, BUILDERS[0]) unless eclipse.builders.include? BUILDERS[0]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
class Buildr::Project
|
70
|
+
include Buildr::Eclipse::Plugin
|
71
|
+
end
|
@@ -0,0 +1,68 @@
|
|
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/core/common'
|
19
|
+
|
20
|
+
module Buildr
|
21
|
+
module Eclipse
|
22
|
+
module Scala
|
23
|
+
include Extension
|
24
|
+
|
25
|
+
NATURE = 'ch.epfl.lamp.sdt.core.scalanature'
|
26
|
+
CONTAINER = 'ch.epfl.lamp.sdt.launching.SCALA_CONTAINER'
|
27
|
+
BUILDER = 'ch.epfl.lamp.sdt.core.scalabuilder'
|
28
|
+
|
29
|
+
after_define :eclipse => :eclipse_scala
|
30
|
+
after_define :eclipse_scala do |project|
|
31
|
+
eclipse = project.eclipse
|
32
|
+
# smart defaults
|
33
|
+
if eclipse.natures.empty? && (project.compile.language == :scala || project.test.compile.language == :scala)
|
34
|
+
eclipse.natures = [NATURE, Buildr::Eclipse::Java::NATURE]
|
35
|
+
eclipse.classpath_containers = [CONTAINER, Buildr::Eclipse::Java::CONTAINER] if eclipse.classpath_containers.empty?
|
36
|
+
eclipse.builders = BUILDER if eclipse.builders.empty?
|
37
|
+
eclipse.exclude_libs += Buildr::Scala::Scalac.dependencies
|
38
|
+
end
|
39
|
+
|
40
|
+
# :scala nature explicitly set
|
41
|
+
if eclipse.natures.include? :scala
|
42
|
+
unless eclipse.natures.include? NATURE
|
43
|
+
# scala nature must be before java nature
|
44
|
+
eclipse.natures += [Buildr::Eclipse::Java::NATURE] unless eclipse.natures.include? Buildr::Eclipse::Java::NATURE
|
45
|
+
index = eclipse.natures.index(Buildr::Eclipse::Java::NATURE) || -1
|
46
|
+
eclipse.natures = eclipse.natures.insert(index, NATURE)
|
47
|
+
end
|
48
|
+
unless eclipse.classpath_containers.include? CONTAINER
|
49
|
+
# scala container must be before java container
|
50
|
+
index = eclipse.classpath_containers.index(Buildr::Eclipse::Java::CONTAINER) || -1
|
51
|
+
eclipse.classpath_containers = eclipse.classpath_containers.insert(index, CONTAINER)
|
52
|
+
end
|
53
|
+
unless eclipse.builders.include? BUILDER
|
54
|
+
# scala builder overrides java builder
|
55
|
+
eclipse.builders -= [Buildr::Eclipse::Java::BUILDER]
|
56
|
+
eclipse.builders += [BUILDER]
|
57
|
+
end
|
58
|
+
eclipse.exclude_libs += Buildr::Scala::Scalac.dependencies
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class Buildr::Project
|
67
|
+
include Buildr::Eclipse::Scala
|
68
|
+
end
|
@@ -0,0 +1,576 @@
|
|
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
|
+
|
21
|
+
|
22
|
+
module Buildr
|
23
|
+
module IntellijIdea
|
24
|
+
# Abstract base class for IdeaModule and IdeaProject
|
25
|
+
class IdeaFile
|
26
|
+
DEFAULT_SUFFIX = ""
|
27
|
+
|
28
|
+
attr_reader :buildr_project
|
29
|
+
attr_writer :suffix
|
30
|
+
attr_writer :id
|
31
|
+
attr_accessor :template
|
32
|
+
|
33
|
+
def suffix
|
34
|
+
@suffix ||= DEFAULT_SUFFIX
|
35
|
+
end
|
36
|
+
|
37
|
+
def filename
|
38
|
+
buildr_project.path_to("#{name}.#{extension}")
|
39
|
+
end
|
40
|
+
|
41
|
+
def id
|
42
|
+
@id ||= buildr_project.name.split(':').last
|
43
|
+
end
|
44
|
+
|
45
|
+
def add_component(name, attrs = {}, &xml)
|
46
|
+
self.components << create_component(name, attrs, &xml)
|
47
|
+
end
|
48
|
+
|
49
|
+
def write(f)
|
50
|
+
document.write f
|
51
|
+
end
|
52
|
+
|
53
|
+
protected
|
54
|
+
|
55
|
+
def name
|
56
|
+
"#{self.id}#{suffix}"
|
57
|
+
end
|
58
|
+
|
59
|
+
def create_component(name, attrs = {})
|
60
|
+
target = StringIO.new
|
61
|
+
Builder::XmlMarkup.new(:target => target, :indent => 2).component(attrs.merge({:name => name})) do |xml|
|
62
|
+
yield xml if block_given?
|
63
|
+
end
|
64
|
+
REXML::Document.new(target.string).root
|
65
|
+
end
|
66
|
+
|
67
|
+
def components
|
68
|
+
@components ||= self.default_components.compact
|
69
|
+
end
|
70
|
+
|
71
|
+
def load_document(filename)
|
72
|
+
REXML::Document.new(File.read(filename))
|
73
|
+
end
|
74
|
+
|
75
|
+
def document
|
76
|
+
if File.exist?(self.filename)
|
77
|
+
doc = load_document(self.filename)
|
78
|
+
else
|
79
|
+
doc = base_document
|
80
|
+
inject_components(doc, self.initial_components)
|
81
|
+
end
|
82
|
+
if self.template
|
83
|
+
template_doc = load_document(self.template)
|
84
|
+
REXML::XPath.each(template_doc, "//component") do |element|
|
85
|
+
inject_component(doc, element)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
inject_components(doc, self.components)
|
89
|
+
doc
|
90
|
+
end
|
91
|
+
|
92
|
+
def inject_components(doc, components)
|
93
|
+
components.each do |component|
|
94
|
+
# execute deferred components
|
95
|
+
component = component.call if Proc === component
|
96
|
+
inject_component(doc, component) if component
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# replace overridden component (if any) with specified component
|
101
|
+
def inject_component(doc, component)
|
102
|
+
doc.root.delete_element("//component[@name='#{component.attributes['name']}']")
|
103
|
+
doc.root.add_element component
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# IdeaModule represents an .iml file
|
108
|
+
class IdeaModule < IdeaFile
|
109
|
+
DEFAULT_TYPE = "JAVA_MODULE"
|
110
|
+
DEFAULT_LOCAL_REPOSITORY_ENV_OVERRIDE = "MAVEN_REPOSITORY"
|
111
|
+
|
112
|
+
attr_accessor :type
|
113
|
+
attr_accessor :local_repository_env_override
|
114
|
+
attr_accessor :group
|
115
|
+
attr_reader :facets
|
116
|
+
|
117
|
+
def initialize
|
118
|
+
@type = DEFAULT_TYPE
|
119
|
+
@local_repository_env_override = DEFAULT_LOCAL_REPOSITORY_ENV_OVERRIDE
|
120
|
+
end
|
121
|
+
|
122
|
+
def buildr_project=(buildr_project)
|
123
|
+
@id = nil
|
124
|
+
@facets = []
|
125
|
+
@skip_content = false
|
126
|
+
@buildr_project = buildr_project
|
127
|
+
end
|
128
|
+
|
129
|
+
def extension
|
130
|
+
"iml"
|
131
|
+
end
|
132
|
+
|
133
|
+
def main_source_directories
|
134
|
+
@main_source_directories ||= [
|
135
|
+
buildr_project.compile.sources,
|
136
|
+
buildr_project.resources.sources
|
137
|
+
].flatten.compact
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_source_directories
|
141
|
+
@test_source_directories ||= [
|
142
|
+
buildr_project.test.compile.sources,
|
143
|
+
buildr_project.test.resources.sources
|
144
|
+
].flatten.compact
|
145
|
+
end
|
146
|
+
|
147
|
+
def excluded_directories
|
148
|
+
@excluded_directories ||= [
|
149
|
+
buildr_project.resources.target,
|
150
|
+
buildr_project.test.resources.target,
|
151
|
+
buildr_project.path_to(:target, :main),
|
152
|
+
buildr_project.path_to(:target, :test),
|
153
|
+
buildr_project.path_to(:reports)
|
154
|
+
].flatten.compact
|
155
|
+
end
|
156
|
+
|
157
|
+
attr_writer :main_output_dir
|
158
|
+
|
159
|
+
def main_output_dir
|
160
|
+
@main_output_dir ||= buildr_project._(:target, :main, :java)
|
161
|
+
end
|
162
|
+
|
163
|
+
attr_writer :test_output_dir
|
164
|
+
|
165
|
+
def test_output_dir
|
166
|
+
@test_output_dir ||= buildr_project._(:target, :test, :java)
|
167
|
+
end
|
168
|
+
|
169
|
+
def main_dependencies
|
170
|
+
@main_dependencies ||= buildr_project.compile.dependencies
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_dependencies
|
174
|
+
@test_dependencies ||= buildr_project.test.compile.dependencies
|
175
|
+
end
|
176
|
+
|
177
|
+
def add_facet(name, type)
|
178
|
+
target = StringIO.new
|
179
|
+
Builder::XmlMarkup.new(:target => target, :indent => 2).facet(:name => name, :type => type) do |xml|
|
180
|
+
yield xml if block_given?
|
181
|
+
end
|
182
|
+
self.facets << REXML::Document.new(target.string).root
|
183
|
+
end
|
184
|
+
|
185
|
+
def skip_content?
|
186
|
+
!!@skip_content
|
187
|
+
end
|
188
|
+
|
189
|
+
def skip_content!
|
190
|
+
@skip_content = true
|
191
|
+
end
|
192
|
+
|
193
|
+
protected
|
194
|
+
|
195
|
+
def test_dependency_details
|
196
|
+
main_dependencies_paths = main_dependencies.map(&:to_s)
|
197
|
+
target_dir = buildr_project.compile.target.to_s
|
198
|
+
test_dependencies.select { |d| d.to_s != target_dir }.collect do |d|
|
199
|
+
dependency_path = d.to_s
|
200
|
+
export = main_dependencies_paths.include?(dependency_path)
|
201
|
+
source_path = nil
|
202
|
+
if d.respond_to?(:to_spec_hash)
|
203
|
+
source_spec = d.to_spec_hash.merge(:classifier => 'sources')
|
204
|
+
source_path = Buildr.artifact(source_spec).to_s
|
205
|
+
source_path = nil unless File.exist?(source_path)
|
206
|
+
end
|
207
|
+
[dependency_path, export, source_path]
|
208
|
+
end
|
209
|
+
|
210
|
+
end
|
211
|
+
|
212
|
+
def base_directory
|
213
|
+
buildr_project.path_to
|
214
|
+
end
|
215
|
+
|
216
|
+
def base_document
|
217
|
+
target = StringIO.new
|
218
|
+
Builder::XmlMarkup.new(:target => target).module(:version => "4", :relativePaths => "true", :type => self.type)
|
219
|
+
REXML::Document.new(target.string)
|
220
|
+
end
|
221
|
+
|
222
|
+
def initial_components
|
223
|
+
[]
|
224
|
+
end
|
225
|
+
|
226
|
+
def default_components
|
227
|
+
[
|
228
|
+
lambda { module_root_component },
|
229
|
+
lambda { facet_component }
|
230
|
+
]
|
231
|
+
end
|
232
|
+
|
233
|
+
def facet_component
|
234
|
+
return nil if self.facets.empty?
|
235
|
+
fm = self.create_component("FacetManager")
|
236
|
+
self.facets.each do |facet|
|
237
|
+
fm.add_element facet
|
238
|
+
end
|
239
|
+
fm
|
240
|
+
end
|
241
|
+
|
242
|
+
def module_root_component
|
243
|
+
create_component("NewModuleRootManager", "inherit-compiler-output" => "false") do |xml|
|
244
|
+
generate_compile_output(xml)
|
245
|
+
generate_content(xml) unless skip_content?
|
246
|
+
generate_initial_order_entries(xml)
|
247
|
+
project_dependencies = []
|
248
|
+
|
249
|
+
# Note: Use the test classpath since IDEA compiles both "main" and "test" classes using the same classpath
|
250
|
+
self.test_dependency_details.each do |dependency_path, export, source_path|
|
251
|
+
project_for_dependency = Buildr.projects.detect do |project|
|
252
|
+
[project.packages, project.compile.target, project.resources.target, project.test.compile.target, project.test.resources.target].flatten.
|
253
|
+
detect { |proj_art| proj_art.to_s == dependency_path }
|
254
|
+
end
|
255
|
+
if project_for_dependency
|
256
|
+
if project_for_dependency.iml? && !project_dependencies.include?(project_for_dependency)
|
257
|
+
generate_project_dependency(xml, project_for_dependency.iml.name, export)
|
258
|
+
end
|
259
|
+
project_dependencies << project_for_dependency
|
260
|
+
next
|
261
|
+
else
|
262
|
+
generate_module_lib(xml, url_for_path(dependency_path), export, (source_path ? url_for_path(source_path) : nil))
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
xml.orderEntryProperties
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
def jar_path(path)
|
271
|
+
"jar://#{resolve_path(path)}!/"
|
272
|
+
end
|
273
|
+
|
274
|
+
def file_path(path)
|
275
|
+
"file://#{resolve_path(path)}"
|
276
|
+
end
|
277
|
+
|
278
|
+
def url_for_path(path)
|
279
|
+
if path =~ /jar$/i
|
280
|
+
jar_path(path)
|
281
|
+
else
|
282
|
+
file_path(path)
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
def resolve_path(path)
|
287
|
+
m2repo = Buildr::Repositories.instance.local
|
288
|
+
if path.to_s.index(m2repo) == 0 && !self.local_repository_env_override.nil?
|
289
|
+
return path.sub(m2repo, "$#{self.local_repository_env_override}$")
|
290
|
+
else
|
291
|
+
begin
|
292
|
+
return "$MODULE_DIR$/#{relative(path)}"
|
293
|
+
rescue ArgumentError
|
294
|
+
# ArgumentError happens on windows when self.base_directory and path are on different drives
|
295
|
+
return path
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
def relative(path)
|
301
|
+
::Buildr::Util.relative_path(File.expand_path(path.to_s), self.base_directory)
|
302
|
+
end
|
303
|
+
|
304
|
+
def generate_compile_output(xml)
|
305
|
+
xml.output(:url => file_path(self.main_output_dir.to_s))
|
306
|
+
xml.tag!("output-test", :url => file_path(self.test_output_dir.to_s))
|
307
|
+
xml.tag!("exclude-output")
|
308
|
+
end
|
309
|
+
|
310
|
+
def generate_content(xml)
|
311
|
+
xml.content(:url => "file://$MODULE_DIR$") do
|
312
|
+
# Source folders
|
313
|
+
{
|
314
|
+
:main => self.main_source_directories,
|
315
|
+
:test => self.test_source_directories
|
316
|
+
}.each do |kind, directories|
|
317
|
+
directories.map { |dir| dir.to_s }.compact.sort.uniq.each do |dir|
|
318
|
+
xml.sourceFolder :url => file_path(dir), :isTestSource => (kind == :test ? 'true' : 'false')
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
# Exclude target directories
|
323
|
+
self.net_excluded_directories.
|
324
|
+
collect { |dir| file_path(dir) }.
|
325
|
+
select { |dir| relative_dir_inside_dir?(dir) }.
|
326
|
+
sort.each do |dir|
|
327
|
+
xml.excludeFolder :url => dir
|
328
|
+
end
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
def relative_dir_inside_dir?(dir)
|
333
|
+
!dir.include?("../")
|
334
|
+
end
|
335
|
+
|
336
|
+
def generate_initial_order_entries(xml)
|
337
|
+
xml.orderEntry :type => "sourceFolder", :forTests => "false"
|
338
|
+
xml.orderEntry :type => "inheritedJdk"
|
339
|
+
end
|
340
|
+
|
341
|
+
def generate_project_dependency(xml, other_project, export = true)
|
342
|
+
attribs = {:type => 'module', "module-name" => other_project}
|
343
|
+
attribs[:exported] = '' if export
|
344
|
+
xml.orderEntry attribs
|
345
|
+
end
|
346
|
+
|
347
|
+
def generate_module_lib(xml, path, export, source_path)
|
348
|
+
attribs = {:type => 'module-library'}
|
349
|
+
attribs[:exported] = '' if export
|
350
|
+
xml.orderEntry attribs do
|
351
|
+
xml.library do
|
352
|
+
xml.CLASSES do
|
353
|
+
xml.root :url => path
|
354
|
+
end
|
355
|
+
xml.JAVADOC
|
356
|
+
xml.SOURCES do
|
357
|
+
if source_path
|
358
|
+
xml.root :url => source_path
|
359
|
+
end
|
360
|
+
end
|
361
|
+
end
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
# Don't exclude things that are subdirectories of other excluded things
|
366
|
+
def net_excluded_directories
|
367
|
+
net = []
|
368
|
+
all = self.excluded_directories.map { |dir| buildr_project._(dir.to_s) }.sort_by { |d| d.size }
|
369
|
+
all.each_with_index do |dir, i|
|
370
|
+
unless all[0 ... i].find { |other| dir =~ /^#{other}/ }
|
371
|
+
net << dir
|
372
|
+
end
|
373
|
+
end
|
374
|
+
net
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
# IdeaModule represents an .ipr file
|
379
|
+
class IdeaProject < IdeaFile
|
380
|
+
attr_accessor :vcs
|
381
|
+
attr_accessor :extra_modules
|
382
|
+
attr_writer :jdk_version
|
383
|
+
|
384
|
+
def initialize(buildr_project)
|
385
|
+
@buildr_project = buildr_project
|
386
|
+
@vcs = detect_vcs
|
387
|
+
@extra_modules = []
|
388
|
+
end
|
389
|
+
|
390
|
+
def jdk_version
|
391
|
+
@jdk_version ||= buildr_project.compile.options.source || "1.6"
|
392
|
+
end
|
393
|
+
|
394
|
+
protected
|
395
|
+
|
396
|
+
def extension
|
397
|
+
"ipr"
|
398
|
+
end
|
399
|
+
|
400
|
+
def detect_vcs
|
401
|
+
if File.directory?(buildr_project._('.svn'))
|
402
|
+
"svn"
|
403
|
+
elsif File.directory?(buildr_project._('.git'))
|
404
|
+
"Git"
|
405
|
+
end
|
406
|
+
end
|
407
|
+
|
408
|
+
def base_document
|
409
|
+
target = StringIO.new
|
410
|
+
Builder::XmlMarkup.new(:target => target).project(:version => "4", :relativePaths => "false")
|
411
|
+
REXML::Document.new(target.string)
|
412
|
+
end
|
413
|
+
|
414
|
+
def default_components
|
415
|
+
[
|
416
|
+
lambda { modules_component },
|
417
|
+
vcs_component
|
418
|
+
]
|
419
|
+
end
|
420
|
+
|
421
|
+
def initial_components
|
422
|
+
[
|
423
|
+
lambda { project_root_manager_component },
|
424
|
+
lambda { project_details_component }
|
425
|
+
]
|
426
|
+
end
|
427
|
+
|
428
|
+
def project_root_manager_component
|
429
|
+
attribs = {"version" => "2",
|
430
|
+
"assert-keyword" => "true",
|
431
|
+
"jdk-15" => "true",
|
432
|
+
"project-jdk-name" => self.jdk_version,
|
433
|
+
"project-jdk-type" => "JavaSDK",
|
434
|
+
"languageLevel" => "JDK_#{self.jdk_version.gsub('.', '_')}"}
|
435
|
+
create_component("ProjectRootManager", attribs) do |xml|
|
436
|
+
xml.output("url" => "file://$PROJECT_DIR$/out")
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
440
|
+
def project_details_component
|
441
|
+
create_component("ProjectDetails") do |xml|
|
442
|
+
xml.option("name" => "projectName", "value" => self.name)
|
443
|
+
end
|
444
|
+
end
|
445
|
+
|
446
|
+
def modules_component
|
447
|
+
create_component("ProjectModuleManager") do |xml|
|
448
|
+
xml.modules do
|
449
|
+
buildr_project.projects.select { |subp| subp.iml? }.each do |subproject|
|
450
|
+
module_path = subproject.base_dir.gsub(/^#{buildr_project.base_dir}\//, '')
|
451
|
+
path = "#{module_path}/#{subproject.iml.name}.iml"
|
452
|
+
attribs = {:fileurl => "file://$PROJECT_DIR$/#{path}", :filepath => "$PROJECT_DIR$/#{path}"}
|
453
|
+
if subproject.iml.group == true
|
454
|
+
attribs[:group] = subproject.parent.name.gsub(':', '/')
|
455
|
+
elsif !subproject.iml.group.nil?
|
456
|
+
attribs[:group] = subproject.group.to_s
|
457
|
+
end
|
458
|
+
xml.module attribs
|
459
|
+
end
|
460
|
+
self.extra_modules.each do |iml_file|
|
461
|
+
xml.module :fileurl => "file://$PROJECT_DIR$/#{iml_file}",
|
462
|
+
:filepath => "$PROJECT_DIR$/#{iml_file}"
|
463
|
+
end
|
464
|
+
if buildr_project.iml?
|
465
|
+
xml.module :fileurl => "file://$PROJECT_DIR$/#{buildr_project.iml.name}.iml",
|
466
|
+
:filepath => "$PROJECT_DIR$/#{buildr_project.iml.name}.iml"
|
467
|
+
end
|
468
|
+
end
|
469
|
+
end
|
470
|
+
end
|
471
|
+
|
472
|
+
def vcs_component
|
473
|
+
if vcs
|
474
|
+
create_component("VcsDirectoryMappings") do |xml|
|
475
|
+
xml.mapping :directory => "", :vcs => vcs
|
476
|
+
end
|
477
|
+
end
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
module ProjectExtension
|
482
|
+
include Extension
|
483
|
+
|
484
|
+
first_time do
|
485
|
+
desc "Generate Intellij IDEA artifacts for all projects"
|
486
|
+
Project.local_task "idea:generate" => "artifacts"
|
487
|
+
|
488
|
+
desc "Delete the generated Intellij IDEA artifacts"
|
489
|
+
Project.local_task "idea:clean"
|
490
|
+
end
|
491
|
+
|
492
|
+
before_define do |project|
|
493
|
+
project.recursive_task("idea:generate")
|
494
|
+
project.recursive_task("idea:clean")
|
495
|
+
end
|
496
|
+
|
497
|
+
after_define do |project|
|
498
|
+
idea = project.task("idea:generate")
|
499
|
+
|
500
|
+
files = [
|
501
|
+
(project.iml if project.iml?),
|
502
|
+
(project.ipr if project.ipr?)
|
503
|
+
].compact
|
504
|
+
|
505
|
+
files.each do |ideafile|
|
506
|
+
module_dir = File.dirname(ideafile.filename)
|
507
|
+
# Need to clear the actions else the extension included as part of buildr will run
|
508
|
+
file(ideafile.filename).clear_actions
|
509
|
+
idea.enhance [file(ideafile.filename)]
|
510
|
+
file(ideafile.filename => [Buildr.application.buildfile]) do |task|
|
511
|
+
mkdir_p module_dir
|
512
|
+
info "Writing #{task.name}"
|
513
|
+
t = Tempfile.open("buildr-idea")
|
514
|
+
temp_filename = t.path
|
515
|
+
t.close!
|
516
|
+
File.open(temp_filename, "w") do |f|
|
517
|
+
ideafile.write f
|
518
|
+
end
|
519
|
+
mv temp_filename, ideafile.filename
|
520
|
+
end
|
521
|
+
end
|
522
|
+
|
523
|
+
project.task("idea:clean") do
|
524
|
+
files.each do |f|
|
525
|
+
info "Removing #{f.filename}" if File.exist?(f.filename)
|
526
|
+
rm_rf f.filename
|
527
|
+
end
|
528
|
+
end
|
529
|
+
end
|
530
|
+
|
531
|
+
def ipr
|
532
|
+
if ipr?
|
533
|
+
@ipr ||= IdeaProject.new(self)
|
534
|
+
else
|
535
|
+
raise "Only the root project has an IPR"
|
536
|
+
end
|
537
|
+
end
|
538
|
+
|
539
|
+
def ipr?
|
540
|
+
!@no_ipr && self.parent.nil?
|
541
|
+
end
|
542
|
+
|
543
|
+
def iml
|
544
|
+
if iml?
|
545
|
+
unless @iml
|
546
|
+
inheritable_iml_source = self.parent
|
547
|
+
while inheritable_iml_source && !inheritable_iml_source.iml?
|
548
|
+
inheritable_iml_source = inheritable_iml_source.parent;
|
549
|
+
end
|
550
|
+
@iml = inheritable_iml_source ? inheritable_iml_source.iml.clone : IdeaModule.new
|
551
|
+
@iml.buildr_project = self
|
552
|
+
end
|
553
|
+
return @iml
|
554
|
+
else
|
555
|
+
raise "IML generation is disabled for #{self.name}"
|
556
|
+
end
|
557
|
+
end
|
558
|
+
|
559
|
+
def no_ipr
|
560
|
+
@no_ipr = true
|
561
|
+
end
|
562
|
+
|
563
|
+
def no_iml
|
564
|
+
@has_iml = false
|
565
|
+
end
|
566
|
+
|
567
|
+
def iml?
|
568
|
+
@has_iml = @has_iml.nil? ? true : @has_iml
|
569
|
+
end
|
570
|
+
end
|
571
|
+
end
|
572
|
+
end
|
573
|
+
|
574
|
+
class Buildr::Project
|
575
|
+
include Buildr::IntellijIdea::ProjectExtension
|
576
|
+
end
|