realityforge-buildr 1.5.9

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.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +5 -0
  3. data/LICENSE +176 -0
  4. data/NOTICE +26 -0
  5. data/README.md +3 -0
  6. data/Rakefile +50 -0
  7. data/addon/buildr/checkstyle-report.xsl +104 -0
  8. data/addon/buildr/checkstyle.rb +254 -0
  9. data/addon/buildr/git_auto_version.rb +36 -0
  10. data/addon/buildr/gpg.rb +90 -0
  11. data/addon/buildr/gwt.rb +413 -0
  12. data/addon/buildr/jacoco.rb +161 -0
  13. data/addon/buildr/pmd.rb +185 -0
  14. data/addon/buildr/single_intermediate_layout.rb +71 -0
  15. data/addon/buildr/spotbugs.rb +265 -0
  16. data/addon/buildr/top_level_generate_dir.rb +37 -0
  17. data/addon/buildr/wsgen.rb +192 -0
  18. data/bin/buildr +20 -0
  19. data/buildr.gemspec +61 -0
  20. data/lib/buildr.rb +86 -0
  21. data/lib/buildr/core/application.rb +705 -0
  22. data/lib/buildr/core/assets.rb +96 -0
  23. data/lib/buildr/core/build.rb +587 -0
  24. data/lib/buildr/core/common.rb +167 -0
  25. data/lib/buildr/core/compile.rb +599 -0
  26. data/lib/buildr/core/console.rb +124 -0
  27. data/lib/buildr/core/doc.rb +275 -0
  28. data/lib/buildr/core/environment.rb +128 -0
  29. data/lib/buildr/core/filter.rb +405 -0
  30. data/lib/buildr/core/help.rb +114 -0
  31. data/lib/buildr/core/progressbar.rb +161 -0
  32. data/lib/buildr/core/project.rb +994 -0
  33. data/lib/buildr/core/test.rb +776 -0
  34. data/lib/buildr/core/transports.rb +456 -0
  35. data/lib/buildr/core/util.rb +77 -0
  36. data/lib/buildr/ide/idea.rb +1664 -0
  37. data/lib/buildr/java/commands.rb +230 -0
  38. data/lib/buildr/java/compiler.rb +85 -0
  39. data/lib/buildr/java/custom_pom.rb +300 -0
  40. data/lib/buildr/java/doc.rb +62 -0
  41. data/lib/buildr/java/packaging.rb +393 -0
  42. data/lib/buildr/java/pom.rb +191 -0
  43. data/lib/buildr/java/test_result.rb +54 -0
  44. data/lib/buildr/java/tests.rb +111 -0
  45. data/lib/buildr/packaging/archive.rb +586 -0
  46. data/lib/buildr/packaging/artifact.rb +1113 -0
  47. data/lib/buildr/packaging/artifact_namespace.rb +1010 -0
  48. data/lib/buildr/packaging/artifact_search.rb +138 -0
  49. data/lib/buildr/packaging/package.rb +237 -0
  50. data/lib/buildr/packaging/version_requirement.rb +189 -0
  51. data/lib/buildr/packaging/zip.rb +189 -0
  52. data/lib/buildr/packaging/ziptask.rb +387 -0
  53. data/lib/buildr/version.rb +18 -0
  54. data/rakelib/release.rake +99 -0
  55. data/spec/addon/checkstyle_spec.rb +58 -0
  56. data/spec/core/application_spec.rb +576 -0
  57. data/spec/core/build_spec.rb +922 -0
  58. data/spec/core/common_spec.rb +670 -0
  59. data/spec/core/compile_spec.rb +656 -0
  60. data/spec/core/console_spec.rb +65 -0
  61. data/spec/core/doc_spec.rb +194 -0
  62. data/spec/core/extension_spec.rb +200 -0
  63. data/spec/core/project_spec.rb +736 -0
  64. data/spec/core/test_spec.rb +1131 -0
  65. data/spec/core/transport_spec.rb +452 -0
  66. data/spec/core/util_spec.rb +154 -0
  67. data/spec/ide/idea_spec.rb +1952 -0
  68. data/spec/java/commands_spec.rb +79 -0
  69. data/spec/java/compiler_spec.rb +274 -0
  70. data/spec/java/custom_pom_spec.rb +165 -0
  71. data/spec/java/doc_spec.rb +55 -0
  72. data/spec/java/packaging_spec.rb +786 -0
  73. data/spec/java/pom_spec.rb +162 -0
  74. data/spec/java/test_coverage_helper.rb +257 -0
  75. data/spec/java/tests_spec.rb +224 -0
  76. data/spec/packaging/archive_spec.rb +686 -0
  77. data/spec/packaging/artifact_namespace_spec.rb +757 -0
  78. data/spec/packaging/artifact_spec.rb +1351 -0
  79. data/spec/packaging/packaging_helper.rb +63 -0
  80. data/spec/packaging/packaging_spec.rb +690 -0
  81. data/spec/sandbox.rb +166 -0
  82. data/spec/spec_helpers.rb +420 -0
  83. data/spec/version_requirement_spec.rb +145 -0
  84. data/spec/xpath_matchers.rb +123 -0
  85. metadata +295 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8aead139867720099e785867e129cdbd0ac5d7755c9aecaa82cad4ba79e8b703
4
+ data.tar.gz: e5b61d9c94ec8ca7cda8ca3583cf99223b9e47226a2a8c7e8bf4620521ee7eb4
5
+ SHA512:
6
+ metadata.gz: d6f7cbf839087fd897e8cea08b42697a1cf5109eba3a77223c70db7e9a124f83e98c2627d411f5b8effad5e691cf2dfffedfc01ae2bf886e5d6d781eb688a49e
7
+ data.tar.gz: c23a3d5b5c4f8bc1996395405d83d059244cd9ed71b97a9fbc653eb05a42b7884e186c936017f561c5fd8b065b3bcb0ed0e7795f67410d6f3d048d0e482c934e
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Change Log
2
+
3
+ ### Unreleased
4
+
5
+ * First release after extraction from Apache Buildr.
data/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
data/NOTICE ADDED
@@ -0,0 +1,26 @@
1
+ Apache Buildr
2
+ Copyright 2007-2016 The Apache Software Foundation
3
+
4
+ This product includes software developed at
5
+ The Apache Software Foundation (http://www.apache.org/).
6
+
7
+
8
+ COPYRIGHT NOTICES
9
+ -----------------
10
+ Copyright 2007 Intalio
11
+
12
+ This product includes software developed by Intalio
13
+ http://www.intalio.com
14
+
15
+
16
+ MATERIALS IN DOCUMENTATION
17
+ --------------------------
18
+ The following materials are incorporated into the documentation
19
+ of this software.
20
+
21
+ * DejaVu - http://dejavu.sourceforge.net
22
+ Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved.
23
+ Bitstream Vera is a trademark of Bitstream, Inc.
24
+
25
+ * ColorCons - http://www.mouserunner.com/
26
+ Copyright (c) 2006 Ken Saunders
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Build
2
+
3
+ This is a fork of [Buildr](http://buildr.apache.org/) to modernize and eliminate unused parts of the tool.
data/Rakefile ADDED
@@ -0,0 +1,50 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+ require 'psych'
17
+ require 'rubygems/package_task'
18
+ require 'rspec/core/rake_task'
19
+
20
+ # We need JAVA_HOME for most things (setup, spec, etc).
21
+ unless ENV['JAVA_HOME']
22
+ if RUBY_PLATFORM[/darwin/]
23
+ ENV['JAVA_HOME'] = '/System/Library/Frameworks/JavaVM.framework/Home'
24
+ else
25
+ fail "Please set JAVA_HOME first (set JAVA_HOME=... or env JAVA_HOME=... rake ...)"
26
+ end
27
+ end
28
+
29
+ desc 'Clean up all temporary directories used for running tests, creating documentation, packaging, etc.'
30
+ task :clobber do
31
+ rm_f 'failed'
32
+ rm_rf '_reports'
33
+ rm_rf '_target'
34
+ rm_rf 'pkg'
35
+ end
36
+
37
+ Gem::PackageTask.new(Gem::Specification.load('buildr.gemspec')) do
38
+ # Empty block required to actually define package task
39
+ end
40
+
41
+ directory '_reports'
42
+
43
+ desc 'Run all specs'
44
+ RSpec::Core::RakeTask.new :spec => ['_reports'] do |task|
45
+ task.rspec_path = 'bundle exec rspec'
46
+ task.rspec_opts = %w{--format html --out _reports/specs.html --backtrace}
47
+ end
48
+
49
+ desc 'Run all specs with CI reporter'
50
+ task 'ci' => %w(clobber spec)
@@ -0,0 +1,104 @@
1
+ <?xml version="1.0"?>
2
+
3
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4
+
5
+ <!--
6
+ Licensed to the Apache Software Foundation (ASF) under one or more
7
+ contributor license agreements. See the NOTICE file distributed with
8
+ this work for additional information regarding copyright ownership.
9
+ The ASF licenses this file to You under the Apache License, Version 2.0
10
+ (the "License"); you may not use this file except in compliance with
11
+ the License. You may obtain a copy of the License at
12
+
13
+ http://www.apache.org/licenses/LICENSE-2.0
14
+
15
+ Unless required by applicable law or agreed to in writing, software
16
+ distributed under the License is distributed on an "AS IS" BASIS,
17
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ See the License for the specific language governing permissions and
19
+ limitations under the License.
20
+ -->
21
+
22
+ <xsl:template match="/">
23
+ <html>
24
+ <head>
25
+ <title>Checkstyle Violations</title>
26
+ </head>
27
+ <body bgcolor="#FFFFEF">
28
+ <p>
29
+ <b>Coding Style Check Results</b>
30
+ </p>
31
+ <table border="1" cellspacing="0" cellpadding="2">
32
+ <tr bgcolor="#CC9966">
33
+ <th colspan="2">
34
+ <b>Summary</b>
35
+ </th>
36
+ </tr>
37
+ <tr bgcolor="#CCF3D0">
38
+ <td>Total files checked</td>
39
+ <td>
40
+ <xsl:number level="any" value="count(descendant::file)"/>
41
+ </td>
42
+ </tr>
43
+ <tr bgcolor="#F3F3E1">
44
+ <td>Files with errors</td>
45
+ <td>
46
+ <xsl:number level="any" value="count(descendant::file[error])"/>
47
+ </td>
48
+ </tr>
49
+ <tr bgcolor="#CCF3D0">
50
+ <td>Total errors</td>
51
+ <td>
52
+ <xsl:number level="any" value="count(descendant::error)"/>
53
+ </td>
54
+ </tr>
55
+ <tr bgcolor="#F3F3E1">
56
+ <td>Errors per file</td>
57
+ <td>
58
+ <xsl:number level="any" value="count(descendant::error) div count(descendant::file)"/>
59
+ </td>
60
+ </tr>
61
+ </table>
62
+ <hr align="left" width="95%" size="1"/>
63
+ <p>The following are violations of the Checkstyle Rules:</p>
64
+ <p/>
65
+ <xsl:apply-templates/>
66
+ </body>
67
+ </html>
68
+ </xsl:template>
69
+
70
+ <xsl:template match="file[error]">
71
+ <table bgcolor="#AFFFFF" width="95%" border="1" cellspacing="0" cellpadding="2">
72
+ <tr>
73
+ <th>File:</th>
74
+ <td>
75
+ <xsl:value-of select="@name"/>
76
+ </td>
77
+ </tr>
78
+ </table>
79
+ <table bgcolor="#DFFFFF" width="95%" border="1" cellspacing="0" cellpadding="2">
80
+ <tr>
81
+ <th>Line Number</th>
82
+ <th>Error Message</th>
83
+ <th>Check</th>
84
+ </tr>
85
+ <xsl:apply-templates select="error"/>
86
+ </table>
87
+ <p/>
88
+ </xsl:template>
89
+
90
+ <xsl:template match="error">
91
+ <tr>
92
+ <td>
93
+ <xsl:value-of select="@line"/>
94
+ </td>
95
+ <td>
96
+ <xsl:value-of select="@message"/>
97
+ </td>
98
+ <td>
99
+ <xsl:value-of select="@source"/>
100
+ </td>
101
+ </tr>
102
+ </xsl:template>
103
+
104
+ </xsl:stylesheet>
@@ -0,0 +1,254 @@
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>checkstyle:html</code> and <code>checkstyle:xml</code> tasks.
18
+ # Require explicitly using <code>require "buildr/checkstyle"</code>.
19
+ module Checkstyle
20
+
21
+ class << self
22
+
23
+ # The specs for requirements
24
+ def dependencies
25
+ version = '8.40'
26
+ spec = "com.puppycrawl.tools:checkstyle-all:jar:#{version}"
27
+ Buildr.download(Buildr.artifact(spec) => "https://github.com/checkstyle/checkstyle/releases/download/checkstyle-#{version}/checkstyle-#{version}-all.jar")
28
+ [spec]
29
+ end
30
+
31
+ def checkstyle(configuration_file, format, output_file, source_paths, options = {})
32
+ dependencies = self.dependencies + (options[:dependencies] || [])
33
+ cp = Buildr.artifacts(dependencies).each { |a| a.invoke if a.respond_to?(:invoke) }.map(&:to_s)
34
+
35
+ args = []
36
+ if options[:properties_file]
37
+ args << '-p'
38
+ args << options[:properties_file]
39
+ end
40
+ args << '-c'
41
+ args << configuration_file
42
+ args << '-f'
43
+ args << format
44
+ args << '-o'
45
+ args << output_file
46
+ args += source_paths.select { |p| File.exist?(p) }
47
+
48
+ begin
49
+ Java::Commands.java 'com.puppycrawl.tools.checkstyle.Main', *(args + [{:classpath => cp, :properties => options[:properties], :java_args => options[:java_args]}])
50
+ rescue Exception => e
51
+ raise e if options[:fail_on_error]
52
+ end
53
+ end
54
+ end
55
+
56
+ class Config
57
+
58
+ attr_writer :enabled
59
+
60
+ def enabled?
61
+ @enabled.nil? ? (File.exist?(self.configuration_file) || !self.configuration_artifact.nil?) : !!@enabled
62
+ end
63
+
64
+ def html_enabled?
65
+ File.exist?(self.style_file)
66
+ end
67
+
68
+ attr_writer :config_directory
69
+
70
+ def config_directory
71
+ @config_directory || project._(:source, :main, :etc, :checkstyle)
72
+ end
73
+
74
+ attr_writer :report_dir
75
+
76
+ def report_dir
77
+ @report_dir || project._(:reports, :checkstyle)
78
+ end
79
+
80
+ attr_writer :configuration_file
81
+
82
+ def configuration_file=(configuration_file)
83
+ raise 'Configuration artifact already specified' if @configuration_artifact
84
+ @configuration_file = configuration_file
85
+ end
86
+
87
+ def configuration_file
88
+ if @configuration_file
89
+ return @configuration_file
90
+ elsif @configuration_artifact.nil?
91
+ "#{self.config_directory}/checks.xml"
92
+ else
93
+ a = Buildr.artifact(@configuration_artifact)
94
+ a.invoke
95
+ a.to_s
96
+ end
97
+ end
98
+
99
+ def configuration_artifact=(configuration_artifact)
100
+ raise 'Configuration file already specified' if @configuration_file
101
+ @configuration_artifact = configuration_artifact
102
+ end
103
+
104
+ def configuration_artifact
105
+ @configuration_artifact
106
+ end
107
+
108
+ attr_writer :fail_on_error
109
+
110
+ def fail_on_error?
111
+ @fail_on_error.nil? ? false : @fail_on_error
112
+ end
113
+
114
+ attr_writer :format
115
+
116
+ def format
117
+ @format || 'xml'
118
+ end
119
+
120
+ attr_writer :xml_output_file
121
+
122
+ def xml_output_file
123
+ @xml_output_file || "#{self.report_dir}/checkstyle.xml"
124
+ end
125
+
126
+ attr_writer :html_output_file
127
+
128
+ def html_output_file
129
+ @html_output_file || "#{self.report_dir}/checkstyle.html"
130
+ end
131
+
132
+ attr_writer :style_file
133
+
134
+ def style_file
135
+ unless @style_file
136
+ project_xsl = "#{self.config_directory}/checkstyle-report.xsl"
137
+ if File.exist?(project_xsl)
138
+ @style_file = project_xsl
139
+ else
140
+ @style_file = "#{File.dirname(__FILE__)}/checkstyle-report.xsl"
141
+ end
142
+ end
143
+ @style_file
144
+ end
145
+
146
+ attr_writer :suppressions_file
147
+
148
+ def suppressions_file
149
+ @suppressions_file || "#{self.config_directory}/suppressions.xml"
150
+ end
151
+
152
+ attr_writer :import_control_file
153
+
154
+ def import_control_file
155
+ @import_control_file || "#{self.config_directory}/import-control.xml"
156
+ end
157
+
158
+ def properties
159
+ unless @properties
160
+ @properties = {:basedir => self.project.base_dir}
161
+ @properties['checkstyle.suppressions.file'] = self.suppressions_file if File.exist?(self.suppressions_file)
162
+ @properties['checkstyle.import-control.file'] = self.import_control_file if File.exist?(self.import_control_file)
163
+ end
164
+ @properties
165
+ end
166
+
167
+ def source_paths
168
+ @source_paths ||= [self.project.compile.sources, self.project.test.compile.sources]
169
+ end
170
+
171
+ def extra_dependencies
172
+ @extra_dependencies ||= []
173
+ end
174
+
175
+ # An array of additional java_args
176
+ attr_writer :java_args
177
+
178
+ def java_args
179
+ @java_args ||= []
180
+ end
181
+
182
+ # An array of additional projects to scan for main and test sources
183
+ attr_writer :additional_project_names
184
+
185
+ def additional_project_names
186
+ @additional_project_names ||= []
187
+ end
188
+
189
+ def complete_source_paths
190
+ paths = self.source_paths.dup
191
+
192
+ self.additional_project_names.each do |project_name|
193
+ p = self.project.project(project_name)
194
+ paths << [p.compile.sources, p.test.compile.sources].flatten.compact
195
+ end
196
+
197
+ paths.flatten.compact
198
+ end
199
+
200
+ protected
201
+
202
+ def initialize(project)
203
+ @project = project
204
+ end
205
+
206
+ attr_reader :project
207
+
208
+ end
209
+
210
+ module ProjectExtension
211
+ include Extension
212
+
213
+ def checkstyle
214
+ @checkstyle ||= Buildr::Checkstyle::Config.new(project)
215
+ end
216
+
217
+ after_define do |project|
218
+ if project.checkstyle.enabled?
219
+ desc 'Generate checkstyle xml report.'
220
+ project.task('checkstyle:xml') do
221
+ puts 'Checkstyle: Analyzing source code...'
222
+ mkdir_p File.dirname(project.checkstyle.xml_output_file)
223
+ source_paths = project.checkstyle.complete_source_paths.select{|p| !p.start_with?(project._(:generated).to_s)}
224
+ source_paths = source_paths.collect{|p|::Buildr::Util.relative_path(File.expand_path(p.to_s), project.base_dir)}
225
+ Buildr::Checkstyle.checkstyle(project.checkstyle.configuration_file,
226
+ project.checkstyle.format,
227
+ project.checkstyle.xml_output_file,
228
+ source_paths,
229
+ :properties => project.checkstyle.properties,
230
+ :java_args => project.checkstyle.java_args,
231
+ :fail_on_error => project.checkstyle.fail_on_error?,
232
+ :dependencies => project.checkstyle.extra_dependencies.dup.flatten.compact)
233
+ end
234
+
235
+ if project.checkstyle.html_enabled?
236
+ xml_task = project.task('checkstyle:xml')
237
+ desc 'Generate checkstyle html report.'
238
+ project.task('checkstyle:html' => xml_task) do
239
+ puts 'Checkstyle: Generating report'
240
+ mkdir_p File.dirname(project.checkstyle.html_output_file)
241
+ args = ['-IN', project.checkstyle.xml_output_file, '-XSL', project.checkstyle.style_file, '-OUT', project.checkstyle.html_output_file]
242
+ classpath = Buildr.artifacts(%w(xalan:xalan:jar:2.7.2 xalan:serializer:jar:2.7.2 xml-apis:xml-apis:jar:1.3.04))
243
+ Java::Commands.java 'org.apache.xalan.xslt.Process', *(args + [{ :classpath => classpath }])
244
+ end
245
+ end
246
+ end
247
+ end
248
+ end
249
+ end
250
+ end
251
+
252
+ class Buildr::Project
253
+ include Buildr::Checkstyle::ProjectExtension
254
+ end