Module: BuildrDependencyExtensions::PomGenerator
- Includes:
- Extension
- Defined in:
- lib/buildr-dependency-extensions/pom-generator.rb
Class Method Summary collapse
- .compile_dependencies(project) ⇒ Object
- .extended(base) ⇒ Object
- .generate_dependencies_hash(dependencies, scope) ⇒ Object
- .generate_pom(project) ⇒ Object
- .runtime_dependencies(project) ⇒ Object
- .test_dependencies(project) ⇒ Object
Class Method Details
.compile_dependencies(project) ⇒ Object
28 29 30 |
# File 'lib/buildr-dependency-extensions/pom-generator.rb', line 28 def compile_dependencies project project.compile.dependencies.select {|dep| HelperFunctions.is_artifact? dep} end |
.extended(base) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/buildr-dependency-extensions/pom-generator.rb', line 10 def self.extended(base) class << base def extra_pom_sections @extra_pom_sections ||= {} end end super end |
.generate_dependencies_hash(dependencies, scope) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/buildr-dependency-extensions/pom-generator.rb', line 40 def generate_dependencies_hash dependencies, scope dependencies.map do |dep| { 'groupId' => dep.to_hash[:group], 'artifactId' => dep.to_hash[:id], 'version' => dep.to_hash[:version], 'scope' => scope, 'type' => dep.to_hash[:type] } end end |
.generate_pom(project) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/buildr-dependency-extensions/pom-generator.rb', line 51 def generate_pom project compile_dependencies = compile_dependencies project runtime_dependencies = runtime_dependencies project test_dependencies = test_dependencies project dependencies_hashes = generate_dependencies_hash compile_dependencies, 'compile' dependencies_hashes += generate_dependencies_hash runtime_dependencies, 'runtime' dependencies_hashes += generate_dependencies_hash test_dependencies, 'test' pom_hash = { 'modelVersion' => '4.0.0', 'groupId' => project.group, 'artifactId' => project.name, 'version' => project.version, 'dependencies' => {'dependency' => dependencies_hashes.to_a} } project.extra_pom_sections.each {|key, value| pom_hash[key] = value} my_pom = file(project.path_to(:target, 'pom.xml')) do |f| FileUtils.mkdir_p(File.dirname(f.name)) unless f.exist? File.open(f.name, 'w') do |file| file.write(XmlSimple.xml_out(pom_hash, {'RootName' => 'project', 'NoAttr' => true})) end end project.package.pom.from my_pom end |
.runtime_dependencies(project) ⇒ Object
32 33 34 |
# File 'lib/buildr-dependency-extensions/pom-generator.rb', line 32 def runtime_dependencies project project.run.classpath.select {|dep| HelperFunctions.is_artifact? dep} end |
.test_dependencies(project) ⇒ Object
36 37 38 |
# File 'lib/buildr-dependency-extensions/pom-generator.rb', line 36 def test_dependencies project project.test.dependencies.select {|dep| HelperFunctions.is_artifact? dep} end |