buildr 1.4.6-java → 1.4.7-java
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +81 -0
- data/Rakefile +5 -2
- data/addon/buildr/antlr.rb +0 -4
- data/addon/buildr/bnd.rb +3 -1
- data/addon/buildr/checkstyle.rb +201 -0
- data/addon/buildr/cobertura.rb +0 -1
- data/addon/buildr/drb.rb +0 -2
- data/addon/buildr/emma.rb +0 -1
- data/addon/buildr/findbugs.rb +227 -0
- data/addon/buildr/gwt.rake +82 -0
- data/addon/buildr/hibernate.rb +0 -4
- data/addon/buildr/javacc.rb +0 -4
- data/addon/buildr/javancss.rb +155 -0
- data/addon/buildr/jdepend.rb +138 -24
- data/addon/buildr/jdepend.rb.orig +178 -0
- data/addon/buildr/jetty.rb +0 -5
- data/addon/buildr/jibx.rb +85 -86
- data/addon/buildr/nailgun.rb +2 -2
- data/addon/buildr/openjpa.rb +0 -4
- data/addon/buildr/pmd.rb +166 -0
- data/addon/buildr/protobuf.rb +0 -1
- data/addon/buildr/sonar.rb +142 -0
- data/addon/buildr/xmlbeans.rb +0 -5
- data/buildr.gemspec +36 -21
- data/doc/_layouts/default.html +1 -0
- data/doc/contributing.textile +11 -2
- data/doc/download.textile +17 -5
- data/doc/index.textile +21 -46
- data/doc/installing.textile +18 -8
- data/doc/installing.textile.orig +282 -0
- data/doc/languages.textile +0 -38
- data/doc/more_stuff.textile +199 -12
- data/doc/more_stuff.textile.orig +1004 -0
- data/doc/packaging.textile +10 -0
- data/doc/settings_profiles.textile +2 -2
- data/etc/KEYS +44 -0
- data/lib/buildr.rb +67 -4
- data/lib/buildr/clojure.rb +0 -2
- data/lib/buildr/core/application.rb +23 -32
- data/lib/buildr/core/build.rb +0 -7
- data/lib/buildr/core/cc.rb +0 -5
- data/lib/buildr/core/checks.rb +0 -4
- data/lib/buildr/core/common.rb +0 -5
- data/lib/buildr/core/compile.rb +5 -10
- data/lib/buildr/core/doc.rb +9 -3
- data/lib/buildr/core/environment.rb +0 -1
- data/lib/buildr/core/filter.rb +0 -5
- data/lib/buildr/core/generate.rb +2 -6
- data/lib/buildr/core/help.rb +1 -6
- data/lib/buildr/core/linux.rb +0 -1
- data/lib/buildr/core/osx.rb +0 -1
- data/lib/buildr/core/project.rb +0 -4
- data/lib/buildr/core/run.rb +1 -5
- data/lib/buildr/core/shell.rb +1 -6
- data/lib/buildr/core/test.rb +1 -7
- data/lib/buildr/core/transports.rb +4 -6
- data/lib/buildr/core/util.rb +2 -65
- data/lib/buildr/groovy/doc.rb +0 -3
- data/lib/buildr/groovy/shell.rb +0 -2
- data/lib/buildr/ide/eclipse.rb +4 -13
- data/lib/buildr/ide/eclipse/java.rb +0 -4
- data/lib/buildr/ide/eclipse/plugin.rb +0 -4
- data/lib/buildr/ide/eclipse/scala.rb +0 -4
- data/lib/buildr/ide/idea.rb +284 -52
- data/lib/buildr/java/ant.rb +2 -6
- data/lib/buildr/java/bdd.rb +5 -123
- data/lib/buildr/java/cobertura.rb +16 -10
- data/lib/buildr/java/commands.rb +33 -7
- data/lib/buildr/java/compiler.rb +0 -7
- data/lib/buildr/java/deprecated.rb +0 -4
- data/lib/buildr/java/doc.rb +0 -2
- data/lib/buildr/java/emma.rb +0 -4
- data/lib/buildr/java/jruby.rb +0 -2
- data/lib/buildr/java/packaging.rb +0 -4
- data/lib/buildr/java/pom.rb +24 -16
- data/lib/buildr/java/rjb.rb +1 -1
- data/lib/buildr/java/test_result.rb +1 -2
- data/lib/buildr/java/tests.rb +68 -6
- data/lib/buildr/packaging/archive.rb +0 -1
- data/lib/buildr/packaging/artifact.rb +19 -16
- data/lib/buildr/packaging/artifact_namespace.rb +51 -24
- data/lib/buildr/packaging/artifact_search.rb +1 -2
- data/lib/buildr/packaging/gems.rb +1 -13
- data/lib/buildr/packaging/package.rb +0 -6
- data/lib/buildr/packaging/tar.rb +2 -4
- data/lib/buildr/packaging/version_requirement.rb +1 -1
- data/lib/buildr/packaging/zip.rb +1 -2
- data/lib/buildr/packaging/ziptask.rb +0 -4
- data/lib/buildr/run.rb +3 -3
- data/lib/buildr/scala/bdd.rb +129 -11
- data/lib/buildr/scala/compiler.rb +53 -6
- data/lib/buildr/scala/doc.rb +6 -4
- data/lib/buildr/scala/org/apache/buildr/Specs2Runner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/Specs2Runner.java +38 -0
- data/lib/buildr/scala/shell.rb +0 -4
- data/lib/buildr/scala/tests.rb +15 -6
- data/lib/buildr/shell.rb +0 -1
- data/lib/buildr/version.rb +1 -1
- data/rakelib/all-in-one.rake +20 -11
- data/rakelib/checks.rake +0 -31
- data/rakelib/doc.rake +86 -100
- data/rakelib/package.rake +3 -3
- data/rakelib/release.rake +1 -1
- data/rakelib/rspec.rake +23 -7
- data/rakelib/stage.rake +18 -21
- data/spec/addon/bnd_spec.rb +2 -2
- data/spec/addon/jaxb_xjc_spec.rb +5 -0
- data/spec/core/application_spec.rb +11 -64
- data/spec/core/cc_spec.rb +12 -5
- data/spec/core/compile_spec.rb +11 -0
- data/spec/core/doc_spec.rb +1 -1
- data/spec/core/run_spec.rb +17 -4
- data/spec/core/test_spec.rb +5 -3
- data/spec/ide/idea_spec.rb +60 -0
- data/spec/java/bdd_spec.rb +8 -218
- data/spec/java/cobertura_spec.rb +4 -0
- data/spec/java/compiler_spec.rb +11 -8
- data/spec/java/emma_spec.rb +4 -1
- data/spec/java/java_spec.rb +1 -1
- data/spec/java/pom_spec.rb +125 -0
- data/spec/java/tests_spec.rb +185 -0
- data/spec/packaging/archive_spec.rb +1 -1
- data/spec/packaging/artifact_namespace_spec.rb +15 -0
- data/spec/packaging/artifact_spec.rb +26 -1
- data/spec/sandbox.rb +7 -1
- data/spec/scala/bdd_spec.rb +111 -8
- data/spec/scala/tests_spec.rb +5 -1
- data/spec/spec_helpers.rb +9 -4
- data/spec/version_requirement_spec.rb +2 -0
- metadata +499 -467
- data/lib/buildr/core.rb +0 -34
- data/lib/buildr/ide.rb +0 -19
- data/lib/buildr/java.rb +0 -25
- data/lib/buildr/java/jtestr_result.rb +0 -331
- data/lib/buildr/java/jtestr_runner.rb.erb +0 -116
- data/lib/buildr/packaging.rb +0 -25
- data/rakelib/setup.rake +0 -68
@@ -0,0 +1,82 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
module Buildr
|
17
|
+
module GWT
|
18
|
+
|
19
|
+
class << self
|
20
|
+
# The specs for requirements
|
21
|
+
def dependencies
|
22
|
+
['com.google.gwt:gwt-dev:jar:2.4.0']
|
23
|
+
end
|
24
|
+
|
25
|
+
def gwtc_main(modules, source_artifacts, output_dir, options = {})
|
26
|
+
cp = Buildr.artifacts(self.dependencies).each(&:invoke).map(&:to_s) + Buildr.artifacts(source_artifacts).each(&:invoke).map(&:to_s)
|
27
|
+
style = options[:style] || "OBFUSCATED," # "PRETTY", "DETAILED"
|
28
|
+
log_level = options[:log_level] # ERROR, WARN, INFO, TRACE, DEBUG, SPAM, or ALL
|
29
|
+
workers = options[:workers] || 2
|
30
|
+
|
31
|
+
args = []
|
32
|
+
if log_level
|
33
|
+
args << "-logLevel"
|
34
|
+
args << log_level
|
35
|
+
end
|
36
|
+
args << "-strict"
|
37
|
+
args << "-style"
|
38
|
+
args << style
|
39
|
+
args << "-localWorkers"
|
40
|
+
args << workers
|
41
|
+
args << "-war"
|
42
|
+
args << output_dir
|
43
|
+
if options[:compile_report_dir]
|
44
|
+
args << "-compileReport"
|
45
|
+
args << "-extra"
|
46
|
+
args << options[:compile_report_dir]
|
47
|
+
end
|
48
|
+
|
49
|
+
if options[:draft_compile]
|
50
|
+
args << "-draftCompile"
|
51
|
+
end
|
52
|
+
|
53
|
+
args += modules
|
54
|
+
|
55
|
+
Java::Commands.java 'com.google.gwt.dev.Compiler', *(args + [{:classpath => cp, :properties => options[:properties], :java_args => options[:java_args]}])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
module ProjectExtension
|
60
|
+
include Extension
|
61
|
+
|
62
|
+
def gwt(module_names, options = {})
|
63
|
+
output_key = options[:output_key] || project.id
|
64
|
+
output_dir = project._(:target, :generated, :gwt, output_key)
|
65
|
+
artifacts = (project.compile.sources + project.resources.sources).collect do |a|
|
66
|
+
a.is_a?(String) ? file(a) : a
|
67
|
+
end
|
68
|
+
dependencies = artifacts(options[:dependencies]) || project.compile.dependencies
|
69
|
+
task = file(output_dir) do
|
70
|
+
Buildr::GWT.gwtc_main(module_names, dependencies + artifacts, output_dir, options.dup)
|
71
|
+
end
|
72
|
+
task.enhance(dependencies)
|
73
|
+
task.enhance([project.compile])
|
74
|
+
task
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
class Buildr::Project
|
81
|
+
include Buildr::GWT::ProjectExtension
|
82
|
+
end
|
data/addon/buildr/hibernate.rb
CHANGED
@@ -13,10 +13,6 @@
|
|
13
13
|
# License for the specific language governing permissions and limitations under
|
14
14
|
# the License.
|
15
15
|
|
16
|
-
|
17
|
-
require 'buildr/java'
|
18
|
-
|
19
|
-
|
20
16
|
module Buildr
|
21
17
|
|
22
18
|
# Provides Hibernate Doclet and schema export tasks. Require explicitly using <code>require "buildr/hibernate"</code>.
|
data/addon/buildr/javacc.rb
CHANGED
@@ -13,10 +13,6 @@
|
|
13
13
|
# License for the specific language governing permissions and limitations under
|
14
14
|
# the License.
|
15
15
|
|
16
|
-
|
17
|
-
require 'buildr/java'
|
18
|
-
|
19
|
-
|
20
16
|
module Buildr
|
21
17
|
# Provides JavaCC compile tasks. Require explicitly using <code>require "buildr/javacc"</code>.
|
22
18
|
module JavaCC
|
@@ -0,0 +1,155 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
module Buildr
|
17
|
+
# Provides the <code>javancss:html</code> and <code>javancss:xml</code> tasks.
|
18
|
+
# Require explicitly using <code>require "buildr/javancss"</code>.
|
19
|
+
module JavaNCSS
|
20
|
+
|
21
|
+
class << self
|
22
|
+
|
23
|
+
# The specs for requirements
|
24
|
+
def dependencies
|
25
|
+
[
|
26
|
+
'org.codehaus.javancss:javancss:jar:32.53',
|
27
|
+
'javancss:ccl:jar:29.50',
|
28
|
+
'javancss:jhbasic:jar:29.50'
|
29
|
+
]
|
30
|
+
end
|
31
|
+
|
32
|
+
def javancss(output_file, source_paths, options = {})
|
33
|
+
dependencies = (options[:dependencies] || []) + self.dependencies
|
34
|
+
cp = Buildr.artifacts(dependencies).each(&:invoke).map(&:to_s)
|
35
|
+
|
36
|
+
args = []
|
37
|
+
args << "-all"
|
38
|
+
args << "-xml"
|
39
|
+
args << "-out"
|
40
|
+
args << output_file
|
41
|
+
args << "-recursive"
|
42
|
+
source_paths.each do |source_path|
|
43
|
+
args << source_path
|
44
|
+
end
|
45
|
+
|
46
|
+
begin
|
47
|
+
Java::Commands.java 'javancss.Main', *(args + [{:classpath => cp, :properties => options[:properties], :java_args => options[:java_args]}])
|
48
|
+
rescue => e
|
49
|
+
raise e if options[:fail_on_error]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Config
|
55
|
+
def enabled?
|
56
|
+
!!@enabled
|
57
|
+
end
|
58
|
+
|
59
|
+
attr_writer :enabled
|
60
|
+
|
61
|
+
def html_enabled?
|
62
|
+
File.exist?(self.style_file)
|
63
|
+
end
|
64
|
+
|
65
|
+
attr_writer :config_directory
|
66
|
+
|
67
|
+
def config_directory
|
68
|
+
@config_directory || project._(:source, :main, :etc, :javancss)
|
69
|
+
end
|
70
|
+
|
71
|
+
attr_writer :report_dir
|
72
|
+
|
73
|
+
def report_dir
|
74
|
+
@report_dir || project._(:reports, :javancss)
|
75
|
+
end
|
76
|
+
|
77
|
+
attr_writer :fail_on_error
|
78
|
+
|
79
|
+
def fail_on_error?
|
80
|
+
@fail_on_error.nil? ? false : @fail_on_error
|
81
|
+
end
|
82
|
+
|
83
|
+
attr_writer :xml_output_file
|
84
|
+
|
85
|
+
def xml_output_file
|
86
|
+
@xml_output_file || "#{self.report_dir}/javancss.xml"
|
87
|
+
end
|
88
|
+
|
89
|
+
attr_writer :html_output_file
|
90
|
+
|
91
|
+
def html_output_file
|
92
|
+
@html_output_file || "#{self.report_dir}/javancss.html"
|
93
|
+
end
|
94
|
+
|
95
|
+
attr_writer :style_file
|
96
|
+
|
97
|
+
def style_file
|
98
|
+
@style_file || "#{self.config_directory}/javancss2html.xsl"
|
99
|
+
end
|
100
|
+
|
101
|
+
def source_paths
|
102
|
+
@source_paths ||= [self.project.compile.sources, self.project.test.compile.sources]
|
103
|
+
end
|
104
|
+
|
105
|
+
protected
|
106
|
+
|
107
|
+
def initialize(project)
|
108
|
+
@project = project
|
109
|
+
end
|
110
|
+
|
111
|
+
attr_reader :project
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
module ProjectExtension
|
116
|
+
include Extension
|
117
|
+
|
118
|
+
def javancss
|
119
|
+
@javancss ||= Buildr::JavaNCSS::Config.new(project)
|
120
|
+
end
|
121
|
+
|
122
|
+
after_define do |project|
|
123
|
+
if project.javancss.enabled?
|
124
|
+
desc "Generate JavaNCSS xml report."
|
125
|
+
project.task("javancss:xml") do
|
126
|
+
puts "JavaNCSS: Analyzing source code..."
|
127
|
+
mkdir_p File.dirname(project.javancss.xml_output_file)
|
128
|
+
Buildr::JavaNCSS.javancss(project.javancss.xml_output_file,
|
129
|
+
project.javancss.source_paths.flatten.compact,
|
130
|
+
:fail_on_error => project.javancss.fail_on_error?)
|
131
|
+
end
|
132
|
+
|
133
|
+
if project.javancss.html_enabled?
|
134
|
+
xml_task = project.task("javancss:xml")
|
135
|
+
desc "Generate JavaNCSS html report."
|
136
|
+
project.task("javancss:html" => xml_task) do
|
137
|
+
puts "JavaNCSS: Generating report"
|
138
|
+
mkdir_p File.dirname(project.javancss.html_output_file)
|
139
|
+
Buildr.ant "javancss" do |ant|
|
140
|
+
ant.xslt :in => project.javancss.xml_output_file,
|
141
|
+
:out => project.javancss.html_output_file,
|
142
|
+
:style => project.javancss.style_file
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
class Buildr::Project
|
154
|
+
include Buildr::JavaNCSS::ProjectExtension
|
155
|
+
end
|
data/addon/buildr/jdepend.rb
CHANGED
@@ -13,48 +13,162 @@
|
|
13
13
|
# License for the specific language governing permissions and limitations under
|
14
14
|
# the License.
|
15
15
|
|
16
|
+
module Buildr
|
17
|
+
# Addes the <code>projectname:jdepend:swing</code>, <code>projectname:jdepend:text</code> and
|
18
|
+
# <code>projectname:jdepend:xml</code> tasks.
|
19
|
+
#
|
20
|
+
# Require explicitly using <code>require "buildr/jdepend"</code>.
|
21
|
+
module JDepend
|
16
22
|
|
17
|
-
|
23
|
+
class << self
|
18
24
|
|
25
|
+
# The specs for requirements
|
26
|
+
def dependencies
|
27
|
+
[
|
28
|
+
'jdepend:jdepend:jar:2.9.1'
|
29
|
+
]
|
30
|
+
end
|
19
31
|
|
20
|
-
|
32
|
+
def jdepend(output_file, target_paths, options = {})
|
33
|
+
dependencies = (options[:dependencies] || []) + self.dependencies
|
34
|
+
cp = Buildr.artifacts(dependencies).each(&:invoke).map(&:to_s)
|
21
35
|
|
22
|
-
|
23
|
-
|
24
|
-
|
36
|
+
args = []
|
37
|
+
if output_file
|
38
|
+
args << "-file"
|
39
|
+
args << output_file
|
40
|
+
end
|
41
|
+
target_paths.each do |target_path|
|
42
|
+
file(target_path).invoke
|
43
|
+
args << target_path.to_s
|
44
|
+
end
|
25
45
|
|
26
|
-
|
46
|
+
# If no output file then we must be trying to run the swing app
|
47
|
+
command = output_file ? 'jdepend.xmlui.JDepend' : 'jdepend.swingui.JDepend'
|
27
48
|
|
28
|
-
|
49
|
+
begin
|
50
|
+
Java::Commands.java command, *(args + [{:classpath => cp, :properties => options[:properties], :java_args => options[:java_args]}])
|
51
|
+
rescue => e
|
52
|
+
raise e if options[:fail_on_error]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
29
56
|
|
30
|
-
|
31
|
-
|
57
|
+
class Config
|
58
|
+
def enabled?
|
59
|
+
!!@enabled
|
32
60
|
end
|
33
61
|
|
34
|
-
|
35
|
-
|
36
|
-
|
62
|
+
attr_writer :enabled
|
63
|
+
|
64
|
+
def html_enabled?
|
65
|
+
File.exist?(self.style_file)
|
37
66
|
end
|
38
67
|
|
39
|
-
|
68
|
+
attr_writer :config_directory
|
40
69
|
|
41
|
-
|
70
|
+
def config_directory
|
71
|
+
@config_directory || project._(:source, :main, :etc, :jdepend)
|
72
|
+
end
|
73
|
+
|
74
|
+
attr_writer :report_dir
|
75
|
+
|
76
|
+
def report_dir
|
77
|
+
@report_dir || project._(:reports, :jdepend)
|
78
|
+
end
|
79
|
+
|
80
|
+
attr_writer :fail_on_error
|
42
81
|
|
43
|
-
|
44
|
-
|
45
|
-
Java::Commands.java "jdepend.swingui.JDepend", paths, :classpath=>requires, :name=>"JDepend"
|
82
|
+
def fail_on_error?
|
83
|
+
@fail_on_error.nil? ? false : @fail_on_error
|
46
84
|
end
|
47
85
|
|
48
|
-
|
49
|
-
|
50
|
-
|
86
|
+
attr_writer :xml_output_file
|
87
|
+
|
88
|
+
def xml_output_file
|
89
|
+
@xml_output_file || "#{self.report_dir}/jdepend.xml"
|
51
90
|
end
|
52
91
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
92
|
+
attr_writer :html_output_file
|
93
|
+
|
94
|
+
def html_output_file
|
95
|
+
@html_output_file || "#{self.report_dir}/jdepend.html"
|
96
|
+
end
|
97
|
+
|
98
|
+
attr_writer :style_file
|
99
|
+
|
100
|
+
def style_file
|
101
|
+
@style_file || "#{self.config_directory}/jdepend.xsl"
|
102
|
+
end
|
103
|
+
|
104
|
+
def target_paths
|
105
|
+
@target_paths ||= [self.project.compile.target, self.project.test.compile.target]
|
106
|
+
end
|
107
|
+
|
108
|
+
def to_options
|
109
|
+
{
|
110
|
+
:fail_on_error => project.jdepend.fail_on_error?,
|
111
|
+
# Set user home so that jdepend.properties will be loaded from there if present
|
112
|
+
:properties => { 'user.home' => project.jdepend.config_directory }
|
113
|
+
}
|
114
|
+
end
|
115
|
+
|
116
|
+
protected
|
117
|
+
|
118
|
+
def initialize(project)
|
119
|
+
@project = project
|
120
|
+
end
|
121
|
+
|
122
|
+
attr_reader :project
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
module ProjectExtension
|
127
|
+
include Extension
|
128
|
+
|
129
|
+
def jdepend
|
130
|
+
@jdepend ||= Buildr::JDepend::Config.new(project)
|
131
|
+
end
|
132
|
+
|
133
|
+
after_define do |project|
|
134
|
+
if project.jdepend.enabled?
|
135
|
+
desc "Generate JDepend xml report."
|
136
|
+
project.task("jdepend:xml") do
|
137
|
+
puts "JDepend: Analyzing source code..."
|
138
|
+
mkdir_p File.dirname(project.jdepend.xml_output_file)
|
139
|
+
Buildr::JDepend.jdepend(project.jdepend.xml_output_file,
|
140
|
+
project.jdepend.target_paths.flatten.compact,
|
141
|
+
project.jdepend.to_options)
|
142
|
+
end
|
143
|
+
|
144
|
+
desc "Run JDepend with Swing UI."
|
145
|
+
project.task("jdepend:swing") do
|
146
|
+
puts "JDepend: Analyzing source code..."
|
147
|
+
Buildr::JDepend.jdepend(nil,
|
148
|
+
project.jdepend.target_paths.flatten.compact,
|
149
|
+
project.jdepend.to_options)
|
150
|
+
end
|
151
|
+
|
152
|
+
if project.jdepend.html_enabled?
|
153
|
+
xml_task = project.task("jdepend:xml")
|
154
|
+
desc "Generate JDepend html report."
|
155
|
+
project.task("jdepend:html" => xml_task) do
|
156
|
+
puts "JDepend: Generating report"
|
157
|
+
mkdir_p File.dirname(project.jdepend.html_output_file)
|
158
|
+
Buildr.ant "jdepend" do |ant|
|
159
|
+
ant.xslt :in => project.jdepend.xml_output_file,
|
160
|
+
:out => project.jdepend.html_output_file,
|
161
|
+
:style => project.jdepend.style_file
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
end
|
57
167
|
end
|
58
168
|
end
|
59
169
|
end
|
60
170
|
end
|
171
|
+
|
172
|
+
class Buildr::Project
|
173
|
+
include Buildr::JDepend::ProjectExtension
|
174
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
module Buildr
|
17
|
+
# Addes the <code>projectname:jdepend:swing</code>, <code>projectname:jdepend:text</code> and
|
18
|
+
# <code>projectname:jdepend:xml</code> tasks.
|
19
|
+
#
|
20
|
+
# Require explicitly using <code>require "buildr/jdepend"</code>.
|
21
|
+
module JDepend
|
22
|
+
|
23
|
+
class << self
|
24
|
+
|
25
|
+
# The specs for requirements
|
26
|
+
def dependencies
|
27
|
+
[
|
28
|
+
'jdepend:jdepend:jar:2.9.1'
|
29
|
+
]
|
30
|
+
end
|
31
|
+
|
32
|
+
def jdepend(output_file, target_paths, options = {})
|
33
|
+
dependencies = (options[:dependencies] || []) + self.dependencies
|
34
|
+
cp = Buildr.artifacts(dependencies).each(&:invoke).map(&:to_s)
|
35
|
+
|
36
|
+
args = []
|
37
|
+
if output_file
|
38
|
+
args << "-file"
|
39
|
+
args << output_file
|
40
|
+
end
|
41
|
+
target_paths.each do |target_path|
|
42
|
+
file(target_path).invoke
|
43
|
+
<<<<<<< HEAD
|
44
|
+
args << target_path
|
45
|
+
=======
|
46
|
+
args << target_path.to_s
|
47
|
+
>>>>>>> 28deb000947f13d5df722228ed2bc24fdcb303d3
|
48
|
+
end
|
49
|
+
|
50
|
+
# If no output file then we must be trying to run the swing app
|
51
|
+
command = output_file ? 'jdepend.xmlui.JDepend' : 'jdepend.swingui.JDepend'
|
52
|
+
|
53
|
+
begin
|
54
|
+
Java::Commands.java command, *(args + [{:classpath => cp, :properties => options[:properties], :java_args => options[:java_args]}])
|
55
|
+
rescue => e
|
56
|
+
raise e if options[:fail_on_error]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class Config
|
62
|
+
def enabled?
|
63
|
+
!!@enabled
|
64
|
+
end
|
65
|
+
|
66
|
+
attr_writer :enabled
|
67
|
+
|
68
|
+
def html_enabled?
|
69
|
+
File.exist?(self.style_file)
|
70
|
+
end
|
71
|
+
|
72
|
+
attr_writer :config_directory
|
73
|
+
|
74
|
+
def config_directory
|
75
|
+
@config_directory || project._(:source, :main, :etc, :jdepend)
|
76
|
+
end
|
77
|
+
|
78
|
+
attr_writer :report_dir
|
79
|
+
|
80
|
+
def report_dir
|
81
|
+
@report_dir || project._(:reports, :jdepend)
|
82
|
+
end
|
83
|
+
|
84
|
+
attr_writer :fail_on_error
|
85
|
+
|
86
|
+
def fail_on_error?
|
87
|
+
@fail_on_error.nil? ? false : @fail_on_error
|
88
|
+
end
|
89
|
+
|
90
|
+
attr_writer :xml_output_file
|
91
|
+
|
92
|
+
def xml_output_file
|
93
|
+
@xml_output_file || "#{self.report_dir}/jdepend.xml"
|
94
|
+
end
|
95
|
+
|
96
|
+
attr_writer :html_output_file
|
97
|
+
|
98
|
+
def html_output_file
|
99
|
+
@html_output_file || "#{self.report_dir}/jdepend.html"
|
100
|
+
end
|
101
|
+
|
102
|
+
attr_writer :style_file
|
103
|
+
|
104
|
+
def style_file
|
105
|
+
@style_file || "#{self.config_directory}/jdepend.xsl"
|
106
|
+
end
|
107
|
+
|
108
|
+
def target_paths
|
109
|
+
@target_paths ||= [self.project.compile.target, self.project.test.compile.target]
|
110
|
+
end
|
111
|
+
|
112
|
+
def to_options
|
113
|
+
{
|
114
|
+
:fail_on_error => project.jdepend.fail_on_error?,
|
115
|
+
# Set user home so that jdepend.properties will be loaded from there if present
|
116
|
+
:properties => { 'user.home' => project.jdepend.config_directory }
|
117
|
+
}
|
118
|
+
end
|
119
|
+
|
120
|
+
protected
|
121
|
+
|
122
|
+
def initialize(project)
|
123
|
+
@project = project
|
124
|
+
end
|
125
|
+
|
126
|
+
attr_reader :project
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
module ProjectExtension
|
131
|
+
include Extension
|
132
|
+
|
133
|
+
def jdepend
|
134
|
+
@jdepend ||= Buildr::JDepend::Config.new(project)
|
135
|
+
end
|
136
|
+
|
137
|
+
after_define do |project|
|
138
|
+
if project.jdepend.enabled?
|
139
|
+
desc "Generate JDepend xml report."
|
140
|
+
project.task("jdepend:xml") do
|
141
|
+
puts "JDepend: Analyzing source code..."
|
142
|
+
mkdir_p File.dirname(project.jdepend.xml_output_file)
|
143
|
+
Buildr::JDepend.jdepend(project.jdepend.xml_output_file,
|
144
|
+
project.jdepend.target_paths.flatten.compact,
|
145
|
+
project.jdepend.to_options)
|
146
|
+
end
|
147
|
+
|
148
|
+
desc "Run JDepend with Swing UI."
|
149
|
+
project.task("jdepend:swing") do
|
150
|
+
puts "JDepend: Analyzing source code..."
|
151
|
+
Buildr::JDepend.jdepend(nil,
|
152
|
+
project.jdepend.target_paths.flatten.compact,
|
153
|
+
project.jdepend.to_options)
|
154
|
+
end
|
155
|
+
|
156
|
+
if project.jdepend.html_enabled?
|
157
|
+
xml_task = project.task("jdepend:xml")
|
158
|
+
desc "Generate JDepend html report."
|
159
|
+
project.task("jdepend:html" => xml_task) do
|
160
|
+
puts "JDepend: Generating report"
|
161
|
+
mkdir_p File.dirname(project.jdepend.html_output_file)
|
162
|
+
Buildr.ant "jdepend" do |ant|
|
163
|
+
ant.xslt :in => project.jdepend.xml_output_file,
|
164
|
+
:out => project.jdepend.html_output_file,
|
165
|
+
:style => project.jdepend.style_file
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
class Buildr::Project
|
177
|
+
include Buildr::JDepend::ProjectExtension
|
178
|
+
end
|