Class: BuildMaster::JavaProject
- Inherits:
-
Object
- Object
- BuildMaster::JavaProject
- Defined in:
- lib/buildmaster/auto/java_project.rb
Overview
Java project that knows how to compile the production and test source
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#output ⇒ Object
Returns the value of attribute output.
-
#prod ⇒ Object
readonly
Returns the value of attribute prod.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#target_version ⇒ Object
Returns the value of attribute target_version.
-
#test ⇒ Object
readonly
Returns the value of attribute test.
Instance Method Summary collapse
- #add_project(project) ⇒ Object
- #classpath ⇒ Object
- #clean ⇒ Object
- #dir(path) ⇒ Object
- #file(path) ⇒ Object
-
#initialize(root) ⇒ JavaProject
constructor
A new instance of JavaProject.
- #jar(file) ⇒ Object
- #javac(buildfile = nil) ⇒ Object
- #junit(report_dir) ⇒ Object
- #make(buildfile = nil) ⇒ Object
- #package(dir, name) {|ant| ... } ⇒ Object
- #rebuild ⇒ Object
- #resource ⇒ Object
- #resource=(dir) ⇒ Object
- #src ⇒ Object
- #src=(dir) ⇒ Object
- #tests_with(*entries) ⇒ Object
- #tests_with_files_in(*dirs) ⇒ Object
-
#to_ant ⇒ Object
create XML classpath element for ANT build file.
-
#uses(*entries) ⇒ Object
Specifies that the current project uses the entry The entry can be one of the three things: It can be another JavaProject, in which case it will be added as a classpath element.
- #uses_files_in(*dirs) ⇒ Object
Constructor Details
#initialize(root) ⇒ JavaProject
Returns a new instance of JavaProject.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/buildmaster/auto/java_project.rb', line 7 def initialize(root) @root = root @prod = ProjectInfo.new(self) @prod.classpath = Classpath.new(root) @test = ProjectInfo.new(self) @test.classpath = Classpath.new(root) if block_given? yield self end end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/buildmaster/auto/java_project.rb', line 4 def name @name end |
#output ⇒ Object
Returns the value of attribute output.
4 5 6 |
# File 'lib/buildmaster/auto/java_project.rb', line 4 def output @output end |
#prod ⇒ Object (readonly)
Returns the value of attribute prod.
5 6 7 |
# File 'lib/buildmaster/auto/java_project.rb', line 5 def prod @prod end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
5 6 7 |
# File 'lib/buildmaster/auto/java_project.rb', line 5 def root @root end |
#target_version ⇒ Object
Returns the value of attribute target_version.
4 5 6 |
# File 'lib/buildmaster/auto/java_project.rb', line 4 def target_version @target_version end |
#test ⇒ Object (readonly)
Returns the value of attribute test.
5 6 7 |
# File 'lib/buildmaster/auto/java_project.rb', line 5 def test @test end |
Instance Method Details
#add_project(project) ⇒ Object
67 68 69 |
# File 'lib/buildmaster/auto/java_project.rb', line 67 def add_project(project) @prod.classpath.add project end |
#classpath ⇒ Object
63 64 65 |
# File 'lib/buildmaster/auto/java_project.rb', line 63 def classpath @prod.classpath end |
#clean ⇒ Object
117 118 119 |
# File 'lib/buildmaster/auto/java_project.rb', line 117 def clean output.delete end |
#dir(path) ⇒ Object
134 135 136 137 138 139 140 |
# File 'lib/buildmaster/auto/java_project.rb', line 134 def dir(path) if (path.class == String) @root.dir(path) else path end end |
#file(path) ⇒ Object
142 143 144 145 146 147 148 |
# File 'lib/buildmaster/auto/java_project.rb', line 142 def file(path) if (path.class == String) @root.file(path) else path end end |
#jar(file) ⇒ Object
113 114 115 |
# File 'lib/buildmaster/auto/java_project.rb', line 113 def jar(file) end |
#javac(buildfile = nil) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/buildmaster/auto/java_project.rb', line 71 def javac(buildfile = nil) javac = JavacAnt.new(prod.output, buildfile) javac.target_version = target_version javac.src = prod.src javac.classpath.add prod.classpath unless prod.classpath.empty? javac.resource = prod.resource if prod.resource result = nil if (test.src.nil?) result = [javac] else javac_test = JavacAnt.new(test.output, buildfile) javac_test.target_version = target_version javac_test.src = test.src javac_test.resource = test.resource if test.resource javac_test.classpath.add prod.output javac_test.classpath.add prod.classpath unless prod.classpath.empty? javac_test.classpath.add test.classpath unless test.classpath.empty? result = [javac, javac_test] end result end |
#junit(report_dir) ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/buildmaster/auto/java_project.rb', line 93 def junit(report_dir) junit = JUnitAnt.new(report_dir, self) junit.classpath.add test.output junit.classpath.add prod.output junit.classpath.add test.classpath junit.classpath.add prod.classpath junit end |
#make(buildfile = nil) ⇒ Object
102 103 104 |
# File 'lib/buildmaster/auto/java_project.rb', line 102 def make(buildfile = nil) javac(buildfile).each {|javac| javac.compile} end |
#package(dir, name) {|ant| ... } ⇒ Object
106 107 108 109 110 111 |
# File 'lib/buildmaster/auto/java_project.rb', line 106 def package(dir, name) ant = PackageAnt.new(dir, name) ant.add(prod.output, prod.src) yield ant if block_given? ant.run end |
#rebuild ⇒ Object
121 122 123 124 |
# File 'lib/buildmaster/auto/java_project.rb', line 121 def rebuild clean make end |
#resource ⇒ Object
30 31 32 |
# File 'lib/buildmaster/auto/java_project.rb', line 30 def resource prod.resource end |
#resource=(dir) ⇒ Object
26 27 28 |
# File 'lib/buildmaster/auto/java_project.rb', line 26 def resource=(dir) prod.resource = dir end |
#src ⇒ Object
22 23 24 |
# File 'lib/buildmaster/auto/java_project.rb', line 22 def src prod.src end |
#src=(dir) ⇒ Object
18 19 20 |
# File 'lib/buildmaster/auto/java_project.rb', line 18 def src=(dir) prod.src = dir end |
#tests_with(*entries) ⇒ Object
55 56 57 |
# File 'lib/buildmaster/auto/java_project.rb', line 55 def tests_with(*entries) add_entry(@test, entries) end |
#tests_with_files_in(*dirs) ⇒ Object
59 60 61 |
# File 'lib/buildmaster/auto/java_project.rb', line 59 def tests_with_files_in(*dirs) dirs.each {|dir| @test.classpath.add_all(dir(dir))} end |
#to_ant ⇒ Object
create XML classpath element for ANT build file
127 128 129 130 131 132 |
# File 'lib/buildmaster/auto/java_project.rb', line 127 def to_ant io = StringIO.new io << ClasspathEntry.new(prod.output).to_ant io << classpath.to_ant io.string end |
#uses(*entries) ⇒ Object
Specifies that the current project uses the entry The entry can be one of the three things: It can be another JavaProject, in which case it will be added as a classpath element. In this case, the project output and its classpath will be part of the current project classpath. It can also be a CottaDirectory or CottaFile, in which case it will be added to the classpath. It can also be a path string, in which case it will be converted to CottaFile or CottaDirectory based on whether or not the extname is empty
47 48 49 |
# File 'lib/buildmaster/auto/java_project.rb', line 47 def uses(*entries) add_entry(@prod, entries) end |
#uses_files_in(*dirs) ⇒ Object
51 52 53 |
# File 'lib/buildmaster/auto/java_project.rb', line 51 def uses_files_in(*dirs) dirs.each {|dir| @prod.classpath.add_all(dir(dir))} end |