buildr-examples 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. data/LICENSE +176 -0
  2. data/README.rdoc +35 -0
  3. data/examples/artifacts/install_upload/app.zip +0 -0
  4. data/examples/artifacts/install_upload/buildfile +29 -0
  5. data/examples/artifacts/install_upload/src/main/java/HelloWorld.java +5 -0
  6. data/examples/artifacts/shared/artifacts.rb +5 -0
  7. data/examples/artifacts/simple/buildfile +75 -0
  8. data/examples/artifacts/simple/src/main/java/HelloWorld.java +5 -0
  9. data/examples/building/apt/buildfile +8 -0
  10. data/examples/building/apt/run.sh +3 -0
  11. data/examples/building/apt/src/main/java/Example.java +9 -0
  12. data/examples/building/chaining/buildfile +13 -0
  13. data/examples/building/chaining/run.sh +2 -0
  14. data/examples/building/chaining/src/main/java/Example.java +5 -0
  15. data/examples/building/chaining/srcs/HelloWorld.java +5 -0
  16. data/examples/building/compiler/buildfile +42 -0
  17. data/examples/building/compiler/groovyproject/src/main/groovy/HelloWorld.groovy +9 -0
  18. data/examples/building/compiler/javaproject/src/main/java/HelloWorld.java +5 -0
  19. data/examples/building/compiler/run.sh +10 -0
  20. data/examples/building/compiler/scalaproject/src/main/scala/HelloWorld.scala +5 -0
  21. data/examples/building/extending_tasks/buildfile +24 -0
  22. data/examples/building/extending_tasks/run.sh +4 -0
  23. data/examples/building/extending_tasks/src/main/java/HelloWorld.java +5 -0
  24. data/examples/building/jjtree/buildfile +10 -0
  25. data/examples/building/jjtree/run.sh +3 -0
  26. data/examples/building/jjtree/src/main/jjtree/com/acme/Example.java +7 -0
  27. data/examples/building/resources/buildfile +23 -0
  28. data/examples/building/resources/profiles.yaml +12 -0
  29. data/examples/building/resources/run.sh +6 -0
  30. data/examples/building/resources/src/main/property-style/ant.txt +1 -0
  31. data/examples/building/resources/src/main/property-style/erb.txt +1 -0
  32. data/examples/building/resources/src/main/property-style/maven.txt +1 -0
  33. data/examples/building/resources/src/main/property-style/regex.txt +1 -0
  34. data/examples/building/resources/src/main/property-style/ruby.txt +1 -0
  35. data/examples/building/resources/src/main/resources/filter.txt +1 -0
  36. data/examples/installing/buildfile +7 -0
  37. data/examples/installing/run.sh +16 -0
  38. data/examples/ivy4r/simple/ant-scripts/ivysettings.xml +9 -0
  39. data/examples/ivy4r/simple/buildfile +10 -0
  40. data/examples/ivy4r/simple/ivy.xml +6 -0
  41. data/examples/ivy4r/simple/run.sh +2 -0
  42. data/examples/ivy4r/simple/src/main/java/HelloWorld.java +8 -0
  43. data/examples/packaging/include_exclude/README +1 -0
  44. data/examples/packaging/include_exclude/buildfile +62 -0
  45. data/examples/packaging/include_exclude/run.sh +4 -0
  46. data/examples/packaging/include_exclude/src/main/java/HelloWorld.java +5 -0
  47. data/examples/packaging/include_exclude/src/main/resources/include/some_resource.txt +0 -0
  48. data/examples/packaging/include_exclude/src/main/resources/some.include +0 -0
  49. data/examples/packaging/include_exclude/src/main/resources/some_exclude.clu +0 -0
  50. data/examples/packaging/include_exclude/src/main/resources/some_exclude.ex +0 -0
  51. data/examples/packaging/include_exclude/src/main/webapp/WEB-INF/web.xml +0 -0
  52. data/examples/packaging/meta/ADDITIONAL +1 -0
  53. data/examples/packaging/meta/DISCLAIMER +1 -0
  54. data/examples/packaging/meta/NOTICE +1 -0
  55. data/examples/packaging/meta/buildfile +25 -0
  56. data/examples/packaging/meta/run.sh +2 -0
  57. data/examples/packaging/meta/src/main/MANIFEST.MF +7 -0
  58. data/examples/packaging/meta/src/main/java/HelloWorld.java +5 -0
  59. data/examples/packaging/meta/src/main/resources/some_resource.txt +0 -0
  60. data/examples/packaging/meta/src/main/webapp/WEB-INF/web.xml +0 -0
  61. data/examples/packaging/multiple/buildfile +39 -0
  62. data/examples/packaging/multiple/run.sh +6 -0
  63. data/examples/packaging/multiple/src/main/java/HelloWorld.java +5 -0
  64. data/examples/packaging/multiple/src/main/resources/some_resource.txt +0 -0
  65. data/examples/packaging/multiple/src/main/webapp/WEB-INF/web.xml +0 -0
  66. data/examples/projects/foo-bar/buildfile +24 -0
  67. data/examples/projects/foo-bar/run.sh +2 -0
  68. data/examples/projects/killer-app/buildfile +82 -0
  69. data/examples/projects/killer-app/run.sh +27 -0
  70. data/examples/projects/killer-app/teh-api/src/main/java/Example.java +5 -0
  71. data/examples/projects/killer-app/teh-api/src/test/java/ExampleTest.java +8 -0
  72. data/examples/projects/killer-app/teh-impl/src/main/java/Example.java +5 -0
  73. data/examples/projects/killer-app/teh-impl/src/main/resources/META-INF/persistence.xml +18 -0
  74. data/examples/projects/killer-app/teh-impl/src/test/java/ExampleTest.java +8 -0
  75. data/examples/projects/silly/buildfile +15 -0
  76. data/examples/projects/silly/run.sh +2 -0
  77. data/examples/projects/task/buildfile +12 -0
  78. data/examples/projects/task/run.sh +5 -0
  79. data/examples/testing/failing/buildfile +11 -0
  80. data/examples/testing/failing/run.sh +7 -0
  81. data/examples/testing/failing/src/main/java/Example.java +5 -0
  82. data/examples/testing/failing/src/test/java/FailingExampleTest.java +8 -0
  83. data/examples/testing/frameworks/buildfile +12 -0
  84. data/examples/testing/frameworks/junit/src/main/java/Example.java +5 -0
  85. data/examples/testing/frameworks/junit/src/test/java/ExampleTest.java +8 -0
  86. data/examples/testing/frameworks/run.sh +5 -0
  87. data/examples/testing/frameworks/testng/src/main/java/Example.java +5 -0
  88. data/examples/testing/frameworks/testng/src/test/java/ExampleTest.java +9 -0
  89. data/examples/testing/include_exclude/buildfile +9 -0
  90. data/examples/testing/include_exclude/run.sh +2 -0
  91. data/examples/testing/include_exclude/src/main/java/Example.java +5 -0
  92. data/examples/testing/include_exclude/src/test/java/ExampleTest.java +8 -0
  93. data/examples/testing/include_exclude/src/test/java/FailingExampleTest.java +8 -0
  94. data/examples/testing/include_exclude/src/test/java/de/phoet/IncludeTest.java +10 -0
  95. data/examples/testing/integration/buildfile +12 -0
  96. data/examples/testing/integration/client/src/main/java/Example.java +5 -0
  97. data/examples/testing/integration/client/src/test/java/ClientExampleTest.java +8 -0
  98. data/examples/testing/integration/run.sh +2 -0
  99. data/examples/testing/integration/server/src/main/java/Example.java +5 -0
  100. data/examples/testing/integration/server/src/test/java/ServerExampleTest.java +8 -0
  101. data/examples/testing/running/buildfile +13 -0
  102. data/examples/testing/running/client/src/main/java/Example.java +5 -0
  103. data/examples/testing/running/client/src/test/java/ClientExampleTest.java +8 -0
  104. data/examples/testing/running/run.sh +26 -0
  105. data/examples/testing/running/server/src/main/java/Example.java +5 -0
  106. data/examples/testing/running/server/src/test/java/ServerExampleTest.java +8 -0
  107. data/features/artifacts.feature +42 -0
  108. data/features/step_definitions/artifacts_steps.rb +19 -0
  109. data/features/support/env.rb +11 -0
  110. metadata +213 -0
@@ -0,0 +1,9 @@
1
+ //hello.groovy
2
+ println "hello, world"
3
+ for (arg in this.args ) {
4
+ println "Argument:" + arg;
5
+ }
6
+ // this is a comment
7
+ /* a block comment, commenting out an alternative to above:
8
+ this.args.each{ arg -> println "hello, ${arg}"}
9
+ */
@@ -0,0 +1,5 @@
1
+ public class HelloWorld {
2
+ public static void main(String[] args){
3
+ System.out.println("Hello World!");
4
+ }
5
+ }
@@ -0,0 +1,10 @@
1
+ echo "compile and enable debug ..."
2
+ buildr clean compile debug=on
3
+
4
+ echo "compile and disable debug ..."
5
+ echo "... when calling buildr with debug=off"
6
+ buildr clean compile debug=off
7
+
8
+ echo "... once until we change the variable with sysproperty"
9
+ export DEBUG=off
10
+ buildr compile
@@ -0,0 +1,5 @@
1
+ object HelloWorld {
2
+ def main(args: Array[String]) {
3
+ println("Hello, world!")
4
+ }
5
+ }
@@ -0,0 +1,24 @@
1
+ repositories.remote << "http://www.ibiblio.org/maven2/"
2
+
3
+ define "extending_tasks", :version=>"1.0.0" do
4
+
5
+ # extend the build task, the taks itself is yielded for the block
6
+ build do |build_task|
7
+ info "extending task #{build_task.inspect}"
8
+ mkdir _('staged')
9
+ touch _('staged/file.txt')
10
+ end
11
+
12
+ # extend the compile task for post-compilation work, the taks itself is yielded for the block
13
+ compile do |compile_task|
14
+ info "extending task #{compile_task.inspect}"
15
+ compile_task.sources.each {|s| info "source: #{s.inspect}"}
16
+ end
17
+
18
+ # extending the clean task to remove additional stuff, the taks itself is yielded for the block
19
+ clean do |clean_task|
20
+ info "extending task #{clean_task.inspect}"
21
+ rm_rf _('staged')
22
+ end
23
+
24
+ end
@@ -0,0 +1,4 @@
1
+ echo "compile to see the extension"
2
+ buildr clean compile
3
+ echo "clean to see additional removal"
4
+ buildr clean
@@ -0,0 +1,5 @@
1
+ public class HelloWorld {
2
+ public static void main(String[] args){
3
+ System.out.println("Hello World!");
4
+ }
5
+ }
@@ -0,0 +1,10 @@
1
+ require 'buildr/javacc'
2
+
3
+ repositories.remote << "http://www.ibiblio.org/maven2/"
4
+
5
+ define "jjtree", :version=>"1.0.0" do
6
+ # use jjtree for compilation
7
+ # --> disabled, due to a missing example...
8
+ # jjtree = jjtree(_('src/main/jjtree'), :in_package=>'com.acme')
9
+ # compile.from javacc(jjtree, :in_package=>'com.acme'), jjtree
10
+ end
@@ -0,0 +1,3 @@
1
+ echo "just build to use jjtree"
2
+ echo "jjtree is disabled because of missing example..."
3
+ #buildr
@@ -0,0 +1,7 @@
1
+ package com.acme;
2
+
3
+ public class Example {
4
+ public void callMe(){
5
+ System.out.println("I got called!");
6
+ }
7
+ }
@@ -0,0 +1,23 @@
1
+ repositories.remote << "http://www.ibiblio.org/maven2/"
2
+
3
+ define "resources", :version=>"1.0.0" do
4
+ # filter the resources with defined param and filters defined in profiles.yaml
5
+ resources.filter.using 'date'=>Time.new
6
+ # this should force the expected behavior, see https://issues.apache.org/jira/browse/BUILDR-349
7
+ resources.filter.using( { 'date' => Time.new }.merge( Buildr.settings.profile['filter'] ))
8
+
9
+ # use a custom filter using ant-style properties like @key@
10
+ run_filter(:ant, :ant)
11
+ # use a custom filter using erb-style properties like <%=key=>
12
+ run_filter(:erb, :erb)
13
+ # use a custom filter using maven-style properties like ${key}
14
+ run_filter(:maven, :maven)
15
+ # use a custom filter using ruby-style properties like #{key}
16
+ run_filter(:ruby, :ruby)
17
+ # use a custom filter using a regex to match property like =key=
18
+ run_filter(:regex, /=(.*?)=/)
19
+ end
20
+
21
+ def run_filter(name, type)
22
+ filter('src/main/property-style').include("#{name}.txt").into('target/resources').using(type, 'version'=>version, 'created'=>Time.now).run
23
+ end
@@ -0,0 +1,12 @@
1
+ filter: &dev
2
+ version: development
3
+ copyright: Acme Inc (C) 2009
4
+
5
+ filter: &tes
6
+ version: test
7
+ copyright: Acme Inc (C) 2009
8
+
9
+ development:
10
+ filter: *dev
11
+ test:
12
+ filter: *tes
@@ -0,0 +1,6 @@
1
+ echo "just build and open the filtered resources"
2
+ buildr clean build && cat target/resources/filter.txt
3
+ buildr -e test clean build && cat target/resources/filter.txt
4
+
5
+ echo "show additional filtered files"
6
+ buildr clean build && cat target/resources/*.txt
@@ -0,0 +1 @@
1
+ vrs: @version@ crt: @created@
@@ -0,0 +1 @@
1
+ vrs: <%=version%> crt: <%=created%>
@@ -0,0 +1 @@
1
+ vrs: ${version} crt: ${created}
@@ -0,0 +1 @@
1
+ vrs: =version= crt: =created=
@@ -0,0 +1 @@
1
+ vrs: #{version} crt: #{created}
@@ -0,0 +1 @@
1
+ version: ${version} copyright: ${copyright} date: ${date}
@@ -0,0 +1,7 @@
1
+ repositories.remote << "http://www.ibiblio.org/maven2/"
2
+
3
+ define "compiler" do
4
+ # define the project-version
5
+ project.version = '1.0.0'
6
+ info "environment: #{Buildr.environment}"
7
+ end
@@ -0,0 +1,16 @@
1
+ echo "process some buildr options"
2
+ echo "-f/--buildfile [file] Specify the buildfile."
3
+ buildr -f buildfile
4
+ buildr --buildfile buildfile
5
+ echo "-e/--environment [name] Environment name (e.g. development, test, production)."
6
+ buildr -e production
7
+ buildr --environment production
8
+ echo "-V/--version Display the program version."
9
+ buildr -V
10
+ buildr --version
11
+ echo "-T/--tasks [PATTERN] Display the tasks (matching optional PATTERN) with descriptions, then exit."
12
+ buildr -T
13
+ buildr --tasks
14
+ echo "-D, --describe [PATTERN] Describe the tasks (matching optional PATTERN), then exit."
15
+ buildr -D
16
+ buildr --describe
@@ -0,0 +1,9 @@
1
+ <ivysettings>
2
+ <settings defaultResolver="chained"/>
3
+ <property name="java.net.maven.pattern" value="[organisation]/jars/[module]-[revision].[ext]"/>
4
+ <resolvers>
5
+ <chain name="chained" returnFirst="true">
6
+ <ibiblio name="ibiblio" m2compatible="true"/>
7
+ </chain>
8
+ </resolvers>
9
+ </ivysettings>
@@ -0,0 +1,10 @@
1
+ require 'ivy4r'
2
+ require 'buildr/ivy_extension'
3
+
4
+ repositories.remote << "http://www.ibiblio.org/maven2/"
5
+
6
+ define "simple", :version=>"1.0.0" do
7
+ ivy.conf :compile => 'default'
8
+
9
+ package(:jar)
10
+ end
@@ -0,0 +1,6 @@
1
+ <ivy-module version="2.0">
2
+ <info organisation="de.nofail" module="ivy4r-example"/>
3
+ <dependencies>
4
+ <dependency org="commons-lang" name="commons-lang" rev="2.0"/>
5
+ </dependencies>
6
+ </ivy-module>
@@ -0,0 +1,2 @@
1
+ echo "build with ivy4r"
2
+ buildr package
@@ -0,0 +1,8 @@
1
+ public class HelloWorld {
2
+ public static void main(String[] args){
3
+ String hello = "Hello World!";
4
+ if(org.apache.commons.lang.StringUtils.isNotBlank(hello)){
5
+ System.out.println(hello);
6
+ }
7
+ }
8
+ }
@@ -0,0 +1 @@
1
+ RTFM!
@@ -0,0 +1,62 @@
1
+ repositories.remote << "http://www.ibiblio.org/maven2/"
2
+
3
+ define "include_exclude", :version=>"1.0.0" do
4
+ package(:zip).include _(:src, :main, :java, '*.java'), 'README'
5
+
6
+ # exclude pattern based on extension-name
7
+ package(:file=>_(:target, 'with_excludes.zip')).
8
+ include('src/main/resources').
9
+ exclude('**/*.ex')
10
+
11
+ # include any file with the provided extensions
12
+ package(:file=>_(:target, 'with_or_pattern.zip')).
13
+ include('src/main/resources/*.{clu,ex}')
14
+
15
+ # include any extension with the characters e and x
16
+ package(:file=>_(:target, 'with_characterpattern.zip')).
17
+ include('src/main/resources/*.[ex]*')
18
+
19
+ # include any extension with 2 characters starting with e
20
+ package(:file=>_(:target, 'with_any_character.zip')).
21
+ include('src/main/resources/*.e?')
22
+
23
+ # put included stuff to different path
24
+ package(:file=>_(:target, 'with_different_path.zip')).
25
+ include(_(:src, :main, :resources, '*'), :path=>"#{id}-#{version}")
26
+
27
+ # use the path repeatedly using 'tap'
28
+ package(:file=>_(:target, 'with_tap.zip')).path("#{id}-#{version}").tap do |path|
29
+ path.include 'src/main/resources/*.*'
30
+ path.include 'README'
31
+ end
32
+
33
+ # define the target-name of an include
34
+ package(:file=>_(:target, 'with_as_filename.zip')).
35
+ include('README', :as=>'readme.txt')
36
+
37
+ # this selects all files currently available in the include-directory (and sub-directory)
38
+ package(:file=>_(:target, 'direct_include.zip')).
39
+ include('target/resources/*')
40
+ # this selects the same but not at definition-time but at execution-time
41
+ package(:file=>_(:target, 'lazy_include.zip')).
42
+ include('target/resources', :as=>'.')
43
+
44
+ # extend the build-task to write some additional file
45
+ build do
46
+ write('target/resources/additional.txt', 'content')
47
+ end
48
+
49
+ # create an empty/cleaned zip
50
+ package(:file=>_(:target, 'empty.zip')).
51
+ include(_(:src, :main, :resources, '*')).
52
+ clean
53
+
54
+ # merge all the zips created yet
55
+ pkgs = packages.map{|p| "#{p}" }
56
+ package(:file=>_(:target, 'merged_all.zip')).
57
+ merge(pkgs)
58
+
59
+ # merge all but remove resources
60
+ package(:file=>_(:target, 'merged_all_without_resources.zip')).
61
+ merge(pkgs).exclude('resources/**')
62
+ end
@@ -0,0 +1,4 @@
1
+ echo "package to create project artifacts"
2
+ buildr clean package
3
+ echo "show content of zips"
4
+ for i in target/*.zip; do unzip -l "$i"; done
@@ -0,0 +1,5 @@
1
+ public class HelloWorld {
2
+ public static void main(String[] args){
3
+ System.out.println("Hello World!");
4
+ }
5
+ }
@@ -0,0 +1 @@
1
+ additional
@@ -0,0 +1 @@
1
+ disclaimer
@@ -0,0 +1 @@
1
+ notice
@@ -0,0 +1,25 @@
1
+ repositories.remote << "http://www.ibiblio.org/maven2/"
2
+
3
+ define "meta", :version=>"1.0.0" do
4
+ # set default manifest
5
+ manifest['Copyright'] = 'Default Inc (C) 2010'
6
+ # set default includes for meta directory
7
+ meta_inf << file('DISCLAIMER') << file('NOTICE')
8
+
9
+ package(:jar, :file=>_(:target, "manifest_default.jar"))
10
+ # merge default with hash
11
+ package(:jar, :file=>_(:target, "manifest_merge.jar")).with :manifest=>manifest.merge('Main-Class'=>'com.acme.Main')
12
+
13
+ # add more to meta directory
14
+ package(:jar, :file=>_(:target, "meta_additional.jar")).with :meta_inf=>file('ADDITIONAL')
15
+
16
+ # create from file
17
+ package(:jar, :file=>_(:target, "manifest_file.jar")).with :manifest=>_('src/main/MANIFEST.MF')
18
+ # create from hash
19
+ package(:jar, :file=>_(:target, "manifest_hash.jar")).with :manifest=>{ 'Copyright'=>'Hash Inc (C) 2010' }
20
+ # create from proc
21
+ package(:jar, :file=>_(:target, "manifest_proc.jar")).with :manifest=>Proc.new{|n|{ 'Copyright'=>'Proc Inc (C) 2010' }}
22
+
23
+ # dont create
24
+ package(:jar, :file=>_(:target, "manifest_none.jar")).with :manifest=>false
25
+ end
@@ -0,0 +1,2 @@
1
+ echo "package to create project artifacts"
2
+ buildr clean package
@@ -0,0 +1,7 @@
1
+ Build-By: nofail
2
+ Build-Jdk: 1.5.0_13
3
+ Implementation-Title: multiple
4
+ Implementation-Version: 1.0.0
5
+ Manifest-Version: 1.0
6
+ Created-By: phoet
7
+
@@ -0,0 +1,5 @@
1
+ public class HelloWorld {
2
+ public static void main(String[] args){
3
+ System.out.println("Hello World!");
4
+ }
5
+ }
@@ -0,0 +1,39 @@
1
+ repositories.remote << "http://www.ibiblio.org/maven2/"
2
+
3
+ define "multiple", :version=>"1.0.0" do
4
+ # you can create multiple packages from one project
5
+
6
+ # create a jar
7
+ package :jar
8
+ # is equivalent to
9
+ package :type=>:jar
10
+ # or let buildr interfer a type from project
11
+ package
12
+
13
+ # create a war
14
+ package :war
15
+
16
+ # create a source-zip
17
+ package :sources
18
+
19
+ # create a zip
20
+ package :zip, :file=>_('target/multiple.zip')
21
+
22
+ # let buildr interfer a type from package-extension (.jar)
23
+ package :file=>_('target/multiple_with_extension.jar')
24
+
25
+ # override the project definition for an artifact (you cant define a file in this case!)
26
+ # other id
27
+ package :jar, :id=>'silly'
28
+ # other group
29
+ package :jar, :group=>'stupid'
30
+ # other version
31
+ package :war, :version=>'1.x'
32
+ # other classifier
33
+ package :zip, :classifier=>'sources'
34
+
35
+ end
36
+
37
+ # print some package-information
38
+ puts project('multiple').packages.first
39
+ puts project('multiple').packages.select { |pkg| pkg.type == :zip }.inspect
@@ -0,0 +1,6 @@
1
+ echo "package to create project artifacts"
2
+ buildr clean package
3
+ echo "show some artifacts"
4
+ unzip -l target/multiple-1.0.0.jar
5
+ unzip -l target/multiple-1.0.0.war
6
+ unzip -l target/multiple.zip