Class: Naether::Maven
- Inherits:
-
Object
- Object
- Naether::Maven
- Defined in:
- lib/naether/maven.rb
Overview
Helper for interacting with a Maven POM
Class Method Summary (collapse)
-
+ (Naether::Maven) create_from_notation(notation)
Create an instance based on notation.
-
+ (Naether::Maven) create_from_pom(pom_path)
Create an instance from a POM.
Instance Method Summary (collapse)
-
- (Object) add_dependency(notation, scope = nil)
Add dependency by scope.
-
- (String) build_pom
Create the XML for a Maven Pom.
-
- (Object) dependencies(scopes = nil)
Get dependences for Project as notations.
-
- (Object) dependencies=(dependencies)
Set dependencies.
- - (Object) final_name
-
- (Maven) initialize(pom_path = nil)
constructor
Create new instance.
-
- (Object) invoke(*opts)
Invoke a Maven goal.
-
- (Object) load_naether(naether)
Load dependencies and remote repo from a Naether instance.
-
- (Object) notation=(notation)
Set the Notation for this Project.
-
- (Object) repositories=(repositories)
Set repositories.
-
- (Object) version
Get the version.
-
- (Object) write_pom(file_path)
Write Maven Pom.
Constructor Details
- (Maven) initialize(pom_path = nil)
Create new instance
51 52 53 54 55 56 57 58 |
# File 'lib/naether/maven.rb', line 51 def initialize(pom_path = nil) if pom_path @project = Naether::Java.create("com.tobedevoured.naether.maven.Project", pom_path ) else @project = Naether::Java.create("com.tobedevoured.naether.maven.Project" ) end end |
Class Method Details
+ (Naether::Maven) create_from_notation(notation)
Create an instance based on notation
41 42 43 44 45 |
# File 'lib/naether/maven.rb', line 41 def create_from_notation( notation ) maven = Maven.new maven.notation = notation maven end |
+ (Naether::Maven) create_from_pom(pom_path)
Create an instance from a POM
32 33 34 |
# File 'lib/naether/maven.rb', line 32 def create_from_pom( pom_path ) maven = Maven.new( pom_path ) end |
Instance Method Details
- (Object) add_dependency(notation, scope = nil)
Add dependency by scope
102 103 104 |
# File 'lib/naether/maven.rb', line 102 def add_dependency( notation, scope = nil ) @project.addDependency( notation, scope ) end |
- (String) build_pom
Create the XML for a Maven Pom
137 138 139 |
# File 'lib/naether/maven.rb', line 137 def build_pom() @project.toXml() end |
- (Object) dependencies(scopes = nil)
Get dependences for Project as notations
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/naether/maven.rb', line 71 def dependencies( scopes = nil) if scopes unless scopes.is_a? Array scopes = [scopes] end end if Naether.platform == 'java' if scopes.nil? deps = @project.getDependenciesNotation() else deps = @project.getDependenciesNotation( scopes ) end elsif scopes list = Naether::Java.convert_to_java_list( scopes ) deps = @project._invoke('getDependenciesNotation', 'Ljava.util.List;', list) else deps = @project.getDependenciesNotation() end Naether::Java.convert_to_ruby_array( deps, true ) end |
- (Object) dependencies=(dependencies)
Set dependencies
110 111 112 |
# File 'lib/naether/maven.rb', line 110 def dependencies=(dependencies) @project.setDependencies( dependencies ) end |
- (Object) final_name
178 179 180 |
# File 'lib/naether/maven.rb', line 178 def final_name @project.getFinalName() end |
- (Object) invoke(*opts)
Invoke a Maven goal
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/naether/maven.rb', line 152 def invoke( *opts ) #defaults config = { # Checks ENV for maven home, otherwise defaults /usr/share/maven # XXX: Reuse Eng.getMavenHome? :maven_home => ENV['maven.home'] || ENV['MAVEN_HOME'] || '/usr/share/maven', :local_repo => File.('~/.m2/repository') } if opts.last.is_a? Hash config = config.merge( opts.pop ) end goals = opts pom = @project.getPomFile().getAbsolutePath() invoker = Naether::Java.create("com.tobedevoured.naether.maven.Invoker", config[:local_repo], config[:maven_home] ) java_list = Naether::Java.convert_to_java_list(goals) if Naether.platform == 'java' invoker.execute( pom, java_list ) else invoker._invoke('execute', 'Ljava.lang.String;Ljava.util.List;', pom, java_list) end end |
- (Object) load_naether(naether)
Load dependencies and remote repo from a Naether instance
129 130 131 132 |
# File 'lib/naether/maven.rb', line 129 def load_naether( naether ) self.dependencies= naether.resolver.currentDependencies() self.repositories= naether.resolver.getRemoteRepositoryUrls() end |
- (Object) notation=(notation)
Set the Notation for this Project
64 65 66 |
# File 'lib/naether/maven.rb', line 64 def notation=(notation) @project.setProjectNotation( notation ) end |
- (Object) repositories=(repositories)
Set repositories
117 118 119 |
# File 'lib/naether/maven.rb', line 117 def repositories=( repositories ) @project.setRepositories( repositories ) end |
- (Object) version
Get the version
return [String] version
124 125 126 |
# File 'lib/naether/maven.rb', line 124 def version() return @project.getVersion() end |
- (Object) write_pom(file_path)
Write Maven Pom
145 146 147 |
# File 'lib/naether/maven.rb', line 145 def write_pom( file_path ) @project.writePom( file_path ) end |