Class: Doubleshot::Pom

Inherits:
Object show all
Defined in:
lib/doubleshot/pom.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Pom

Returns a new instance of Pom.



3
4
5
# File 'lib/doubleshot/pom.rb', line 3

def initialize(config)
  @config = config
end

Instance Method Details

#to_sObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/doubleshot/pom.rb', line 7

def to_s
  jars = @config.runtime.jars + @config.development.jars

  <<-EOS.margin
    <?xml version="1.0"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>#{@config.group}</groupId>
      <artifactId>#{@config.project}</artifactId>
      <version>#{@config.version}</version>
      <name>#{@config.project}</name>
      #{
        unless jars.empty?
          "<dependencies>\n            " +
          jars.map do |jar|
            <<-JAR.strip
        <dependency>
          <groupId>#{jar.group}</groupId>
          <artifactId>#{jar.artifact}</artifactId>
          <type>#{jar.packaging}</type>
          #{
          "<classifier>#{jar.classifier}</classifier>" unless jar.classifier.blank?
          }<version>#{jar.version}</version>#{
          unless jar.exclusions.empty?
            "\n              <exclusions>\n                " +
              jar.exclusions.map do |exclusion|
              groupId, artifactId = exclusion.split(":")
            <<-EXCLUSION.strip
            <exclusion>
              <groupId>#{groupId}</groupId>
              <artifactId>#{artifactId}</artifactId>
            </exclusion>
            EXCLUSION
              end.join("\n                ") +
            "\n              </exclusions>"
          end}
        </dependency>
            JAR
          end.join("\n            ") +
          "\n          </dependencies>\n"
        end
      }          <build>
        <sourceDirectory>#{@config.source.java}</sourceDirectory>
      </build>
    </project>
  EOS
end