Class: Buildr4OSGi::P2::UpdateSitePublisherTask

Inherits:
Buildr::Packaging::Java::JarTask
  • Object
show all
Defined in:
lib/buildr4osgi/eclipse/p2.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ UpdateSitePublisherTask

:nodoc:



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/buildr4osgi/eclipse/p2.rb', line 36

def initialize(*args) #:nodoc:
  super
  
  enhance do |p2_task|
    if @site.nil?
      @site = project.package(:site)
    end
    fail "The p2 task needs to be associated with a site " if @site.nil?
    p2_task.enhance [@site]
    #add a prerequisite to the list of prerequisites, gives a chance
    #for other prerequisites to be placed before this block is executed.
    p2_task.enhance do 
      targetP2Repo = File.join(project.base_dir, "target", "p2repository")
      mkpath targetP2Repo
      Buildr::unzip(targetP2Repo=>@site.to_s).extract
      eclipseSDK = Buildr::artifact("org.eclipse:eclipse-SDK:zip:3.6M3-win32")
      eclipseSDK.invoke
      Buildr::unzip(File.dirname(eclipseSDK.to_s) => eclipseSDK.to_s).extract

      launcherPlugin = Dir.glob("#{File.dirname(eclipseSDK.to_s)}/eclipse/plugins/org.eclipse.equinox.launcher_*")[0]

      cmdline = <<-CMD
      java -jar #{launcherPlugin} -application org.eclipse.equinox.p2.publisher.UpdateSitePublisher
      -metadataRepository file:#{targetP2Repo} 
      -artifactRepository file:#{targetP2Repo}
      -metadataRepositoryName #{project.name}_#{project.version}
      -artifactRepositoryName #{project.name}_#{project.version} 
      -source #{targetP2Repo} 
      -configs gtk.linux.x86 
      -publishArtifacts 
      -clean -consoleLog
      CMD
      info "Invoking P2's metadata generation: #{cmdline}"
      system cmdline.gsub(/\n/, "").gsub(/\s+/, " ")

      include targetP2Repo, :as => "."
    end
  end
end

Instance Attribute Details

#siteObject

Returns the value of attribute site.



34
35
36
# File 'lib/buildr4osgi/eclipse/p2.rb', line 34

def site
  @site
end

Instance Method Details

#with(options) ⇒ Object

:call-seq:

with(options) => self

Passes options to the task and returns self.



81
82
83
84
85
86
87
88
89
90
# File 'lib/buildr4osgi/eclipse/p2.rb', line 81

def with(options)
  options.each do |key, value|
    begin
      send "#{key}=", value
    rescue NoMethodError
      raise ArgumentError, "#{self.class.name} does not support the option #{key}"
    end
  end
  self
end