Class: JavaClass::Classpath::MavenArtefact
- Defined in:
- lib/javaclass/classpath/maven_artefact.rb
Overview
A reference to a Maven artefact. This is a group/artefact/version tuple that points to a single Jar in the Maven repository.
- Author
-
Peter Kofler
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#classpath ⇒ Object
Return this Maven artefact’s JavaClass::Classpath.
-
#download_if_needed ⇒ Object
Kind of hack function to call Maven to download the current artefact if it does not exist.
-
#initialize(group, name, version, title = nil) ⇒ MavenArtefact
constructor
Create a Maven artefact with given group , name and version .
-
#repository_path ⇒ Object
Return the Jar’s file path of this artefact inside ~/.m2/repository.
Constructor Details
#initialize(group, name, version, title = nil) ⇒ MavenArtefact
Create a Maven artefact with given group , name and version .
13 14 15 16 17 18 |
# File 'lib/javaclass/classpath/maven_artefact.rb', line 13 def initialize(group, name, version, title=nil) @group = group @name = name @version = version @title = title || make_title end |
Instance Attribute Details
#group ⇒ Object (readonly)
Returns the value of attribute group.
10 11 12 |
# File 'lib/javaclass/classpath/maven_artefact.rb', line 10 def group @group end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/javaclass/classpath/maven_artefact.rb', line 10 def name @name end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
10 11 12 |
# File 'lib/javaclass/classpath/maven_artefact.rb', line 10 def title @title end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
10 11 12 |
# File 'lib/javaclass/classpath/maven_artefact.rb', line 10 def version @version end |
Instance Method Details
#classpath ⇒ Object
Return this Maven artefact’s JavaClass::Classpath. This is a single Jar in the Maven repository.
28 29 30 31 32 |
# File 'lib/javaclass/classpath/maven_artefact.rb', line 28 def classpath cp = CompositeClasspath.new(basename) cp.add_file_name(repository_path) cp end |
#download_if_needed ⇒ Object
Kind of hack function to call Maven to download the current artefact if it does not exist.
21 22 23 24 25 |
# File 'lib/javaclass/classpath/maven_artefact.rb', line 21 def download_if_needed unless File.exist? repository_path puts `#{download_command}` end end |
#repository_path ⇒ Object
Return the Jar’s file path of this artefact inside ~/.m2/repository
35 36 37 |
# File 'lib/javaclass/classpath/maven_artefact.rb', line 35 def repository_path File.join(ENV['HOME'], '.m2', 'repository', @group.gsub(/\./, '/'), @name, @version, "#{basename}.jar" ) end |