buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From as...@apache.org
Subject svn commit: r645778 - in /incubator/buildr/trunk: addon/buildr/ lib/buildr/ lib/buildr/core/ lib/buildr/ide/ lib/buildr/java/ lib/buildr/packaging/ lib/buildr/tasks/
Date Tue, 08 Apr 2008 06:59:44 GMT
Author: assaf
Date: Mon Apr  7 23:59:39 2008
New Revision: 645778

URL: http://svn.apache.org/viewvc?rev=645778&view=rev
Log:
A bit more organization: consolidated generic packaging stuff in buildr/packaging, left only
Java-specific packaging in buildr/java.


Added:
    incubator/buildr/trunk/lib/buildr/packaging/
    incubator/buildr/trunk/lib/buildr/packaging.rb
    incubator/buildr/trunk/lib/buildr/packaging/artifact.rb
      - copied, changed from r645772, incubator/buildr/trunk/lib/buildr/java/artifact.rb
    incubator/buildr/trunk/lib/buildr/packaging/artifact_namespace.rb
      - copied unchanged from r645772, incubator/buildr/trunk/lib/buildr/java/artifact_namespace.rb
    incubator/buildr/trunk/lib/buildr/packaging/artifact_search.rb
      - copied unchanged from r645772, incubator/buildr/trunk/lib/buildr/java/artifact_search.rb
    incubator/buildr/trunk/lib/buildr/packaging/gems.rb
    incubator/buildr/trunk/lib/buildr/packaging/package.rb
      - copied, changed from r645772, incubator/buildr/trunk/lib/buildr/core/package.rb
    incubator/buildr/trunk/lib/buildr/packaging/tar.rb
      - copied, changed from r645772, incubator/buildr/trunk/lib/buildr/tasks/tar.rb
    incubator/buildr/trunk/lib/buildr/packaging/zip.rb
      - copied unchanged from r645772, incubator/buildr/trunk/lib/buildr/tasks/zip.rb
Removed:
    incubator/buildr/trunk/lib/buildr/core/addon.rb
    incubator/buildr/trunk/lib/buildr/core/package.rb
    incubator/buildr/trunk/lib/buildr/java/artifact.rb
    incubator/buildr/trunk/lib/buildr/java/artifact_namespace.rb
    incubator/buildr/trunk/lib/buildr/java/artifact_search.rb
    incubator/buildr/trunk/lib/buildr/tasks.rb
    incubator/buildr/trunk/lib/buildr/tasks/concat.rb
    incubator/buildr/trunk/lib/buildr/tasks/tar.rb
    incubator/buildr/trunk/lib/buildr/tasks/zip.rb
Modified:
    incubator/buildr/trunk/addon/buildr/jetty.rb
    incubator/buildr/trunk/lib/buildr/core.rb
    incubator/buildr/trunk/lib/buildr/core/common.rb
    incubator/buildr/trunk/lib/buildr/ide/eclipse.rb
    incubator/buildr/trunk/lib/buildr/ide/idea.rb
    incubator/buildr/trunk/lib/buildr/ide/idea7x.rb
    incubator/buildr/trunk/lib/buildr/java/compilers.rb
    incubator/buildr/trunk/lib/buildr/java/packaging.rb
    incubator/buildr/trunk/lib/buildr/java/pom.rb

Modified: incubator/buildr/trunk/addon/buildr/jetty.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/addon/buildr/jetty.rb?rev=645778&r1=645777&r2=645778&view=diff
==============================================================================
--- incubator/buildr/trunk/addon/buildr/jetty.rb (original)
+++ incubator/buildr/trunk/addon/buildr/jetty.rb Mon Apr  7 23:59:39 2008
@@ -18,7 +18,7 @@
 require 'net/http'
 require 'buildr/core/project'
 require 'buildr/java'
-require 'buildr/java/artifact'
+require 'buildr/packaging'
 require 'thread'
 
 

Modified: incubator/buildr/trunk/lib/buildr/core.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/core.rb?rev=645778&r1=645777&r2=645778&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/core.rb (original)
+++ incubator/buildr/trunk/lib/buildr/core.rb Mon Apr  7 23:59:39 2008
@@ -20,10 +20,8 @@
 require 'buildr/core/environment'
 require 'buildr/core/help'
 require 'buildr/core/build'
-require 'buildr/core/package'
 require 'buildr/core/filter'
 require 'buildr/core/compile'
 require 'buildr/core/test'
 require 'buildr/core/checks'
 require 'buildr/core/generate'
-require 'buildr/core/addon'

Modified: incubator/buildr/trunk/lib/buildr/core/common.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/core/common.rb?rev=645778&r1=645777&r2=645778&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/core/common.rb (original)
+++ incubator/buildr/trunk/lib/buildr/core/common.rb Mon Apr  7 23:59:39 2008
@@ -13,6 +13,8 @@
 # License for the specific language governing permissions and limitations under
 # the License.
 
+
+require 'rake'
 require 'tempfile'
 require 'open-uri'
 $LOADED_FEATURES << 'rubygems/open-uri.rb' # avoid loading rubygems' open-uri
@@ -118,6 +120,36 @@
 
   end
 
-end
+  # A file task that concatenates all its prerequisites to create a new file.
+  #
+  # For example:
+  #   concat("master.sql"=>["users.sql", "orders.sql", reports.sql"]
+  #
+  # See also Buildr#concat.
+  class ConcatTask < Rake::FileTask
+    def initialize(*args) #:nodoc:
+      super
+      enhance do |task|
+        content = prerequisites.inject("") do |content, prereq|
+          content << File.read(prereq.to_s) if File.exists?(prereq) && !File.directory?(prereq)
+          content
+        end
+        File.open(task.name, "wb") { |file| file.write content }
+      end
+    end
+  end
 
+  # :call-seq:
+  #    concat(target=>files) => task
+  #
+  # Creates and returns a file task that concatenates all its prerequisites to create
+  # a new file. See #ConcatTask.
+  #
+  # For example:
+  #   concat("master.sql"=>["users.sql", "orders.sql", reports.sql"]
+  def concat(args)
+    file, arg_names, deps = Buildr.application.resolve_args([args])
+    ConcatTask.define_task(File.expand_path(file)=>deps)
+  end
 
+end

Modified: incubator/buildr/trunk/lib/buildr/ide/eclipse.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/ide/eclipse.rb?rev=645778&r1=645777&r2=645778&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/ide/eclipse.rb (original)
+++ incubator/buildr/trunk/lib/buildr/ide/eclipse.rb Mon Apr  7 23:59:39 2008
@@ -15,7 +15,7 @@
 
 
 require 'buildr/core/project'
-require 'buildr/java/artifact'
+require 'buildr/packaging'
 
 
 module Buildr

Modified: incubator/buildr/trunk/lib/buildr/ide/idea.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/ide/idea.rb?rev=645778&r1=645777&r2=645778&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/ide/idea.rb (original)
+++ incubator/buildr/trunk/lib/buildr/ide/idea.rb Mon Apr  7 23:59:39 2008
@@ -15,7 +15,7 @@
 
 
 require 'buildr/core/project'
-require 'buildr/java/artifact'
+require 'buildr/packaging'
 require 'stringio'
 require 'rexml/document'
 

Modified: incubator/buildr/trunk/lib/buildr/ide/idea7x.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/ide/idea7x.rb?rev=645778&r1=645777&r2=645778&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/ide/idea7x.rb (original)
+++ incubator/buildr/trunk/lib/buildr/ide/idea7x.rb Mon Apr  7 23:59:39 2008
@@ -15,7 +15,7 @@
 
 
 require 'buildr/core/project'
-require 'buildr/java/artifact'
+require 'buildr/packaging'
 require 'stringio'
 require 'rexml/document'
 

Modified: incubator/buildr/trunk/lib/buildr/java/compilers.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/java/compilers.rb?rev=645778&r1=645777&r2=645778&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/java/compilers.rb (original)
+++ incubator/buildr/trunk/lib/buildr/java/compilers.rb Mon Apr  7 23:59:39 2008
@@ -17,7 +17,7 @@
 require 'buildr/core/project'
 require 'buildr/core/common'
 require 'buildr/core/compile'
-require 'buildr/java/artifact'
+require 'buildr/packaging'
 
 
 module Buildr

Modified: incubator/buildr/trunk/lib/buildr/java/packaging.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/java/packaging.rb?rev=645778&r1=645777&r2=645778&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/java/packaging.rb (original)
+++ incubator/buildr/trunk/lib/buildr/java/packaging.rb Mon Apr  7 23:59:39 2008
@@ -14,9 +14,7 @@
 # the License.
 
 
-require 'buildr/core/package'
-require 'buildr/tasks/zip'
-require 'buildr/tasks/tar'
+require 'buildr/packaging'
 
 
 module Buildr

Modified: incubator/buildr/trunk/lib/buildr/java/pom.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/java/pom.rb?rev=645778&r1=645777&r2=645778&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/java/pom.rb (original)
+++ incubator/buildr/trunk/lib/buildr/java/pom.rb Mon Apr  7 23:59:39 2008
@@ -15,7 +15,7 @@
 
 
 require 'xmlsimple'
-require 'buildr/java/artifact'
+require 'buildr/packaging'
 
 
 module Buildr

Added: incubator/buildr/trunk/lib/buildr/packaging.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/packaging.rb?rev=645778&view=auto
==============================================================================
--- incubator/buildr/trunk/lib/buildr/packaging.rb (added)
+++ incubator/buildr/trunk/lib/buildr/packaging.rb Mon Apr  7 23:59:39 2008
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
+require 'buildr/packaging/zip'
+require 'buildr/packaging/tar'
+require 'buildr/packaging/artifact'
+require 'buildr/packaging/package'
+require 'buildr/packaging/gems'

Copied: incubator/buildr/trunk/lib/buildr/packaging/artifact.rb (from r645772, incubator/buildr/trunk/lib/buildr/java/artifact.rb)
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/packaging/artifact.rb?p2=incubator/buildr/trunk/lib/buildr/packaging/artifact.rb&p1=incubator/buildr/trunk/lib/buildr/java/artifact.rb&r1=645772&r2=645778&rev=645778&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/java/artifact.rb (original)
+++ incubator/buildr/trunk/lib/buildr/packaging/artifact.rb Mon Apr  7 23:59:39 2008
@@ -17,7 +17,7 @@
 require 'builder'
 require 'buildr/core/project'
 require 'buildr/core/transports'
-require 'buildr/java/artifact_namespace'
+require 'buildr/packaging/artifact_namespace'
 
 
 module Buildr

Added: incubator/buildr/trunk/lib/buildr/packaging/gems.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/packaging/gems.rb?rev=645778&view=auto
==============================================================================
--- incubator/buildr/trunk/lib/buildr/packaging/gems.rb (added)
+++ incubator/buildr/trunk/lib/buildr/packaging/gems.rb Mon Apr  7 23:59:39 2008
@@ -0,0 +1,98 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
+require 'buildr/packaging/package'
+require 'buildr/packaging/zip'
+require 'rubyforge'
+
+
+module Buildr
+
+  class PackageGemTask < ArchiveTask
+
+    def initialize(*args)
+      super
+      @spec = Gem::Specification.new
+    end
+
+    def spec
+      yield @spec if block_given?
+      @spec
+    end
+
+    def install
+      Util.ruby 'install', name, :command => 'gem', :sudo => true
+    end
+
+    def uninstall
+      Util.ruby 'uninstall', spec.name, '-v', spec.version.to_s, :command => 'gem', :sudo
=> true
+    end
+
+    def upload
+      rubyforge = RubyForge.new
+      rubyforge.login
+      #File.open('.changes', 'w'){|f| f.write(current)}
+      #rubyforge.userconfig.merge!('release_changes' => '.changes',  'preformatted' =>
true)
+      rubyforge.add_release spec.rubyforge_project.downcase, spec.name.downcase, spec.version,
package(:gem).to_s
+    end
+
+  private
+
+    def create_from(file_map)
+      spec.mark_version
+      spec.validate
+      Gem::Package.open(name, 'w', signer) do |pkg|
+        pkg.metadata = spec.to_yaml
+        file_map.each do |path, content|
+          next if content.nil? || File.directory?(content.to_s)
+          pkg.add_file_simple(path, File.stat(name).mode & 0777, File.size(content.to_s))
do |os|
+              os.write File.open(content.to_s, 'rb') { |f| f.read }
+          end
+        end
+      end
+    end
+
+    def signer
+      # TODO: implement.
+    end
+  end
+
+
+  module PackageAsGem
+
+    def package_as_gem(file_name) #:nodoc:
+      PackageGemTask.define_task(file_name).tap do |gem|
+        %{ lib test doc }.each do |dir|
+          gem.include :from=>_(dir), :path=>dir if File.directory?(_(dir))
+        end
+        gem.spec do |spec|
+          spec.name = id
+          spec.version = version
+          spec.summary = full_comment
+          spec.has_rdoc = true
+          spec.rdoc_options << '--title' << comment
+          spec.require_path = 'lib'
+        end
+      end
+    end
+
+  end
+
+  class Project
+    include PackageAsGem
+  end
+
+end

Copied: incubator/buildr/trunk/lib/buildr/packaging/package.rb (from r645772, incubator/buildr/trunk/lib/buildr/core/package.rb)
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/packaging/package.rb?p2=incubator/buildr/trunk/lib/buildr/packaging/package.rb&p1=incubator/buildr/trunk/lib/buildr/core/package.rb&r1=645772&r2=645778&rev=645778&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/core/package.rb (original)
+++ incubator/buildr/trunk/lib/buildr/packaging/package.rb Mon Apr  7 23:59:39 2008
@@ -16,7 +16,7 @@
 
 require 'buildr/core/project'
 require 'buildr/core/compile'
-require 'buildr/java/artifact'
+require 'buildr/packaging/artifact'
 
 
 module Buildr

Copied: incubator/buildr/trunk/lib/buildr/packaging/tar.rb (from r645772, incubator/buildr/trunk/lib/buildr/tasks/tar.rb)
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/packaging/tar.rb?p2=incubator/buildr/trunk/lib/buildr/packaging/tar.rb&p1=incubator/buildr/trunk/lib/buildr/tasks/tar.rb&r1=645772&r2=645778&rev=645778&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/tasks/tar.rb (original)
+++ incubator/buildr/trunk/lib/buildr/packaging/tar.rb Mon Apr  7 23:59:39 2008
@@ -14,7 +14,7 @@
 # the License.
 
 
-require 'buildr/tasks/zip'
+require 'buildr/packaging/zip'
 require 'archive/tar/minitar'
 
 



Mime
View raw message