class Buildr::CustomPom
Constants
- Developer
Attributes
dependency_filter[RW]
Property that accepts a proc that accepts a dependency and returns a boolean to determine whether dependency is included in pom or not.
description[W]
Specify a project description
issues_system[RW]
issues_url[RW]
name[W]
Specify the name of the project
scm_connection[RW]
scm_developer_connection[RW]
scm_url[RW]
url[RW]
Property for the projects url
Protected Class Methods
pom_xml(project, package)
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 165 def self.pom_xml(project, package) Proc.new do xml = Builder::XmlMarkup.new(:indent => 2) xml.instruct! xml.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') do xml.modelVersion '4.0.0' xml.groupId project.group xml.artifactId project.id xml.version project.version candidates = project.packages.select{|p| p.classifier.nil? }.collect{|p|p.type.to_s} packaging = !candidates.empty? ? candidates[0] : (project.compile.packaging || :zip).to_s xml.packaging packaging xml.name project.pom.name if project.pom.name xml.description project.pom.description if project.pom.description xml.url project.pom.url if project.pom.url xml.licenses do project.pom.licenses.each_pair do |name, url| xml.license do xml.name name xml.url url xml.distribution 'repo' end end end unless project.pom.licenses.empty? if project.pom.scm_url || project.pom.scm_connection || project.pom.scm_developer_connection xml.scm do xml.connection project.pom.scm_connection if project.pom.scm_connection xml.developerConnection project.pom.scm_developer_connection if project.pom.scm_developer_connection xml.url project.pom.scm_url if project.pom.scm_url end end if project.pom.issues_url xml.issueManagement do xml.url project.pom.issues_url xml.system project.pom.issues_system if project.pom.issues_system end end xml.developers do project.pom.developers.each do |developer| xml.developer do xml.id developer.id xml.name developer.name if developer.name xml.email developer.email if developer.email if developer.roles xml.roles do developer.roles.each do |role| xml.role role end end end end end end unless project.pom.developers.empty? provided_deps = Buildr.artifacts(project.pom.provided_dependencies) runtime_deps = Buildr.artifacts(project.pom.runtime_dependencies) additional_deps = Buildr.artifacts(project.pom.additional_dependencies) include_transitive_deps = Buildr.artifacts(project.pom.include_transitive_dependencies).collect {|dep| dep.to_s} optional_deps = Buildr.artifacts(project.pom.optional_dependencies).collect {|dep| dep.to_s} done = [] deps = [] deps += provided_deps. select {|d| d.is_a?(ActsAsArtifact)}. select {|d| !done.include?(d.to_s)}. collect {|dep| done << dep.to_s; dep.to_hash.merge(:scope => 'provided', :optional => optional_deps.include?(dep.to_s), :include_transitive => include_transitive_deps.include?(dep.to_s), :artifact => dep)} deps += runtime_deps. select {|d| d.is_a?(ActsAsArtifact)}. select {|d| !done.include?(d.to_s)}. collect {|dep| done << dep.to_s; dep.to_hash.merge(:scope => 'runtime', :optional => optional_deps.include?(dep.to_s), :include_transitive => include_transitive_deps.include?(dep.to_s), :artifact => dep)} deps += additional_deps. select {|d| d.is_a?(ActsAsArtifact)}. select {|d| !done.include?(d.to_s)}. collect {|dep| done << dep.to_s; dep.to_hash.merge(:scope => 'compile', :optional => optional_deps.include?(dep.to_s), :include_transitive => include_transitive_deps.include?(dep.to_s), :artifact => dep)} deps += Buildr.artifacts(project.compile.dependencies). select {|d| d.is_a?(ActsAsArtifact)}. select {|d| !done.include?(d.to_s)}. collect {|d| done << d.to_s; d.to_hash.merge(:scope => 'compile', :optional => optional_deps.include?(d.to_s), :include_transitive => include_transitive_deps.include?(d.to_s), :artifact => d)} deps += Buildr.artifacts(project.test.compile.dependencies). select {|d| d.is_a?(ActsAsArtifact)}. select {|d| !done.include?(d.to_s)}. collect {|d| d.to_hash.merge(:scope => 'test', :include_transitive => include_transitive_deps.include?(d.to_s), :artifact => d)} xml.dependencies do deps.select {|dependency| project.pom.dependency_filter.nil? ? true : project.pom.dependency_filter.call(dependency)}.each do |dependency| xml.dependency do xml.groupId dependency[:group] xml.artifactId dependency[:id] xml.version dependency[:version] xml.classifier dependency[:classifier] if dependency[:classifier] && dependency[:classifier].to_s != 'jar' xml.scope dependency[:scope] unless dependency[:scope] == 'compile' xml.optional true if dependency[:optional] unless dependency[:include_transitive] xml.exclusions do xml.exclusion do xml.groupId '*' xml.artifactId '*' end end end end end end unless deps.empty? end end end
Public Instance Methods
add_apache_v2_license()
click to toggle source
Add Apache2 to the list of licenses
# File lib/buildr/java/custom_pom.rb, line 45 def add_apache_v2_license self.licenses['The Apache Software License, Version 2.0'] = 'http://www.apache.org/licenses/LICENSE-2.0.txt' end
add_bsd_2_license()
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 49 def add_bsd_2_license self.licenses['The BSD 2-Clause License'] = 'http://opensource.org/licenses/BSD-2-Clause' end
add_bsd_3_license()
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 53 def add_bsd_3_license self.licenses['The BSD 3-Clause License'] = 'http://opensource.org/licenses/BSD-3-Clause' end
add_cddl_v1_license()
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 57 def add_cddl_v1_license self.licenses['Common Development and Distribution License (CDDL-1.0)'] = 'http://opensource.org/licenses/CDDL-1.0' end
add_developer(id, name = nil, email = nil, roles = nil)
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 111 def add_developer(id, name = nil, email = nil, roles = nil) self.developers << Developer.new(id, name, email, roles) end
add_epl_v1_license()
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 61 def add_epl_v1_license self.licenses['Eclipse Public License - v 1.0'] = 'http://www.eclipse.org/legal/epl-v10.html' end
add_github_project(project_spec)
click to toggle source
Add a project like add_github_project
('realityforge/gwt-appcache')
# File lib/buildr/java/custom_pom.rb, line 97 def add_github_project(project_spec) git_url = "git@github.com:#{project_spec}.git" self.scm_connection = self.scm_developer_connection = "scm:git:#{git_url}" self.scm_url = git_url web_url = "https://github.com/#{project_spec}" self.url = web_url self.issues_url = "#{web_url}/issues" self.issues_system = 'GitHub Issues' end
add_gpl_v1_license()
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 65 def add_gpl_v1_license self.licenses['GNU General Public License (GPL) version 1.0'] = 'http://www.gnu.org/licenses/gpl-1.0.html' end
add_gpl_v2_license()
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 69 def add_gpl_v2_license self.licenses['GNU General Public License (GPL) version 2.0'] = 'http://www.gnu.org/licenses/gpl-2.0.html' end
add_gpl_v3_license()
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 73 def add_gpl_v3_license self.licenses['GNU General Public License (GPL) version 3.0'] = 'http://www.gnu.org/licenses/gpl-3.0.html' end
add_lgpl_v2_license()
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 77 def add_lgpl_v2_license self.licenses['GNU General Lesser Public License (LGPL) version 2.1'] = 'http://www.gnu.org/licenses/lgpl-2.1.html' end
add_lgpl_v3_license()
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 81 def add_lgpl_v3_license self.licenses['GNU General Lesser Public License (LGPL) version 3.0'] = 'http://www.gnu.org/licenses/lgpl-3.0.html' end
add_mit_license()
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 85 def add_mit_license self.licenses['The MIT License'] = 'http://opensource.org/licenses/MIT' end
additional_dependencies()
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 131 def additional_dependencies @additional_dependencies ||= [] end
additional_dependencies=(additional_dependencies)
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 135 def additional_dependencies=(additional_dependencies) @additional_dependencies = additional_dependencies end
description()
click to toggle source
Retrieve the project description, defaulting to the name if not specified
# File lib/buildr/java/custom_pom.rb, line 32 def description @description || name end
developers()
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 107 def developers @developers ||= [] end
include_transitive_dependencies()
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 139 def include_transitive_dependencies @include_transitive_dependencies ||= [] end
include_transitive_dependencies=(include_transitive_dependencies)
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 143 def include_transitive_dependencies=(include_transitive_dependencies) @include_transitive_dependencies = include_transitive_dependencies end
licenses()
click to toggle source
Return the map of licenses for project
# File lib/buildr/java/custom_pom.rb, line 40 def licenses @licenses ||= {} end
name()
click to toggle source
Retrieve the name of the project, defaulting to the project description or the name if not specified
# File lib/buildr/java/custom_pom.rb, line 24 def name @name || @buildr_project.comment || @buildr_project.name end
optional_dependencies()
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 147 def optional_dependencies @optional_dependencies ||= [] end
optional_dependencies=(optional_dependencies)
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 151 def optional_dependencies=(optional_dependencies) @optional_dependencies = optional_dependencies end
provided_dependencies()
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 115 def provided_dependencies @provided_dependencies ||= [] end
provided_dependencies=(provided_dependencies)
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 119 def provided_dependencies=(provided_dependencies) @provided_dependencies = provided_dependencies end
runtime_dependencies()
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 123 def runtime_dependencies @runtime_dependencies ||= [] end
runtime_dependencies=(runtime_dependencies)
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 127 def runtime_dependencies=(runtime_dependencies) @runtime_dependencies = runtime_dependencies end
Protected Instance Methods
associate_project(buildr_project)
click to toggle source
# File lib/buildr/java/custom_pom.rb, line 161 def associate_project(buildr_project) @buildr_project = buildr_project end