bee_java 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/bin/bee2maven CHANGED
@@ -23,12 +23,14 @@ HELP = 'Usage: bee2maven file'
23
23
  TEMPLATE = ERB.new("<project>
24
24
  <dependencies>
25
25
  % for dependency in dependencies
26
+ % if dependency['group']
26
27
  <dependency>
27
28
  <groupId><%= dependency['group'] %></groupId>
28
29
  <artifactId><%= dependency['artifact'] %></artifactId>
29
30
  <version><%= dependency['version'] %></version>
30
31
  <type><%= dependency['type'] || 'jar' %></type>
31
32
  </dependency>
33
+ % end
32
34
  % end
33
35
  </dependencies>
34
36
  </project>
data/bin/gendeps CHANGED
@@ -18,30 +18,72 @@
18
18
 
19
19
  require 'erb'
20
20
 
21
- TEMPLATE = ERB.new('- group: <%= group %>
22
- artifact: <%= artifact %>
23
- version: <%= version %>
21
+ DEFAULT_REPOSITORY = 'http://mirrors.ibiblio.org/pub/mirrors/maven2'
22
+
23
+ TEMPLATE = ERB.new('- group: "<%= group %>"
24
+ artifact: "<%= artifact %>"
25
+ version: "<%= version %>"
24
26
  % if type
25
- type: <%= type %>
27
+ type: "<%= type %>"
26
28
  % end
27
- % if scope
28
- scope: <%= scope %>
29
+ % if scopes
30
+ % if scopes.length > 1
31
+ scope: [<%= scopes.map{|s| "\"#{s}\""}.join(", ") %>]
32
+ % else
33
+ scope: "<%= scopes[0] %>"
34
+ % end
29
35
  % end
30
36
  % if classifier
31
- classifier: <%= classifier %>
37
+ classifier: "<%= classifier %>"
38
+ % end
39
+ % if path
40
+ path: "<%= path %>"
32
41
  % end
33
42
 
34
43
  ', nil, '%')
35
44
 
36
- lines = `mvn dependency:list`
37
- for line in lines.split("\n")
38
- if line =~ /^\[INFO\] ([^:]+):([^:]+):([^:]+):([^:]+):([^:]+)\s*$/
39
- group = $1
40
- artifact = $2
41
- type = $3
42
- version = $4
43
- scope = $5
44
- classifier = nil
45
- puts TEMPLATE.result(binding)
45
+ DEFAULT_SCOPE = 'compile'
46
+
47
+ # scope availability: list for a given dependency scope the implied classpath
48
+ # scopes
49
+ SCOPE_AVAILABILITY = {
50
+ 'compile' => ['compile', 'test', 'runtime'],
51
+ 'provided' => ['compile', 'test'],
52
+ 'runtime' => ['test', 'runtime'],
53
+ 'test' => ['test'],
54
+ 'system' => ['compile', 'test', 'runtime'],
55
+ }
56
+
57
+ def error(message)
58
+ $stderr.puts message
59
+ exit(1)
60
+ end
61
+
62
+ def main
63
+ lines = `mvn dependency:list`
64
+ puts "- repository: \"#{DEFAULT_REPOSITORY}\""
65
+ puts
66
+ for line in lines.split("\n")
67
+ if line =~ /^\[INFO\] ([^:]+):([^:]+):([^:]+):([^:]+):([^:]+)\s*$/
68
+ group = $1
69
+ artifact = $2
70
+ type = $3
71
+ version = $4
72
+ scope = $5 || DEFAULT_SCOPE
73
+ classifier = nil
74
+ error("Unknown dependency scope '#{scope}'") if
75
+ !SCOPE_AVAILABILITY.keys.include?(scope)
76
+ scopes = SCOPE_AVAILABILITY[scope]
77
+ scopes = nil if scope == 'compile'
78
+ if scope == 'system'
79
+ $stderr.puts "Set path for system dependency '#{group}:#{artifact}:#{version}'"
80
+ path = 'TODO'
81
+ else
82
+ path = nil
83
+ end
84
+ puts TEMPLATE.result(binding)
85
+ end
46
86
  end
47
87
  end
88
+
89
+ main
data/bin/maven2bee CHANGED
@@ -29,7 +29,11 @@ TEMPLATE = ERB.new('- group: <%= group %>
29
29
  type: <%= type %>
30
30
  % end
31
31
  % if scope
32
- scope: <%= scope %>
32
+ % if scope.length > 1
33
+ scope: [<%= scope.join(", ") %>]
34
+ % else
35
+ scope: <%= scope[0] %>
36
+ % end
33
37
  % end
34
38
  % if classifier
35
39
  classifier: <%= classifier %>
@@ -37,9 +41,24 @@ TEMPLATE = ERB.new('- group: <%= group %>
37
41
 
38
42
  ', nil, '%')
39
43
 
44
+ # scope availability: list for a given dependency scope the implied classpath scopes
45
+ SCOPE_AVAILABILITY = {
46
+ 'compile' => ['compile', 'test', 'runtime'],
47
+ 'provided' => ['compile', 'test'],
48
+ 'runtime' => ['test', 'runtime'],
49
+ 'test' => ['test'],
50
+ }
51
+
40
52
  def deps_to_yaml(file)
41
53
  result = ''
42
54
  document = REXML::Document.new(File.read(ARGV[0]))
55
+ # load maven properties
56
+ properties = {}
57
+ REXML::XPath.each(document, '/project/properties/*') do |property|
58
+ name = property.name
59
+ value = property.text.strip
60
+ properties[name] = value
61
+ end
43
62
  REXML::XPath.each(document, '//dependency') do |dependency|
44
63
  group = dependency.elements['groupId'].text.strip
45
64
  artifact = dependency.elements['artifactId'].text.strip
@@ -51,6 +70,7 @@ def deps_to_yaml(file)
51
70
  end
52
71
  if dependency.elements['scope'] and dependency.elements['scope'].text
53
72
  scope = dependency.elements['scope'].text.strip
73
+ scope = SCOPE_AVAILABILITY[scope]
54
74
  else
55
75
  scope = nil
56
76
  end
@@ -59,11 +79,30 @@ def deps_to_yaml(file)
59
79
  else
60
80
  classifier = nil
61
81
  end
82
+ # replace properties references with their values
83
+ group = evaluate(group, properties)
84
+ artifact = evaluate(artifact, properties)
85
+ version = evaluate(version, properties)
86
+ type = evaluate(type, properties)
87
+ scope = evaluate(scope, properties)
88
+ classifier = evaluate(classifier, properties)
89
+ # build the dependency entry
62
90
  result += TEMPLATE.result(binding)
63
91
  end
64
92
  return result
65
93
  end
66
94
 
95
+ def evaluate(value, properties)
96
+ return nil if value == nil
97
+ if value =~ /\$\{.+\}/
98
+ name = value[2...-1]
99
+ raise "Property '#{name}' not found" if !properties.has_key?(name)
100
+ return properties[name]
101
+ else
102
+ return value
103
+ end
104
+ end
105
+
67
106
  if ARGV.length < 1
68
107
  puts HELP
69
108
  exit
data/build/README CHANGED
@@ -20,4 +20,4 @@ or go to URL http://www.apache.org/licenses/LICENSE-2.0).
20
20
 
21
21
  = Copyright
22
22
 
23
- Bee_java version 0.0.3 (C) Michel Casabianca - 2008-2010
23
+ Bee_java version 0.0.4 (C) Michel Casabianca - 2008-2012
data/egg/lib/build.erb CHANGED
@@ -1,54 +1,8 @@
1
1
  - build: <%= name %>
2
- default: all
3
2
  description: Build file for project <%= name.capitalize %>
3
+ extends: ":java:java.yml"
4
4
 
5
5
  - properties:
6
- name: "<%= name %>"
7
- version: "0.0.1"
8
- src: "src"
9
- tst: "test"
10
- lib: "lib"
11
- build: "build"
12
- classes: "#{build}/classes"
13
- test_classes: "#{build}/tst-classes"
14
- jar: "#{build}/#{name}-#{version}.jar"
15
-
16
- - target: compile
17
- description: Compile Java source files
18
- script:
19
- - java.javac:
20
- src: :src
21
- dest: :classes
22
-
23
- - target: test
24
- depends: compile
25
- description: Run unit tests
26
- script:
27
- - java.classpath:
28
- classpath: classpath
29
- directories: [:classes, :test_classes]
30
- - java.javac:
31
- src: :tst
32
- dest: :test_classes
33
- classpath: :classpath
34
- - java.junit:
35
- src: :tst
36
- classpath: :classpath
37
-
38
- - target: jar
39
- depends: test
40
- description: Generate JAR archive
41
- script:
42
- - java.jar:
43
- src: :classes
44
- dest: :jar
45
-
46
- - target: clean
47
- description: Clean generated files
48
- script:
49
- - rmdir: :build
50
-
51
- - target: all
52
- depends: [clean, jar]
53
- description: Clean generated files
54
-
6
+ name: "<%= name %>"
7
+ version: "0.0.1"
8
+ jv_main: "<%= main %>"
@@ -1,5 +1,6 @@
1
- - repository: http://www.ibiblio.org/maven2
1
+ - repository: http://mirrors.ibiblio.org/pub/mirrors/maven2
2
2
 
3
- - group: junit
4
- artifact: junit
5
- version: 4.3
3
+ - group: "junit"
4
+ artifact: "junit"
5
+ version: "4.10"
6
+ scope: "test"
data/egg/lib/source.erb CHANGED
@@ -6,4 +6,8 @@ public class <%= File.basename(main.gsub(/\./, '/')) %> {
6
6
  return "Hello "+who+"!";
7
7
  }
8
8
 
9
+ public static void main(String[] args) {
10
+ System.out.println(hello("World"));
11
+ }
12
+
9
13
  }
data/egg/lib.yml CHANGED
@@ -12,25 +12,25 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- - build: tiny
16
- default: all
15
+ - build: tiny
16
+ default: all
17
17
  description: "Generate a Java project for a library"
18
18
 
19
19
  - properties:
20
- name: test
21
- main: test.Test
20
+ name: lib
21
+ main: lib.Lib
22
22
  description: |
23
23
  This script will create Java project for a library. Build file has
24
24
  'compile', 'test' and 'jar' targets to compile, run unit tests, and
25
25
  generate JAR archive.
26
26
 
27
- - target: welcome
27
+ - target: welcome
28
28
  description: "Print information message"
29
29
  script:
30
30
  - print: :description
31
31
 
32
- - target: prompt
33
- depends: welcome
32
+ - target: prompt
33
+ depends: welcome
34
34
  description: "Prompt for project information"
35
35
  script:
36
36
  - print: "Please answer following questions to generate the project:"
@@ -43,8 +43,8 @@
43
43
  default: :main
44
44
  property: main
45
45
 
46
- - target: generate
47
- depends: prompt
46
+ - target: generate
47
+ depends: prompt
48
48
  description: "Generate project"
49
49
  script:
50
50
  - print: "Generating project..."
@@ -58,8 +58,8 @@
58
58
  - erb: { src: "#{base}/lib/build.erb", dest: "#{here}/#{name}/build.yml" }
59
59
  - cp: { src: "#{base}/lib/dependencies.yml", dest: "#{here}/#{name}/dependencies.yml" }
60
60
 
61
- - target: customization
62
- depends: generate
61
+ - target: customization
62
+ depends: generate
63
63
  description: "Print information about project customization"
64
64
  script:
65
65
  - print: |
@@ -67,5 +67,5 @@
67
67
  print information about generated build file.
68
68
  Enjoy!
69
69
 
70
- - target: all
70
+ - target: all
71
71
  depends: [welcome, prompt, generate, customization]
@@ -1,80 +1,40 @@
1
1
  - build: <%= name %>
2
- default: all
3
- description: Build file for project Test
4
- extends: tomcat.yml
2
+ description: Build file for project <%= name.capitalize %>
3
+ extends:
4
+ - ":java:java.yml"
5
+ - tomcat.yml
5
6
 
6
7
  - properties:
7
- name: "<%= name %>"
8
- version: "0.0.1"
9
- src: "src"
10
- test: "test"
11
- build: "build"
12
- classes: "#{build}/classes"
13
- test_classes: "#{build}/test-classes"
14
- jar: "#{build}/#{name}-#{version}.jar"
15
- clean_dirs:
16
- - :build
8
+ name: "<%= name %>"
9
+ version: "0.0.1"
10
+ tomcat_home: ~
11
+ jv_main: "<%= main %>"
12
+ jv_clean_dirs:
13
+ - :jv_build_dir
17
14
  - "#{tomcat_base}/logs/*"
18
15
  - "#{tomcat_base}/work/*"
19
16
  - "#{tomcat_base}/temp/*"
20
- clean_files: []
21
-
22
- - target: classpath
23
- description: Build classpath
24
- script:
25
- - java.classpath:
26
- classpath: classpath
27
- directories: [:classes, :test_classes]
28
-
29
- - target: compile
30
- depends: classpath
31
- description: Compile Java source files
32
- script:
33
- - java.javac:
34
- src: :src
35
- dest: :classes
36
- classpath: :classpath
37
-
38
- - target: test
39
- depends: compile
40
- description: Run unit tests
41
- script:
42
- - java.javac:
43
- src: :test
44
- dest: :test_classes
45
- classpath: :classpath
46
- - java.junit:
47
- src: :test
48
- classpath: :classpath
49
-
50
- - target: jar
51
- depends: test
52
- description: Generate JAR archive
53
- script:
54
- - java.jar:
55
- src: :classes
56
- dest: :jar
57
17
 
58
18
  - target: web
59
- depends: jar
19
+ depends: jv_jar
60
20
  description: Generate web archive
61
21
  script:
62
- - mkdir: "#{build}/web"
22
+ - mkdir: "#{jv_build_dir}/web"
63
23
  - copy:
64
24
  root: web
65
- dest: "#{build}/web"
66
- - mkdir: "#{build}/web/WEB-INF/lib"
25
+ dest: "#{jv_build_dir}/web"
26
+ - mkdir: "#{jv_build_dir}/web/WEB-INF/lib"
67
27
  - cp:
68
- src: :jar
69
- dest: "#{build}/web/WEB-INF/lib"
28
+ src: :jv_jar
29
+ dest: "#{jv_build_dir}/web/WEB-INF/lib"
70
30
 
71
31
  - target: war
72
32
  depends: web
73
33
  description: Build the WAR archive
74
34
  script:
75
35
  - zip:
76
- root: "#{build}/web"
77
- dest: "#{build}/#{name}-#{version}.war"
36
+ root: "#{jv_build_dir}/web"
37
+ dest: "#{jv_build_dir}/#{name}-#{version}.war"
78
38
 
79
39
  - target: run
80
40
  depends: [web, tomcat_restart]
@@ -84,13 +44,3 @@
84
44
  description: Print Tomcat logs on the console
85
45
  script:
86
46
  - "tail -f tomcat/logs/catalina.out"
87
-
88
- - target: clean
89
- description: Clean generated files
90
- script:
91
- - rmdir: :clean_dirs
92
- - rm: :clean_files
93
-
94
- - target: all
95
- depends: [clean, run]
96
- description: Clean and run application
@@ -1,8 +1,9 @@
1
- - repository: http://www.ibiblio.org/maven2
1
+ - repository: http://mirrors.ibiblio.org/pub/mirrors/maven2
2
2
 
3
3
  - group: junit
4
4
  artifact: junit
5
5
  version: 4.3
6
+ scope: test
6
7
 
7
8
  - group: servletapi
8
9
  artifact: servletapi
@@ -54,4 +54,3 @@
54
54
  - |
55
55
  #{tomcat_env}
56
56
  #{tomcat_script} start
57
-
data/egg/servlet/web.xml CHANGED
@@ -3,7 +3,8 @@
3
3
  <web-app version="2.4"
4
4
  xmlns="http://java.sun.com/xml/ns/j2ee"
5
5
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6
- xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
6
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
7
+ http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
7
8
 
8
9
  <display-name><%= name.capitalize %></display-name>
9
10
 
data/egg/servlet.yml CHANGED
@@ -17,7 +17,7 @@
17
17
  description: Generate a Java project for a servlet
18
18
 
19
19
  - properties:
20
- name: hello
20
+ name: servlet
21
21
  main: hello.World
22
22
  description: |
23
23
  This script will create Java project for a servlet. Type 'bee -b' to
data/egg/tiny/build.erb CHANGED
@@ -1,34 +1,8 @@
1
- - build: <%= name %>
2
- default: all
1
+ - build: <%= name %>
3
2
  description: Build file for project <%= name.capitalize %>
3
+ extends: ":java:java.yml"
4
4
 
5
5
  - properties:
6
- name: "<%= name %>"
7
- src: "src"
8
- build: "build"
9
- classes: "#{build}/classes"
10
- main: "<%= main %>"
11
- classpath: :classes
12
-
13
- - target: compile
14
- description: Compile Java source files
15
- script:
16
- - java.javac:
17
- src: :src
18
- dest: :classes
19
-
20
- - target: run
21
- depends: compile
22
- description: Run java program
23
- script:
24
- - java.java:
25
- main: :main
26
- classpath: :classes
27
-
28
- - target: clean
29
- description: Clean generated files
30
- script:
31
- - rmdir: :build
32
-
33
- - target: all
34
- depends: [clean, compile, run]
6
+ name: "<%= name %>"
7
+ version: "0.0.1"
8
+ jv_main: "<%= main %>"
@@ -0,0 +1,6 @@
1
+ - repository: http://mirrors.ibiblio.org/pub/mirrors/maven2
2
+
3
+ #- group: junit
4
+ # artifact: junit
5
+ # version: 4.3
6
+ # scope: test
data/egg/tiny.yml CHANGED
@@ -12,25 +12,25 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- - build: tiny
16
- default: all
15
+ - build: tiny
16
+ default: all
17
17
  description: "Generate a tiny Java project"
18
18
 
19
19
  - properties:
20
- name: test
20
+ name: tiny
21
21
  main: test.Test
22
22
  description: |
23
23
  This script will create a tiny Java project. Build file has targets
24
24
  'compile' and 'run' to compile and run Java source file. This is an
25
25
  accurate project to quickly test Java code.
26
26
 
27
- - target: welcome
27
+ - target: welcome
28
28
  description: "Print information message"
29
29
  script:
30
30
  - print: :description
31
31
 
32
- - target: prompt
33
- depends: welcome
32
+ - target: prompt
33
+ depends: welcome
34
34
  description: "Prompt for project information"
35
35
  script:
36
36
  - print: "Please answer following questions to generate the project:"
@@ -43,8 +43,8 @@
43
43
  default: :main
44
44
  property: main
45
45
 
46
- - target: generate
47
- depends: prompt
46
+ - target: generate
47
+ depends: prompt
48
48
  description: "Generate project"
49
49
  script:
50
50
  - print: "Generating project..."
@@ -54,9 +54,10 @@
54
54
  - mkdir: "#{here}/#{name}/src/#{File.dirname(main.gsub(/\./,'/'))}"
55
55
  - erb: { src: "#{base}/tiny/source.erb", dest: "#{here}/#{name}/src/#{main.gsub(/\./,'/')}.java" }
56
56
  - erb: { src: "#{base}/tiny/build.erb", dest: "#{here}/#{name}/build.yml" }
57
+ - cp: { src: "#{base}/tiny/dependencies.yml", dest: "#{here}/#{name}/" }
57
58
 
58
- - target: customization
59
- depends: generate
59
+ - target: customization
60
+ depends: generate
60
61
  description: "Print information about project customization"
61
62
  script:
62
63
  - print: |
@@ -64,5 +65,5 @@
64
65
  print information about generated build file.
65
66
  Enjoy!
66
67
 
67
- - target: all
68
+ - target: all
68
69
  depends: [welcome, prompt, generate, customization]
data/egg/xmlrpc/build.yml CHANGED
@@ -1,56 +1,21 @@
1
1
  - build: <%= name %>
2
- default: all
3
- description: Build file for sample XML-RPC project
2
+ description: Build file for project <%= name.capitalize %>
3
+ extends:
4
+ - ":java:java.yml"
4
5
 
5
6
  - properties:
6
- name: "<%= name %>"
7
- src: "src"
8
- build: "build"
9
- classes: "#{build}/classes"
10
- client: "test.Client"
11
- server: "test.Server"
12
- classpath: :classes
13
-
14
- - target: depends
15
- description: Get dependencies
16
- script:
17
- - java.classpath:
18
- classpath: cp_compile
19
- - rb: "cp_runtime = cp_compile + ':' + classes"
20
-
21
- - target: compile
22
- depends: depends
23
- description: Compile Java source files
24
- script:
25
- - java.javac:
26
- src: :src
27
- dest: :classes
28
- classpath: :cp_compile
29
- - copy:
30
- root: :src
7
+ name: "<%= name %>"
8
+ version: "0.0.1"
9
+ jv_main: "test.Server"
10
+ jv_res:
11
+ root: :jv_src
31
12
  includes: "**/*.properties"
32
- dest: :classes
13
+ client_main: "test.Client"
33
14
 
34
15
  - target: client
35
- depends: compile
16
+ depends: jv_compile
36
17
  description: Run XML-RPC client
37
18
  script:
38
19
  - java.java:
39
- main: :client
40
- classpath: :cp_runtime
41
-
42
- - target: server
43
- depends: compile
44
- description: Run XML-RPC server
45
- script:
46
- - java.java:
47
- main: :server
48
- classpath: :cp_runtime
49
-
50
- - target: clean
51
- description: Clean generated files
52
- script:
53
- - rmdir: :build
54
-
55
- - target: all
56
- depends: [clean, compile]
20
+ main: :client_main
21
+ classpath: :jv_runtime_cp
@@ -1,4 +1,4 @@
1
- - repository: http://www.ibiblio.org/maven2
1
+ - repository: http://mirrors.ibiblio.org/pub/mirrors/maven2
2
2
 
3
3
  - group: org.apache.xmlrpc
4
4
  artifact: xmlrpc-common
@@ -23,4 +23,3 @@
23
23
  - group: org.apache.ws.commons
24
24
  artifact: ws-commons-java5
25
25
  version: 1.0
26
-