buildr 1.3.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. data/CHANGELOG +780 -0
  2. data/DISCLAIMER +7 -0
  3. data/KEYS +151 -0
  4. data/LICENSE +176 -0
  5. data/NOTICE +31 -0
  6. data/README +173 -0
  7. data/Rakefile +63 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/cobertura.rb +232 -0
  10. data/addon/buildr/hibernate.rb +142 -0
  11. data/addon/buildr/javacc.rb +85 -0
  12. data/addon/buildr/jdepend.rb +60 -0
  13. data/addon/buildr/jetty.rb +248 -0
  14. data/addon/buildr/nailgun.rb +892 -0
  15. data/addon/buildr/openjpa.rb +90 -0
  16. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  17. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  18. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  19. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  20. data/addon/buildr/xmlbeans.rb +93 -0
  21. data/bin/buildr +21 -0
  22. data/buildr.gemspec +50 -0
  23. data/doc/css/default.css +225 -0
  24. data/doc/css/print.css +95 -0
  25. data/doc/css/syntax.css +43 -0
  26. data/doc/images/apache-incubator-logo.png +0 -0
  27. data/doc/images/buildr-hires.png +0 -0
  28. data/doc/images/buildr.png +0 -0
  29. data/doc/images/note.png +0 -0
  30. data/doc/images/tip.png +0 -0
  31. data/doc/images/zbuildr.tif +0 -0
  32. data/doc/pages/artifacts.textile +317 -0
  33. data/doc/pages/building.textile +501 -0
  34. data/doc/pages/contributing.textile +178 -0
  35. data/doc/pages/download.textile +25 -0
  36. data/doc/pages/extending.textile +229 -0
  37. data/doc/pages/getting_started.textile +337 -0
  38. data/doc/pages/index.textile +63 -0
  39. data/doc/pages/mailing_lists.textile +17 -0
  40. data/doc/pages/more_stuff.textile +367 -0
  41. data/doc/pages/packaging.textile +592 -0
  42. data/doc/pages/projects.textile +449 -0
  43. data/doc/pages/recipes.textile +127 -0
  44. data/doc/pages/settings_profiles.textile +339 -0
  45. data/doc/pages/testing.textile +475 -0
  46. data/doc/pages/troubleshooting.textile +121 -0
  47. data/doc/pages/whats_new.textile +389 -0
  48. data/doc/print.haml +52 -0
  49. data/doc/print.toc.yaml +28 -0
  50. data/doc/scripts/buildr-git.rb +411 -0
  51. data/doc/scripts/install-jruby.sh +44 -0
  52. data/doc/scripts/install-linux.sh +64 -0
  53. data/doc/scripts/install-osx.sh +52 -0
  54. data/doc/site.haml +55 -0
  55. data/doc/site.toc.yaml +44 -0
  56. data/lib/buildr.rb +47 -0
  57. data/lib/buildr/core.rb +27 -0
  58. data/lib/buildr/core/application.rb +373 -0
  59. data/lib/buildr/core/application_cli.rb +134 -0
  60. data/lib/buildr/core/build.rb +262 -0
  61. data/lib/buildr/core/checks.rb +382 -0
  62. data/lib/buildr/core/common.rb +155 -0
  63. data/lib/buildr/core/compile.rb +594 -0
  64. data/lib/buildr/core/environment.rb +120 -0
  65. data/lib/buildr/core/filter.rb +258 -0
  66. data/lib/buildr/core/generate.rb +195 -0
  67. data/lib/buildr/core/help.rb +118 -0
  68. data/lib/buildr/core/progressbar.rb +156 -0
  69. data/lib/buildr/core/project.rb +890 -0
  70. data/lib/buildr/core/test.rb +690 -0
  71. data/lib/buildr/core/transports.rb +486 -0
  72. data/lib/buildr/core/util.rb +235 -0
  73. data/lib/buildr/ide.rb +19 -0
  74. data/lib/buildr/ide/eclipse.rb +181 -0
  75. data/lib/buildr/ide/idea.ipr.template +300 -0
  76. data/lib/buildr/ide/idea.rb +194 -0
  77. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  78. data/lib/buildr/ide/idea7x.rb +210 -0
  79. data/lib/buildr/java.rb +26 -0
  80. data/lib/buildr/java/ant.rb +71 -0
  81. data/lib/buildr/java/bdd_frameworks.rb +267 -0
  82. data/lib/buildr/java/commands.rb +210 -0
  83. data/lib/buildr/java/compilers.rb +432 -0
  84. data/lib/buildr/java/deprecated.rb +141 -0
  85. data/lib/buildr/java/groovyc.rb +137 -0
  86. data/lib/buildr/java/jruby.rb +99 -0
  87. data/lib/buildr/java/org/apache/buildr/BuildrNail$Main.class +0 -0
  88. data/lib/buildr/java/org/apache/buildr/BuildrNail.class +0 -0
  89. data/lib/buildr/java/org/apache/buildr/BuildrNail.java +41 -0
  90. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  91. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +116 -0
  92. data/lib/buildr/java/packaging.rb +706 -0
  93. data/lib/buildr/java/pom.rb +178 -0
  94. data/lib/buildr/java/rjb.rb +142 -0
  95. data/lib/buildr/java/test_frameworks.rb +290 -0
  96. data/lib/buildr/java/version_requirement.rb +172 -0
  97. data/lib/buildr/packaging.rb +21 -0
  98. data/lib/buildr/packaging/artifact.rb +729 -0
  99. data/lib/buildr/packaging/artifact_namespace.rb +957 -0
  100. data/lib/buildr/packaging/artifact_search.rb +140 -0
  101. data/lib/buildr/packaging/gems.rb +102 -0
  102. data/lib/buildr/packaging/package.rb +233 -0
  103. data/lib/buildr/packaging/tar.rb +104 -0
  104. data/lib/buildr/packaging/zip.rb +719 -0
  105. data/rakelib/apache.rake +126 -0
  106. data/rakelib/changelog.rake +56 -0
  107. data/rakelib/doc.rake +103 -0
  108. data/rakelib/package.rake +44 -0
  109. data/rakelib/release.rake +53 -0
  110. data/rakelib/rspec.rake +81 -0
  111. data/rakelib/rubyforge.rake +45 -0
  112. data/rakelib/scm.rake +49 -0
  113. data/rakelib/setup.rake +59 -0
  114. data/rakelib/stage.rake +45 -0
  115. data/spec/application_spec.rb +316 -0
  116. data/spec/archive_spec.rb +494 -0
  117. data/spec/artifact_namespace_spec.rb +635 -0
  118. data/spec/artifact_spec.rb +738 -0
  119. data/spec/build_spec.rb +193 -0
  120. data/spec/checks_spec.rb +537 -0
  121. data/spec/common_spec.rb +579 -0
  122. data/spec/compile_spec.rb +561 -0
  123. data/spec/groovy_compilers_spec.rb +239 -0
  124. data/spec/java_bdd_frameworks_spec.rb +238 -0
  125. data/spec/java_compilers_spec.rb +446 -0
  126. data/spec/java_packaging_spec.rb +1042 -0
  127. data/spec/java_test_frameworks_spec.rb +414 -0
  128. data/spec/packaging_helper.rb +63 -0
  129. data/spec/packaging_spec.rb +589 -0
  130. data/spec/project_spec.rb +739 -0
  131. data/spec/sandbox.rb +116 -0
  132. data/spec/scala_compilers_spec.rb +239 -0
  133. data/spec/spec.opts +6 -0
  134. data/spec/spec_helpers.rb +283 -0
  135. data/spec/test_spec.rb +871 -0
  136. data/spec/transport_spec.rb +300 -0
  137. data/spec/version_requirement_spec.rb +115 -0
  138. metadata +324 -0
@@ -0,0 +1,44 @@
1
+ #!/bin/sh
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with this
4
+ # work for additional information regarding copyright ownership. The ASF
5
+ # licenses this file to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ # License for the specific language governing permissions and limitations under
15
+ # the License.
16
+ if [ -z `which jruby` ] ; then
17
+ version=1.1
18
+ target=/opt/jruby
19
+ echo "Installing JRuby ${version} in ${target}"
20
+ sudo mkdir -p $(dirname ${target})
21
+ curl -OL http://dist.codehaus.org/jruby/jruby-bin-${version}.tar.gz
22
+ tar -xz < jruby-bin-${version}.tar.gz
23
+ sudo mv jruby-${version} ${target}
24
+ rm jruby-bin-${version}.tar.gz
25
+ export PATH=$PATH:${target}
26
+ if [ -e ~/.bash_profile ] ; then
27
+ echo "export PATH=${target}/bin:\$PATH" >> ~/.bash_profile
28
+ elif [ -e ~/.profile ] ; then
29
+ echo "export PATH=${target}/bin:\$PATH" >> ~/.profile
30
+ else
31
+ echo "You need to add ${target}/bin to the PATH"
32
+ fi
33
+ fi
34
+
35
+ if [ `which buildr` ] ; then
36
+ echo "Updating to the latest version of Buildr"
37
+ sudo jruby -S gem update buildr
38
+ else
39
+ echo "Installing the latest version of Buildr"
40
+ sudo jruby -S gem install buildr
41
+ fi
42
+ echo
43
+
44
+ jruby -S buildr --version
@@ -0,0 +1,64 @@
1
+ #!/bin/sh
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with this
4
+ # work for additional information regarding copyright ownership. The ASF
5
+ # licenses this file to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ # License for the specific language governing permissions and limitations under
15
+ # the License.
16
+ if [ -z `which ruby` ] ; then
17
+ echo "You do not have Ruby 1.8.6 ..."
18
+ # yum comes first since some people have apt-get installed in addition to yum.
19
+ if [ `which yum` ] ; then
20
+ echo "Installing Ruby using yum"
21
+ sudo yum install ruby rubygems ruby-devel gcc
22
+ elif [ `which apt-get` ] ; then
23
+ echo "Installing Ruby using apt-get"
24
+ # ruby package does not contain RDoc, IRB, etc; ruby-full is a meta-package.
25
+ # build-essentials not installed by default in Ubuntu, required for C extensions.
26
+ sudo apt-get install ruby-full ruby1.8-dev libopenssl-ruby build-essential
27
+ # RubyGems broken on Ubunutu, installing directly from source.
28
+ echo "Installing RubyGems from RubyForge"
29
+ curl -OL http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz
30
+ tar xzf rubygems-1.0.1.tgz
31
+ cd rubygems-1.0.1
32
+ sudo ruby setup.rb
33
+ cd ..
34
+ rm -rf rubygems-1.0.1
35
+ # ruby is same as ruby1.8, we need gem that is same as gem1.8
36
+ sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
37
+ else
38
+ echo "Can only install Ruby 1.8.6 using apt-get or yum, and can't find either one"
39
+ exit 1
40
+ fi
41
+ echo
42
+ fi
43
+
44
+ if [ -z $JAVA_HOME ] ; then
45
+ echo "Please set JAVA_HOME before proceeding"
46
+ exit 1
47
+ fi
48
+
49
+ if [ $(gem --version) \< '1.0.1' ] ; then
50
+ echo "Upgrading to RubyGems 1.0.1"
51
+ sudo gem update --system
52
+ echo
53
+ fi
54
+
55
+ if [ `which buildr` ] ; then
56
+ echo "Updating to the latest version of Buildr"
57
+ sudo env JAVA_HOME=$JAVA_HOME gem update buildr
58
+ else
59
+ echo "Installing the latest version of Buildr"
60
+ sudo env JAVA_HOME=$JAVA_HOME gem install buildr
61
+ fi
62
+ echo
63
+
64
+ buildr --version
@@ -0,0 +1,52 @@
1
+ #!/bin/sh
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with this
4
+ # work for additional information regarding copyright ownership. The ASF
5
+ # licenses this file to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ # License for the specific language governing permissions and limitations under
15
+ # the License.
16
+ version=$(ruby --version)
17
+ if [ ${version:5:5} \< '1.8.6' ] ; then
18
+ echo "You do not have Ruby 1.8.6 or later, attempting to install a newer version."
19
+ if [ `which port` ] ; then
20
+ echo "Installing Ruby using MacPorts"
21
+ sudo port install ruby rb-rubygems
22
+ elif [ `which fink` ] ; then
23
+ echo "Installing Ruby using Fink"
24
+ sudo fink install ruby ruby18-dev rubygems-rb18
25
+ else
26
+ echo "Can only upgrade to Ruby 1.8.6 using either MacPorts or Fink, and can't find either one"
27
+ exit 1
28
+ fi
29
+ echo
30
+ fi
31
+
32
+ if [ -z $JAVA_HOME ] ; then
33
+ echo "Setting JAVA_HOME"
34
+ export JAVA_HOME=/Library/Java/Home
35
+ fi
36
+
37
+ if [ $(gem --version) \< '1.0.1' ] ; then
38
+ echo "Upgrading to RubyGems 1.0.1"
39
+ sudo gem update --system
40
+ echo
41
+ fi
42
+
43
+ if [ `which buildr` ] ; then
44
+ echo "Updating to the latest version of Buildr"
45
+ sudo env JAVA_HOME=$JAVA_HOME gem update buildr
46
+ else
47
+ echo "Installing the latest version of Buildr"
48
+ sudo env JAVA_HOME=$JAVA_HOME gem install buildr
49
+ fi
50
+ echo
51
+
52
+ buildr --version
@@ -0,0 +1,55 @@
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
+ !!! 1.1
17
+ %html
18
+ %head
19
+ %meta{ 'http-equiv'=>'Content-Type', :content=>'text/html;charset=UTF-8' }/
20
+ %title= "#{collection.title} &mdash; #{page.title}"
21
+ %style{ :type=>'text/css' }
22
+ @import 'css/default.css';
23
+ @import 'css/syntax.css';
24
+ %style{ :type=>'text/css', :media=>'print' }
25
+ @import 'css/print.css';
26
+ \#header { display: none }
27
+ %meta{ :name=>'subject', :content=>'Official Buildr documentation from the people in the know' }
28
+ %body
29
+ #wrap
30
+ #header
31
+ %a{ :href=>'http://incubator.apache.org/', :style=>'float:right' }
32
+ %img{ :src=>'images/apache-incubator-logo.png', :alt=>'Apache Incubator' }
33
+ %a{ :href=>'http://incubator.apache.org/buildr/' }
34
+ %img{ :src=>'images/buildr.png', :alt=>collection.title }
35
+ .tagline= ''
36
+ #pages
37
+ = collection.toc.to_html(:nested=>1, :class=>'toc')
38
+ %form{ :id=>'searchbox_003673095760649043902:ogcgrzu0l2y', :action=>'http://www.google.com/cse' }
39
+ %input{ :type=>'hidden', :name=>'cx', :value=>'003673095760649043902:ogcgrzu0l2y' }
40
+ %input{ :type=>'hidden', :name=>'cof', :value=>'FORID:0' }
41
+ %input{ :name=>'q', :type=>'text', :size=>'20' }
42
+ %input{ :type=>'submit', :name=>'sa', :value=>'Search' }
43
+ %img{ :src=>'http://www.google.com/coop/images/google_custom_search_smnar.gif', :alt=>'Google Custom Search' }
44
+
45
+ #content
46
+ %h1= page.title
47
+ = page.toc.to_html(:nested, :class=>'toc')
48
+ ~ page.content
49
+ #navigation
50
+ - if prev_page = collection.prev(page)
51
+ %a{ :href=>prev_page.path, :class=>'prev' }= '&laquo; ' + prev_page.title
52
+ - if next_page = collection.next(page)
53
+ %a{ :href=>next_page.path, :class=>'next' }= next_page.title + ' &raquo;'
54
+ #footer
55
+ Copyright &copy; 2007-2008 The Apache Software Foundation
@@ -0,0 +1,44 @@
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
+ - Main:
17
+ - Welcome: /
18
+ - Download and Installation: download.html
19
+ - Printable PDF: buildr.pdf
20
+ - New: whats_new.html
21
+ - Using Buildr:
22
+ - Getting Started: getting_started.html
23
+ - Projects: projects.html
24
+ - Building: building.html
25
+ - Artifcats: artifacts.html
26
+ - Packaging: packaging.html
27
+ - Testing: testing.html
28
+ - Settings/Profiles: settings_profiles.html
29
+ - More Stuff: more_stuff.html
30
+ - Extending: extending.html
31
+ - Recipes: recipes.html
32
+ - Reference:
33
+ - API: rdoc
34
+ - Rake: http://docs.rubyrake.org
35
+ - Antwrap: http://antwrap.rubyforge.org
36
+ - Troubleshooting: troubleshooting.html
37
+ - Getting Involved:
38
+ - Contributing: contributing.html
39
+ - Mailing Lists: mailing_lists.html
40
+ - Issues/Bugs: http://issues.apache.org/jira/browse/Buildr
41
+ - Project Status:
42
+ - License: license.html
43
+ - Change Log: changelog.html
44
+ - Specs: specs.html
@@ -0,0 +1,47 @@
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
+ $KCODE = 'utf8'
18
+ # in order to work around a bug in jruby (1.0.1 and trunk as of oct11, 2007)
19
+ # needle and net/ssh need to be loaded before -anything- else. please see
20
+ # http://jira.codehaus.org/browse/JRUBY-1188 for more info.
21
+ require 'needle'
22
+ require 'net/ssh'
23
+
24
+ require 'highline/import'
25
+ require 'builder' # A different kind of buildr, one we use to create XML.
26
+
27
+ module Buildr
28
+ VERSION = '1.3.0'.freeze # unless const_defined?(:VERSION)
29
+ end
30
+
31
+ require 'buildr/core'
32
+ require 'buildr/packaging'
33
+ require 'buildr/java'
34
+ require 'buildr/ide'
35
+
36
+ # Methods defined in Buildr are both instance methods (e.g. when included in Project)
37
+ # and class methods when invoked like Buildr.artifacts().
38
+ module Buildr ; extend self ; end
39
+ # The Buildfile object (self) has access to all the Buildr methods and constants.
40
+ class << self ; include Buildr ; end
41
+ class Object #:nodoc:
42
+ Buildr.constants.each { |c| const_set c, Buildr.const_get(c) unless const_defined?(c) }
43
+ end
44
+
45
+ # Prevent RSpec runner from running at_exit.
46
+ require 'spec'
47
+ Spec.run = true
@@ -0,0 +1,27 @@
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/common'
18
+ require 'buildr/core/application'
19
+ require 'buildr/core/project'
20
+ require 'buildr/core/environment'
21
+ require 'buildr/core/help'
22
+ require 'buildr/core/build'
23
+ require 'buildr/core/filter'
24
+ require 'buildr/core/compile'
25
+ require 'buildr/core/test'
26
+ require 'buildr/core/checks'
27
+ require 'buildr/core/generate'
@@ -0,0 +1,373 @@
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
+ # Portion of this file derived from Rake.
17
+ # Copyright (c) 2003, 2004 Jim Weirich
18
+ #
19
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
20
+ # of this software and associated documentation files (the "Software"), to deal
21
+ # in the Software without restriction, including without limitation the rights
22
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23
+ # copies of the Software, and to permit persons to whom the Software is
24
+ # furnished to do so, subject to the following conditions:
25
+ #
26
+ # The above copyright notice and this permission notice shall be included in
27
+ # all copies or substantial portions of the Software.
28
+ #
29
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
+ # SOFTWARE.
36
+
37
+
38
+ require 'benchmark'
39
+ require 'rake'
40
+ require 'rubygems/source_info_cache'
41
+ require 'buildr/core/application_cli'
42
+ require 'buildr/core/util'
43
+
44
+
45
+ # Gem::user_home is nice, but ENV['HOME'] lets you override from the environment.
46
+ ENV["HOME"] ||= File.expand_path(Gem::user_home)
47
+ ENV['BUILDR_ENV'] ||= 'development'
48
+
49
+ module Buildr
50
+
51
+ # Provide settings that come from three sources.
52
+ #
53
+ # User settings are placed in the .buildr/settings.yaml file located in the user's home directory.
54
+ # The should only be used for settings that are specific to the user and applied the same way
55
+ # across all builds. Example for user settings are preferred repositories, path to local repository,
56
+ # user/name password for uploading to remote repository.
57
+ #
58
+ # Build settings are placed in the build.yaml file located in the build directory. They help keep
59
+ # the buildfile and build.yaml file simple and readable, working to the advantages of each one.
60
+ # Example for build settings are gems, repositories and artifacts used by that build.
61
+ #
62
+ # Profile settings are placed in the profiles.yaml file located in the build directory. They provide
63
+ # settings that differ in each environment the build runs in. For example, URLs and database
64
+ # connections will be different when used in development, test and production environments.
65
+ # The settings for the current environment are obtained by calling #profile.
66
+ class Settings
67
+
68
+ def initialize(application) #:nodoc:
69
+ @application = application
70
+ @user = load_from('settings', @application.home_dir)
71
+ @build = load_from('build')
72
+ @profiles = load_from('profiles')
73
+ end
74
+
75
+ # User settings loaded from setting.yaml file in user's home directory.
76
+ attr_reader :user
77
+
78
+ # Build settings loaded from build.yaml file in build directory.
79
+ attr_reader :build
80
+
81
+ # Profiles loaded from profiles.yaml file in build directory.
82
+ attr_reader :profiles
83
+
84
+ # :call-seq:
85
+ # profile => hash
86
+ #
87
+ # Returns the profile for the current environment.
88
+ def profile
89
+ profiles[@application.environment] ||= {}
90
+ end
91
+
92
+ private
93
+
94
+ def load_from(base_name, dir = nil)
95
+ file_name = ['yaml', 'yml'].map { |ext| File.expand_path("#{base_name}.#{ext}", dir) }.find { |fn| File.exist?(fn) }
96
+ return {} unless file_name
97
+ yaml = YAML.load(File.read(file_name)) || {}
98
+ fail "Expecting #{file_name} to be a map (name: value)!" unless Hash === yaml
99
+ @application.build_files << file_name
100
+ yaml
101
+ end
102
+
103
+ end
104
+
105
+
106
+ class Application < Rake::Application #:nodoc:
107
+
108
+ DEFAULT_BUILDFILES = ['buildfile', 'Buildfile'] + DEFAULT_RAKEFILES
109
+
110
+ include CommandLineInterface
111
+
112
+ attr_reader :rakefiles, :requires
113
+ private :rakefiles, :requires
114
+
115
+ def initialize
116
+ super
117
+ @rakefiles = DEFAULT_BUILDFILES
118
+ @name = 'Buildr'
119
+ @requires = []
120
+ @top_level_tasks = []
121
+ parse_options
122
+ collect_tasks
123
+ top_level_tasks.unshift 'buildr:initialize'
124
+ @home_dir = File.expand_path('.buildr', ENV['HOME'])
125
+ mkpath @home_dir unless File.exist?(@home_dir)
126
+ @environment = ENV['BUILDR_ENV'] ||= 'development'
127
+ end
128
+
129
+ # Returns list of Gems associated with this buildfile, as listed in build.yaml.
130
+ # Each entry is of type Gem::Specification.
131
+ attr_reader :gems
132
+
133
+ # Buildr home directory, .buildr under user's home directory.
134
+ attr_reader :home_dir
135
+
136
+ # Copied from BUILD_ENV.
137
+ attr_reader :environment
138
+
139
+ # Returns the Settings associated with this build.
140
+ def settings
141
+ @settings ||= Settings.new(self)
142
+ end
143
+
144
+ # :call-seq:
145
+ # buildfile
146
+ def buildfile
147
+ rakefile
148
+ end
149
+
150
+ # :call-seq:
151
+ # build_files => files
152
+ #
153
+ # Returns a list of build files. These are files used by the build,
154
+ def build_files
155
+ [buildfile].compact + Array(@build_files)
156
+ end
157
+
158
+ # Returns Gem::Specification for every listed and installed Gem, Gem::Dependency
159
+ # for listed and uninstalled Gem, which is the installed before loading the buildfile.
160
+ def listed_gems #:nodoc:
161
+ Array(settings.build['gems']).map do |dep|
162
+ name, trail = dep.scan(/^\s*(\S*)\s*(.*)\s*$/).first
163
+ versions = trail.scan(/[=><~!]{0,2}\s*[\d\.]+/)
164
+ versions = ['>= 0'] if versions.empty?
165
+ dep = Gem::Dependency.new(name, versions)
166
+ Gem::SourceIndex.from_installed_gems.search(dep).last || dep
167
+ end
168
+ end
169
+ private :listed_gems
170
+
171
+ def run
172
+ times = Benchmark.measure do
173
+ standard_exception_handling do
174
+ find_buildfile
175
+ load_gems
176
+ load_buildfile
177
+ top_level
178
+ load_tasks
179
+ end
180
+ end
181
+ if verbose
182
+ real = []
183
+ real << ("%ih" % (times.real / 3600)) if times.real >= 3600
184
+ real << ("%im" % ((times.real / 60) % 60)) if times.real >= 60
185
+ real << ("%.3fs" % (times.real % 60))
186
+ puts "Completed in #{real.join}"
187
+ end
188
+ end
189
+
190
+ # Load/install all Gems specified in build.yaml file.
191
+ def load_gems #:nodoc:
192
+ missing_deps, installed = listed_gems.partition { |gem| gem.is_a?(Gem::Dependency) }
193
+ unless missing_deps.empty?
194
+ remote = missing_deps.map { |dep| Gem::SourceInfoCache.search(dep).last || dep }
195
+ not_found_deps, install = remote.partition { |gem| gem.is_a?(Gem::Dependency) }
196
+ fail Gem::LoadError, "Build requires the gems #{not_found_deps.join(', ')}, which cannot be found in local or remote repository." unless not_found_deps.empty?
197
+ uses = "This build requires the gems #{install.map(&:full_name).join(', ')}:"
198
+ fail Gem::LoadError, "#{uses} to install, run Buildr interactively." unless $stdout.isatty
199
+ unless agree("#{uses} do you want me to install them? [Y/n]", true)
200
+ fail Gem::LoadError, 'Cannot build without these gems.'
201
+ end
202
+ install.each do |spec|
203
+ say "Installing #{spec.full_name} ... " if verbose
204
+ Util.ruby 'install', spec.name, '-v', spec.version.to_s, :command => 'gem', :sudo => true, :verbose => false
205
+ Gem.source_index.load_gems_in Gem::SourceIndex.installed_spec_directories
206
+ end
207
+ installed += install
208
+ end
209
+
210
+ installed.each do |spec|
211
+ if gem(spec.name, spec.version.to_s)
212
+ # FileList[spec.require_paths.map { |path| File.expand_path("#{path}/*.rb", spec.full_gem_path) }].
213
+ # map { |path| File.basename(path) }.each { |file| require file }
214
+ # FileList[File.expand_path('tasks/*.rake', spec.full_gem_path)].each do |file|
215
+ # Buildr.application.add_import file
216
+ # end
217
+ end
218
+ end
219
+ @gems = installed
220
+ end
221
+
222
+ def find_buildfile
223
+ here = Dir.pwd
224
+ while ! have_rakefile
225
+ Dir.chdir('..')
226
+ if Dir.pwd == here || options.nosearch
227
+ error = "No Buildfile found (looking for: #{@rakefiles.join(', ')})"
228
+ if STDIN.isatty
229
+ chdir(original_dir) { task('generate').invoke }
230
+ exit 1
231
+ else
232
+ raise error
233
+ end
234
+ end
235
+ here = Dir.pwd
236
+ end
237
+ end
238
+
239
+ def load_buildfile
240
+ @requires.each { |name| require name }
241
+ puts "(in #{Dir.pwd}, #{environment})"
242
+ load File.expand_path(@rakefile) if @rakefile != ''
243
+ load_imports
244
+ end
245
+
246
+ # Loads buildr.rake files from users home directory and project directory.
247
+ # Loads custom tasks from .rake files in tasks directory.
248
+ def load_tasks #:nodoc:
249
+ @build_files = [ File.expand_path('buildr.rb', ENV['HOME']), 'buildr.rb' ].select { |file| File.exist?(file) }
250
+ @build_files += [ File.expand_path('buildr.rake', ENV['HOME']), File.expand_path('buildr.rake') ].
251
+ select { |file| File.exist?(file) }.each { |file| warn "Please use '#{file.ext('rb')}' instead of '#{file}'" }
252
+ #Load local tasks that can be used in the Buildfile.
253
+ @build_files += Dir["#{Dir.pwd}/tasks/*.rake"]
254
+ @build_files.each do |file|
255
+ unless $LOADED_FEATURES.include?(file)
256
+ load file
257
+ $LOADED_FEATURES << file
258
+ end
259
+ end
260
+ true
261
+ end
262
+ private :load_tasks
263
+
264
+ # :call-seq:
265
+ # deprecated(message)
266
+ #
267
+ # Use with deprecated methods and classes. This method automatically adds the file name and line number,
268
+ # and the text 'Deprecated' before the message, and eliminated duplicate warnings. It only warns when
269
+ # running in verbose mode.
270
+ #
271
+ # For example:
272
+ # deprecated 'Please use new_foo instead of foo.'
273
+ def deprecated(message) #:nodoc:
274
+ return unless verbose
275
+ "#{caller[1]}: Deprecated: #{message}".tap do |message|
276
+ @deprecated ||= {}
277
+ unless @deprecated[message]
278
+ @deprecated[message] = true
279
+ warn message
280
+ end
281
+ end
282
+ end
283
+
284
+ # Not for external consumption.
285
+ def switch_to_namespace(names) #:nodoc:
286
+ current, @scope = @scope, names
287
+ begin
288
+ yield
289
+ ensure
290
+ @scope = current
291
+ end
292
+ end
293
+
294
+ end
295
+
296
+
297
+ class << self
298
+
299
+ task 'buildr:initialize' do
300
+ Buildr.load_tasks_and_local_files
301
+ end
302
+
303
+ # Returns the Buildr::Application object.
304
+ def application
305
+ Rake.application
306
+ end
307
+
308
+ def application=(app) #:nodoc:
309
+ Rake.application = app
310
+ end
311
+
312
+ # Returns the Settings associated with this build.
313
+ def settings
314
+ Buildr.application.settings
315
+ end
316
+
317
+ # Copied from BUILD_ENV.
318
+ def environment
319
+ Buildr.application.environment
320
+ end
321
+
322
+ end
323
+
324
+ Buildr.application = Buildr::Application.new
325
+
326
+ end
327
+
328
+
329
+ # Add a touch of colors (red) to warnings.
330
+ if $stdout.isatty
331
+ begin
332
+ require 'Win32/Console/ANSI' if Config::CONFIG['host_os'] =~ /mswin/
333
+ HighLine.use_color = true
334
+ rescue LoadError
335
+ end
336
+ end
337
+
338
+ if HighLine.use_color?
339
+ module Kernel #:nodoc:
340
+ alias :warn_without_color :warn
341
+ def warn(message)
342
+ warn_without_color $terminal.color(message.to_s, :red)
343
+ end
344
+ end
345
+ end
346
+
347
+
348
+ module Rake #:nodoc
349
+ class Task #:nodoc:
350
+ def invoke(*args)
351
+ task_args = TaskArguments.new(arg_names, args)
352
+ invoke_with_call_chain(task_args, Thread.current[:rake_chain] || InvocationChain::EMPTY)
353
+ end
354
+
355
+ def invoke_with_call_chain(task_args, invocation_chain)
356
+ new_chain = InvocationChain.append(self, invocation_chain)
357
+ @lock.synchronize do
358
+ if application.options.trace
359
+ puts "** Invoke #{name} #{format_trace_flags}"
360
+ end
361
+ return if @already_invoked
362
+ @already_invoked = true
363
+ invoke_prerequisites(task_args, new_chain)
364
+ begin
365
+ old_chain, Thread.current[:rake_chain] = Thread.current[:rake_chain], new_chain
366
+ execute(task_args) if needed?
367
+ ensure
368
+ Thread.current[:rake_chain] = nil
369
+ end
370
+ end
371
+ end
372
+ end
373
+ end