buildr-gemjar 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.braids +8 -0
- data/.gitignore +5 -0
- data/.rvmrc +1 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +98 -0
- data/Rakefile +8 -0
- data/buildr-gemjar.gemspec +42 -0
- data/lib/buildr-gemjar.rb +162 -0
- data/lib/buildr-gemjar/version.rb +3 -0
- data/meta.rakefile +30 -0
- data/spec/buildr-gemjar/version_spec.rb +11 -0
- data/spec/buildr-gemjar_spec.rb +179 -0
- data/spec/repo_builder.rb +59 -0
- data/spec/spec_helper.rb +44 -0
- data/vendor/buildr/.gitignore +17 -0
- data/vendor/buildr/CHANGELOG +1283 -0
- data/vendor/buildr/Gemfile +4 -0
- data/vendor/buildr/LICENSE +176 -0
- data/vendor/buildr/NOTICE +26 -0
- data/vendor/buildr/README.rdoc +134 -0
- data/vendor/buildr/Rakefile +44 -0
- data/vendor/buildr/_buildr +35 -0
- data/vendor/buildr/_jbuildr +35 -0
- data/vendor/buildr/addon/buildr/antlr.rb +65 -0
- data/vendor/buildr/addon/buildr/bnd.rb +147 -0
- data/vendor/buildr/addon/buildr/cobertura.rb +22 -0
- data/vendor/buildr/addon/buildr/drb.rb +281 -0
- data/vendor/buildr/addon/buildr/emma.rb +22 -0
- data/vendor/buildr/addon/buildr/hibernate.rb +149 -0
- data/vendor/buildr/addon/buildr/javacc.rb +85 -0
- data/vendor/buildr/addon/buildr/jaxb_xjc.rb +72 -0
- data/vendor/buildr/addon/buildr/jdepend.rb +60 -0
- data/vendor/buildr/addon/buildr/jetty.rb +248 -0
- data/vendor/buildr/addon/buildr/jibx.rb +86 -0
- data/vendor/buildr/addon/buildr/nailgun.rb +221 -0
- data/vendor/buildr/addon/buildr/openjpa.rb +88 -0
- data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
- data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
- data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
- data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
- data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
- data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
- data/vendor/buildr/addon/buildr/protobuf.rb +88 -0
- data/vendor/buildr/addon/buildr/xmlbeans.rb +93 -0
- data/vendor/buildr/all-in-one/_buildr +19 -0
- data/vendor/buildr/all-in-one/buildr +368 -0
- data/vendor/buildr/all-in-one/buildr.cmd +1 -0
- data/vendor/buildr/bin/buildr +19 -0
- data/vendor/buildr/buildr.buildfile +58 -0
- data/vendor/buildr/buildr.gemspec +74 -0
- data/vendor/buildr/doc/_config.yml +1 -0
- data/vendor/buildr/doc/_layouts/default.html +90 -0
- data/vendor/buildr/doc/_layouts/preface.html +22 -0
- data/vendor/buildr/doc/artifacts.textile +217 -0
- data/vendor/buildr/doc/building.textile +276 -0
- data/vendor/buildr/doc/contributing.textile +268 -0
- data/vendor/buildr/doc/css/default.css +236 -0
- data/vendor/buildr/doc/css/print.css +101 -0
- data/vendor/buildr/doc/css/syntax.css +23 -0
- data/vendor/buildr/doc/download.textile +138 -0
- data/vendor/buildr/doc/extending.textile +212 -0
- data/vendor/buildr/doc/images/1442160941-frontcover.jpg +0 -0
- data/vendor/buildr/doc/images/asf-logo.gif +0 -0
- data/vendor/buildr/doc/images/asf-logo.png +0 -0
- data/vendor/buildr/doc/images/buildr-hires.png +0 -0
- data/vendor/buildr/doc/images/buildr.png +0 -0
- data/vendor/buildr/doc/images/favicon.png +0 -0
- data/vendor/buildr/doc/images/growl-icon.tiff +0 -0
- data/vendor/buildr/doc/images/note.png +0 -0
- data/vendor/buildr/doc/images/project-structure.png +0 -0
- data/vendor/buildr/doc/images/tip.png +0 -0
- data/vendor/buildr/doc/images/zbuildr.png +0 -0
- data/vendor/buildr/doc/images/zbuildr.tif +0 -0
- data/vendor/buildr/doc/index.textile +69 -0
- data/vendor/buildr/doc/installing.textile +284 -0
- data/vendor/buildr/doc/languages.textile +599 -0
- data/vendor/buildr/doc/mailing_lists.textile +29 -0
- data/vendor/buildr/doc/more_stuff.textile +845 -0
- data/vendor/buildr/doc/packaging.textile +618 -0
- data/vendor/buildr/doc/preface.textile +54 -0
- data/vendor/buildr/doc/projects.textile +276 -0
- data/vendor/buildr/doc/quick_start.textile +210 -0
- data/vendor/buildr/doc/releasing.textile +117 -0
- data/vendor/buildr/doc/scripts/buildr-git.rb +512 -0
- data/vendor/buildr/doc/scripts/gitflow.rb +296 -0
- data/vendor/buildr/doc/scripts/install-jruby.sh +44 -0
- data/vendor/buildr/doc/scripts/install-linux.sh +73 -0
- data/vendor/buildr/doc/scripts/install-osx.sh +52 -0
- data/vendor/buildr/doc/settings_profiles.textile +287 -0
- data/vendor/buildr/doc/testing.textile +247 -0
- data/vendor/buildr/etc/KEYS +189 -0
- data/vendor/buildr/lib/buildr.rb +44 -0
- data/vendor/buildr/lib/buildr/clojure.rb +34 -0
- data/vendor/buildr/lib/buildr/clojure/shell.rb +52 -0
- data/vendor/buildr/lib/buildr/core.rb +34 -0
- data/vendor/buildr/lib/buildr/core/application.rb +700 -0
- data/vendor/buildr/lib/buildr/core/build.rb +516 -0
- data/vendor/buildr/lib/buildr/core/cc.rb +166 -0
- data/vendor/buildr/lib/buildr/core/checks.rb +253 -0
- data/vendor/buildr/lib/buildr/core/common.rb +151 -0
- data/vendor/buildr/lib/buildr/core/compile.rb +622 -0
- data/vendor/buildr/lib/buildr/core/doc.rb +276 -0
- data/vendor/buildr/lib/buildr/core/environment.rb +129 -0
- data/vendor/buildr/lib/buildr/core/filter.rb +404 -0
- data/vendor/buildr/lib/buildr/core/generate.rb +197 -0
- data/vendor/buildr/lib/buildr/core/help.rb +119 -0
- data/vendor/buildr/lib/buildr/core/jrebel.rb +42 -0
- data/vendor/buildr/lib/buildr/core/linux.rb +30 -0
- data/vendor/buildr/lib/buildr/core/osx.rb +46 -0
- data/vendor/buildr/lib/buildr/core/progressbar.rb +161 -0
- data/vendor/buildr/lib/buildr/core/project.rb +975 -0
- data/vendor/buildr/lib/buildr/core/run.rb +43 -0
- data/vendor/buildr/lib/buildr/core/shell.rb +137 -0
- data/vendor/buildr/lib/buildr/core/test.rb +843 -0
- data/vendor/buildr/lib/buildr/core/transports.rb +565 -0
- data/vendor/buildr/lib/buildr/core/util.rb +537 -0
- data/vendor/buildr/lib/buildr/groovy.rb +20 -0
- data/vendor/buildr/lib/buildr/groovy/bdd.rb +106 -0
- data/vendor/buildr/lib/buildr/groovy/compiler.rb +153 -0
- data/vendor/buildr/lib/buildr/groovy/doc.rb +76 -0
- data/vendor/buildr/lib/buildr/groovy/shell.rb +57 -0
- data/vendor/buildr/lib/buildr/ide.rb +19 -0
- data/vendor/buildr/lib/buildr/ide/eclipse.rb +427 -0
- data/vendor/buildr/lib/buildr/ide/eclipse/java.rb +53 -0
- data/vendor/buildr/lib/buildr/ide/eclipse/plugin.rb +71 -0
- data/vendor/buildr/lib/buildr/ide/eclipse/scala.rb +68 -0
- data/vendor/buildr/lib/buildr/ide/idea.rb +576 -0
- data/vendor/buildr/lib/buildr/java.rb +25 -0
- data/vendor/buildr/lib/buildr/java/ant.rb +94 -0
- data/vendor/buildr/lib/buildr/java/bdd.rb +460 -0
- data/vendor/buildr/lib/buildr/java/cobertura.rb +297 -0
- data/vendor/buildr/lib/buildr/java/commands.rb +223 -0
- data/vendor/buildr/lib/buildr/java/compiler.rb +135 -0
- data/vendor/buildr/lib/buildr/java/deprecated.rb +141 -0
- data/vendor/buildr/lib/buildr/java/doc.rb +86 -0
- data/vendor/buildr/lib/buildr/java/ecj.rb +69 -0
- data/vendor/buildr/lib/buildr/java/emma.rb +244 -0
- data/vendor/buildr/lib/buildr/java/external.rb +73 -0
- data/vendor/buildr/lib/buildr/java/jruby.rb +122 -0
- data/vendor/buildr/lib/buildr/java/jtestr_result.rb +295 -0
- data/vendor/buildr/lib/buildr/java/jtestr_runner.rb.erb +116 -0
- data/vendor/buildr/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/vendor/buildr/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +142 -0
- data/vendor/buildr/lib/buildr/java/packaging.rb +734 -0
- data/vendor/buildr/lib/buildr/java/pom.rb +178 -0
- data/vendor/buildr/lib/buildr/java/rjb.rb +154 -0
- data/vendor/buildr/lib/buildr/java/test_result.rb +101 -0
- data/vendor/buildr/lib/buildr/java/tests.rb +362 -0
- data/vendor/buildr/lib/buildr/java/version_requirement.rb +172 -0
- data/vendor/buildr/lib/buildr/packaging.rb +25 -0
- data/vendor/buildr/lib/buildr/packaging/archive.rb +535 -0
- data/vendor/buildr/lib/buildr/packaging/artifact.rb +903 -0
- data/vendor/buildr/lib/buildr/packaging/artifact_namespace.rb +984 -0
- data/vendor/buildr/lib/buildr/packaging/artifact_search.rb +140 -0
- data/vendor/buildr/lib/buildr/packaging/gems.rb +105 -0
- data/vendor/buildr/lib/buildr/packaging/package.rb +249 -0
- data/vendor/buildr/lib/buildr/packaging/tar.rb +189 -0
- data/vendor/buildr/lib/buildr/packaging/version_requirement.rb +192 -0
- data/vendor/buildr/lib/buildr/packaging/zip.rb +178 -0
- data/vendor/buildr/lib/buildr/packaging/ziptask.rb +356 -0
- data/vendor/buildr/lib/buildr/resources/buildr.icns +0 -0
- data/vendor/buildr/lib/buildr/resources/completed.png +0 -0
- data/vendor/buildr/lib/buildr/resources/failed.png +0 -0
- data/vendor/buildr/lib/buildr/resources/icons-license.txt +17 -0
- data/vendor/buildr/lib/buildr/run.rb +195 -0
- data/vendor/buildr/lib/buildr/scala.rb +26 -0
- data/vendor/buildr/lib/buildr/scala/bdd.rb +118 -0
- data/vendor/buildr/lib/buildr/scala/compiler.rb +242 -0
- data/vendor/buildr/lib/buildr/scala/doc.rb +142 -0
- data/vendor/buildr/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
- data/vendor/buildr/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
- data/vendor/buildr/lib/buildr/scala/shell.rb +52 -0
- data/vendor/buildr/lib/buildr/scala/tests.rb +171 -0
- data/vendor/buildr/lib/buildr/shell.rb +185 -0
- data/vendor/buildr/lib/buildr/version.rb +18 -0
- data/vendor/buildr/rakelib/all-in-one.rake +113 -0
- data/vendor/buildr/rakelib/checks.rake +57 -0
- data/vendor/buildr/rakelib/doc.rake +137 -0
- data/vendor/buildr/rakelib/metrics.rake +39 -0
- data/vendor/buildr/rakelib/package.rake +73 -0
- data/vendor/buildr/rakelib/release.rake +161 -0
- data/vendor/buildr/rakelib/rspec.rake +101 -0
- data/vendor/buildr/rakelib/setup.rake +66 -0
- data/vendor/buildr/rakelib/stage.rake +220 -0
- data/vendor/buildr/spec/addon/bnd_spec.rb +330 -0
- data/vendor/buildr/spec/addon/drb_spec.rb +328 -0
- data/vendor/buildr/spec/addon/jaxb_xjc_spec.rb +125 -0
- data/vendor/buildr/spec/core/application_spec.rb +631 -0
- data/vendor/buildr/spec/core/build_spec.rb +837 -0
- data/vendor/buildr/spec/core/cc_spec.rb +224 -0
- data/vendor/buildr/spec/core/checks_spec.rb +519 -0
- data/vendor/buildr/spec/core/common_spec.rb +725 -0
- data/vendor/buildr/spec/core/compile_spec.rb +658 -0
- data/vendor/buildr/spec/core/doc_spec.rb +195 -0
- data/vendor/buildr/spec/core/extension_spec.rb +201 -0
- data/vendor/buildr/spec/core/generate_spec.rb +33 -0
- data/vendor/buildr/spec/core/project_spec.rb +772 -0
- data/vendor/buildr/spec/core/run_spec.rb +93 -0
- data/vendor/buildr/spec/core/shell_spec.rb +146 -0
- data/vendor/buildr/spec/core/test_spec.rb +1320 -0
- data/vendor/buildr/spec/core/transport_spec.rb +544 -0
- data/vendor/buildr/spec/core/util_spec.rb +141 -0
- data/vendor/buildr/spec/groovy/bdd_spec.rb +80 -0
- data/vendor/buildr/spec/groovy/compiler_spec.rb +251 -0
- data/vendor/buildr/spec/groovy/doc_spec.rb +65 -0
- data/vendor/buildr/spec/ide/eclipse_spec.rb +739 -0
- data/vendor/buildr/spec/ide/idea_spec.rb +1144 -0
- data/vendor/buildr/spec/java/ant_spec.rb +37 -0
- data/vendor/buildr/spec/java/bdd_spec.rb +374 -0
- data/vendor/buildr/spec/java/cobertura_spec.rb +112 -0
- data/vendor/buildr/spec/java/commands_spec.rb +93 -0
- data/vendor/buildr/spec/java/compiler_spec.rb +252 -0
- data/vendor/buildr/spec/java/doc_spec.rb +56 -0
- data/vendor/buildr/spec/java/ecj_spec.rb +115 -0
- data/vendor/buildr/spec/java/emma_spec.rb +121 -0
- data/vendor/buildr/spec/java/external_spec.rb +56 -0
- data/vendor/buildr/spec/java/java_spec.rb +132 -0
- data/vendor/buildr/spec/java/packaging_spec.rb +1270 -0
- data/vendor/buildr/spec/java/run_spec.rb +78 -0
- data/vendor/buildr/spec/java/test_coverage_helper.rb +257 -0
- data/vendor/buildr/spec/java/tests_spec.rb +497 -0
- data/vendor/buildr/spec/packaging/archive_spec.rb +775 -0
- data/vendor/buildr/spec/packaging/artifact_namespace_spec.rb +743 -0
- data/vendor/buildr/spec/packaging/artifact_spec.rb +1066 -0
- data/vendor/buildr/spec/packaging/packaging_helper.rb +63 -0
- data/vendor/buildr/spec/packaging/packaging_spec.rb +719 -0
- data/vendor/buildr/spec/sandbox.rb +165 -0
- data/vendor/buildr/spec/scala/bdd_spec.rb +124 -0
- data/vendor/buildr/spec/scala/compiler_spec.rb +289 -0
- data/vendor/buildr/spec/scala/doc_spec.rb +88 -0
- data/vendor/buildr/spec/scala/scala.rb +38 -0
- data/vendor/buildr/spec/scala/tests_spec.rb +283 -0
- data/vendor/buildr/spec/spec_helpers.rb +369 -0
- data/vendor/buildr/spec/version_requirement_spec.rb +143 -0
- data/vendor/buildr/spec/xpath_matchers.rb +121 -0
- data/vendor/buildr/tests/BUILDR-320/Buildfile +29 -0
- data/vendor/buildr/tests/JavaSystemProperty/Buildfile +18 -0
- data/vendor/buildr/tests/JavaSystemProperty/src/test/java/FooTest.java +24 -0
- data/vendor/buildr/tests/compile_with_parent/Buildfile +18 -0
- data/vendor/buildr/tests/compile_with_parent/child/src/main/java/Foo.java +23 -0
- data/vendor/buildr/tests/helloWorld/Buildfile +20 -0
- data/vendor/buildr/tests/helloWorld/src/main/java/HelloWorld.java +23 -0
- data/vendor/buildr/tests/integration_testing.rb +56 -0
- data/vendor/buildr/tests/junit3/Buildfile +9 -0
- data/vendor/buildr/tests/junit3/src/main/java/Foo.java +23 -0
- data/vendor/buildr/tests/junit3/src/test/java/FooTest.java +28 -0
- data/vendor/buildr/tests/package_war_as_jar/Buildfile +15 -0
- data/vendor/buildr/tests/package_war_as_jar/src/main/java/Foo.java +19 -0
- metadata +524 -0
@@ -0,0 +1,356 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
|
17
|
+
require 'buildr/packaging/archive'
|
18
|
+
|
19
|
+
|
20
|
+
module Buildr
|
21
|
+
|
22
|
+
# The ZipTask creates a new Zip file. You can include any number of files and and directories,
|
23
|
+
# use exclusion patterns, and include files into specific directories.
|
24
|
+
#
|
25
|
+
# For example:
|
26
|
+
# zip('test.zip').tap do |task|
|
27
|
+
# task.include 'srcs'
|
28
|
+
# task.include 'README', 'LICENSE'
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# See Buildr#zip and ArchiveTask.
|
32
|
+
class ZipTask < ArchiveTask
|
33
|
+
|
34
|
+
# Compression leve for this Zip.
|
35
|
+
attr_accessor :compression_level
|
36
|
+
|
37
|
+
def initialize(*args) #:nodoc:
|
38
|
+
self.compression_level = Zlib::DEFAULT_COMPRESSION
|
39
|
+
super
|
40
|
+
end
|
41
|
+
|
42
|
+
# :call-seq:
|
43
|
+
# entry(name) => Entry
|
44
|
+
#
|
45
|
+
# Returns a ZIP file entry. You can use this to check if the entry exists and its contents,
|
46
|
+
# for example:
|
47
|
+
# package(:jar).entry("META-INF/LICENSE").should contain(/Apache Software License/)
|
48
|
+
def entry(entry_name)
|
49
|
+
::Zip::ZipEntry.new(name, entry_name)
|
50
|
+
end
|
51
|
+
|
52
|
+
def entries #:nodoc:
|
53
|
+
@entries ||= Zip::ZipFile.open(name) { |zip| zip.entries }
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def create_from(file_map)
|
59
|
+
Zip::ZipOutputStream.open name do |zip|
|
60
|
+
seen = {}
|
61
|
+
mkpath = lambda do |dir|
|
62
|
+
dirname = (dir[-1..-1] =~ /\/$/) ? dir : dir + '/'
|
63
|
+
unless dir == '.' || seen[dirname]
|
64
|
+
mkpath.call File.dirname(dirname)
|
65
|
+
zip.put_next_entry(dirname, compression_level)
|
66
|
+
seen[dirname] = true
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
file_map.each do |path, content|
|
71
|
+
warn "Warning: Path in zipfile #{name} contains backslash: #{path}" if path =~ /\\/
|
72
|
+
mkpath.call File.dirname(path)
|
73
|
+
if content.respond_to?(:call)
|
74
|
+
zip.put_next_entry(path, compression_level)
|
75
|
+
content.call zip
|
76
|
+
elsif content.nil? || File.directory?(content.to_s)
|
77
|
+
mkpath.call path
|
78
|
+
else
|
79
|
+
entry = zip.put_next_entry(path, compression_level)
|
80
|
+
File.open content.to_s, 'rb' do |is|
|
81
|
+
entry.unix_perms = is.stat.mode & 07777
|
82
|
+
while data = is.read(4096)
|
83
|
+
zip << data
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
# :call-seq:
|
95
|
+
# zip(file) => ZipTask
|
96
|
+
#
|
97
|
+
# The ZipTask creates a new Zip file. You can include any number of files and
|
98
|
+
# and directories, use exclusion patterns, and include files into specific
|
99
|
+
# directories.
|
100
|
+
#
|
101
|
+
# For example:
|
102
|
+
# zip('test.zip').tap do |task|
|
103
|
+
# task.include 'srcs'
|
104
|
+
# task.include 'README', 'LICENSE'
|
105
|
+
# end
|
106
|
+
def zip(file)
|
107
|
+
ZipTask.define_task(file)
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
# An object for unzipping/untarring a file into a target directory. You can tell it to include
|
112
|
+
# or exclude only specific files and directories, and also to map files from particular
|
113
|
+
# paths inside the zip file into the target directory. Once ready, call #extract.
|
114
|
+
#
|
115
|
+
# Usually it is more convenient to create a file task for extracting the zip file
|
116
|
+
# (see #unzip) and pass this object as a prerequisite to other tasks.
|
117
|
+
#
|
118
|
+
# See Buildr#unzip.
|
119
|
+
class Unzip
|
120
|
+
|
121
|
+
# The zip file to extract.
|
122
|
+
attr_accessor :zip_file
|
123
|
+
# The target directory to extract to.
|
124
|
+
attr_accessor :target
|
125
|
+
|
126
|
+
# Initialize with hash argument of the form target=>zip_file.
|
127
|
+
def initialize(args)
|
128
|
+
@target, arg_names, zip_file = Buildr.application.resolve_args([args])
|
129
|
+
@zip_file = zip_file.first
|
130
|
+
@paths = {}
|
131
|
+
end
|
132
|
+
|
133
|
+
# :call-seq:
|
134
|
+
# extract
|
135
|
+
#
|
136
|
+
# Extract the zip/tgz file into the target directory.
|
137
|
+
#
|
138
|
+
# You can call this method directly. However, if you are using the #unzip method,
|
139
|
+
# it creates a file task for the target directory: use that task instead as a
|
140
|
+
# prerequisite. For example:
|
141
|
+
# build unzip(dir=>zip_file)
|
142
|
+
# Or:
|
143
|
+
# unzip(dir=>zip_file).target.invoke
|
144
|
+
def extract
|
145
|
+
# If no paths specified, then no include/exclude patterns
|
146
|
+
# specified. Nothing will happen unless we include all files.
|
147
|
+
if @paths.empty?
|
148
|
+
@paths[nil] = FromPath.new(self, nil)
|
149
|
+
end
|
150
|
+
|
151
|
+
# Otherwise, empty unzip creates target as a file when touching.
|
152
|
+
mkpath target.to_s
|
153
|
+
if zip_file.to_s.match /\.t?gz$/
|
154
|
+
#un-tar.gz
|
155
|
+
Zlib::GzipReader.open(zip_file.to_s) { |tar|
|
156
|
+
Archive::Tar::Minitar::Input.open(tar) do |inp|
|
157
|
+
inp.each do |tar_entry|
|
158
|
+
@paths.each do |path, patterns|
|
159
|
+
patterns.map([tar_entry]).each do |dest, entry|
|
160
|
+
next if entry.directory?
|
161
|
+
dest = File.expand_path(dest, target.to_s)
|
162
|
+
trace "Extracting #{dest}"
|
163
|
+
mkpath File.dirname(dest) rescue nil
|
164
|
+
#entry.restore_permissions = true
|
165
|
+
File.open(dest, 'wb') {|f| f.write entry.read}
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
}
|
171
|
+
else
|
172
|
+
Zip::ZipFile.open(zip_file.to_s) do |zip|
|
173
|
+
entries = zip.collect
|
174
|
+
@paths.each do |path, patterns|
|
175
|
+
patterns.map(entries).each do |dest, entry|
|
176
|
+
next if entry.directory?
|
177
|
+
dest = File.expand_path(dest, target.to_s)
|
178
|
+
trace "Extracting #{dest}"
|
179
|
+
mkpath File.dirname(dest) rescue nil
|
180
|
+
entry.restore_permissions = true
|
181
|
+
entry.extract(dest) { true }
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
# Let other tasks know we updated the target directory.
|
187
|
+
touch target.to_s
|
188
|
+
end
|
189
|
+
|
190
|
+
#reads the includes/excludes and apply them to the entry_name
|
191
|
+
def included?(entry_name)
|
192
|
+
@paths.each do |path, patterns|
|
193
|
+
return true if path.nil?
|
194
|
+
if entry_name =~ /^#{path}/
|
195
|
+
short = entry_name.sub(path, '')
|
196
|
+
if patterns.include.any? { |pattern| File.fnmatch(pattern, entry_name) } &&
|
197
|
+
!patterns.exclude.any? { |pattern| File.fnmatch(pattern, entry_name) }
|
198
|
+
# trace "tar_entry.full_name " + entry_name + " is included"
|
199
|
+
return true
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
# trace "tar_entry.full_name " + entry_name + " is excluded"
|
204
|
+
return false
|
205
|
+
end
|
206
|
+
|
207
|
+
|
208
|
+
# :call-seq:
|
209
|
+
# include(*files) => self
|
210
|
+
# include(*files, :path=>name) => self
|
211
|
+
#
|
212
|
+
# Include all files that match the patterns and returns self.
|
213
|
+
#
|
214
|
+
# Use include if you only want to unzip some of the files, by specifying
|
215
|
+
# them instead of using exclusion. You can use #include in combination
|
216
|
+
# with #exclude.
|
217
|
+
def include(*files)
|
218
|
+
if Hash === files.last
|
219
|
+
from_path(files.pop[:path]).include *files
|
220
|
+
else
|
221
|
+
from_path(nil).include *files
|
222
|
+
end
|
223
|
+
self
|
224
|
+
end
|
225
|
+
alias :add :include
|
226
|
+
|
227
|
+
# :call-seq:
|
228
|
+
# exclude(*files) => self
|
229
|
+
#
|
230
|
+
# Exclude all files that match the patterns and return self.
|
231
|
+
#
|
232
|
+
# Use exclude to unzip all files except those that match the pattern.
|
233
|
+
# You can use #exclude in combination with #include.
|
234
|
+
def exclude(*files)
|
235
|
+
if Hash === files.last
|
236
|
+
from_path(files.pop[:path]).exclude *files
|
237
|
+
else
|
238
|
+
from_path(nil).exclude *files
|
239
|
+
end
|
240
|
+
self
|
241
|
+
end
|
242
|
+
|
243
|
+
# :call-seq:
|
244
|
+
# from_path(name) => Path
|
245
|
+
#
|
246
|
+
# Allows you to unzip from a path. Returns an object you can use to
|
247
|
+
# specify which files to include/exclude relative to that path.
|
248
|
+
# Expands the file relative to that path.
|
249
|
+
#
|
250
|
+
# For example:
|
251
|
+
# unzip(Dir.pwd=>'test.jar').from_path('etc').include('LICENSE')
|
252
|
+
# will unzip etc/LICENSE into ./LICENSE.
|
253
|
+
#
|
254
|
+
# This is different from:
|
255
|
+
# unzip(Dir.pwd=>'test.jar').include('etc/LICENSE')
|
256
|
+
# which unzips etc/LICENSE into ./etc/LICENSE.
|
257
|
+
def from_path(name)
|
258
|
+
@paths[name] ||= FromPath.new(self, name)
|
259
|
+
end
|
260
|
+
alias :path :from_path
|
261
|
+
|
262
|
+
# :call-seq:
|
263
|
+
# root => Unzip
|
264
|
+
#
|
265
|
+
# Returns the root path, essentially the Unzip object itself. In case you are wondering
|
266
|
+
# down paths and want to go back.
|
267
|
+
def root
|
268
|
+
self
|
269
|
+
end
|
270
|
+
|
271
|
+
# Returns the path to the target directory.
|
272
|
+
def to_s
|
273
|
+
target.to_s
|
274
|
+
end
|
275
|
+
|
276
|
+
class FromPath #:nodoc:
|
277
|
+
|
278
|
+
def initialize(unzip, path)
|
279
|
+
@unzip = unzip
|
280
|
+
if path
|
281
|
+
@path = path[-1] == ?/ ? path : path + '/'
|
282
|
+
else
|
283
|
+
@path = ''
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
# See UnzipTask#include
|
288
|
+
def include(*files) #:doc:
|
289
|
+
@include ||= []
|
290
|
+
@include |= files
|
291
|
+
self
|
292
|
+
end
|
293
|
+
|
294
|
+
# See UnzipTask#exclude
|
295
|
+
def exclude(*files) #:doc:
|
296
|
+
@exclude ||= []
|
297
|
+
@exclude |= files
|
298
|
+
self
|
299
|
+
end
|
300
|
+
|
301
|
+
def map(entries)
|
302
|
+
includes = @include || ['*']
|
303
|
+
excludes = @exclude || []
|
304
|
+
entries.inject({}) do |map, entry|
|
305
|
+
if entry.name =~ /^#{@path}/
|
306
|
+
short = entry.name.sub(@path, '')
|
307
|
+
if includes.any? { |pat| File.fnmatch(pat, short) } &&
|
308
|
+
!excludes.any? { |pat| File.fnmatch(pat, short) }
|
309
|
+
map[short] = entry
|
310
|
+
end
|
311
|
+
end
|
312
|
+
map
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
# Documented in Unzip.
|
317
|
+
def root
|
318
|
+
@unzip
|
319
|
+
end
|
320
|
+
|
321
|
+
# The target directory to extract to.
|
322
|
+
def target
|
323
|
+
@unzip.target
|
324
|
+
end
|
325
|
+
|
326
|
+
end
|
327
|
+
|
328
|
+
end
|
329
|
+
|
330
|
+
# :call-seq:
|
331
|
+
# unzip(to_dir=>zip_file) => Zip
|
332
|
+
#
|
333
|
+
# Creates a task that will unzip a file into the target directory. The task name
|
334
|
+
# is the target directory, the prerequisite is the file to unzip.
|
335
|
+
#
|
336
|
+
# This method creates a file task to expand the zip file. It returns an Unzip object
|
337
|
+
# that specifies how the file will be extracted. You can include or exclude specific
|
338
|
+
# files from within the zip, and map to different paths.
|
339
|
+
#
|
340
|
+
# The Unzip object's to_s method return the path to the target directory, so you can
|
341
|
+
# use it as a prerequisite. By keeping the Unzip object separate from the file task,
|
342
|
+
# you overlay additional work on top of the file task.
|
343
|
+
#
|
344
|
+
# For example:
|
345
|
+
# unzip('all'=>'test.zip')
|
346
|
+
# unzip('src'=>'test.zip').include('README', 'LICENSE')
|
347
|
+
# unzip('libs'=>'test.zip').from_path('libs')
|
348
|
+
def unzip(args)
|
349
|
+
target, arg_names, zip_file = Buildr.application.resolve_args([args])
|
350
|
+
task = file(File.expand_path(target.to_s)=>zip_file)
|
351
|
+
Unzip.new(task=>zip_file).tap do |setup|
|
352
|
+
task.enhance { setup.extract }
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
MouseRunner.com Green/Red icons
|
3
|
+
-------------------------------
|
4
|
+
|
5
|
+
The graphics contained in the 'completed.png' and 'failed.png' files are
|
6
|
+
licensed under the Creative Commons Attribution-ShareAlike 2.5 License
|
7
|
+
|
8
|
+
Furthermore,
|
9
|
+
You may not claim the works as your own.
|
10
|
+
You must provide a link back to www.MouseRunner.com when using on a website,
|
11
|
+
for commercial purposes, and for applications.
|
12
|
+
|
13
|
+
Visit the address below to learn more about the Creative Commons license.
|
14
|
+
http://creativecommons.org/licenses/by-nc-sa/2.5/legalcode
|
15
|
+
|
16
|
+
|
17
|
+
|
@@ -0,0 +1,195 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
|
17
|
+
module Buildr
|
18
|
+
module Run
|
19
|
+
include Extension
|
20
|
+
|
21
|
+
class << self
|
22
|
+
def runners
|
23
|
+
@runners ||= []
|
24
|
+
end
|
25
|
+
|
26
|
+
def select_by_lang(lang)
|
27
|
+
fail 'Unable to define run task for nil language' if lang.nil?
|
28
|
+
runners.detect { |e| e.languages.nil? ? false : e.languages.include?(lang.to_sym) }
|
29
|
+
end
|
30
|
+
|
31
|
+
alias_method :select, :select_by_lang
|
32
|
+
|
33
|
+
def select_by_name(name)
|
34
|
+
fail 'Unable to define run task for nil' if name.nil?
|
35
|
+
runners.detect { |e| e.to_sym == name.to_sym }
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
# Base class for any run provider. Defines most
|
41
|
+
# common functionality (things like @lang@, @build?@ and friends).
|
42
|
+
class Base
|
43
|
+
attr_reader :project
|
44
|
+
|
45
|
+
class << self
|
46
|
+
attr_accessor :runner_name, :languages
|
47
|
+
|
48
|
+
def specify(options)
|
49
|
+
@runner_name ||= options[:name]
|
50
|
+
@languages ||= options[:languages]
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_sym
|
54
|
+
@runner_name || name.split('::').last.downcase.to_sym
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def initialize(project)
|
59
|
+
@project = project
|
60
|
+
end
|
61
|
+
|
62
|
+
def build?
|
63
|
+
true
|
64
|
+
end
|
65
|
+
|
66
|
+
def launch
|
67
|
+
fail 'Not implemented'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
class RunTask < Rake::Task
|
72
|
+
# Classpath dependencies.
|
73
|
+
attr_accessor :classpath
|
74
|
+
|
75
|
+
# Returns the run options.
|
76
|
+
attr_reader :options
|
77
|
+
|
78
|
+
# Returns file dependencies
|
79
|
+
attr_reader :files
|
80
|
+
|
81
|
+
attr_reader :project # :nodoc:
|
82
|
+
|
83
|
+
def initialize(*args) # :nodoc:
|
84
|
+
super
|
85
|
+
@options = {}
|
86
|
+
@classpath = []
|
87
|
+
@files = FileList[]
|
88
|
+
end
|
89
|
+
|
90
|
+
# :call-seq:
|
91
|
+
# with(*artifacts) => self
|
92
|
+
#
|
93
|
+
# Adds files and artifacts as classpath dependencies, and returns self.
|
94
|
+
def with(*specs)
|
95
|
+
@classpath |= Buildr.artifacts(specs.flatten).uniq
|
96
|
+
self
|
97
|
+
end
|
98
|
+
|
99
|
+
# :call-seq:
|
100
|
+
# using(options) => self
|
101
|
+
#
|
102
|
+
# Sets the run options from a hash and returns self.
|
103
|
+
#
|
104
|
+
# For example:
|
105
|
+
# run.using :main=>'org.example.Main'
|
106
|
+
def using(*args)
|
107
|
+
args.pop.each { |key, value| @options[key.to_sym] = value } if Hash === args.last
|
108
|
+
|
109
|
+
until args.empty?
|
110
|
+
new_runner = Run.select_by_name(args.pop)
|
111
|
+
@runner = new_runner.new(project) unless new_runner.nil?
|
112
|
+
end
|
113
|
+
|
114
|
+
self
|
115
|
+
end
|
116
|
+
|
117
|
+
# :call-seq:
|
118
|
+
# requires(*files) => self
|
119
|
+
#
|
120
|
+
# Adds additional files and directories as dependencies to the task and returns self.
|
121
|
+
# When specifying a directory, includes all files in that directory.
|
122
|
+
def requires(*files)
|
123
|
+
@files.include *files.flatten.compact
|
124
|
+
self
|
125
|
+
end
|
126
|
+
|
127
|
+
def runner
|
128
|
+
@runner ||= guess_runner
|
129
|
+
end
|
130
|
+
|
131
|
+
def runner?
|
132
|
+
@runner ||= begin
|
133
|
+
guess_runner if project.compile.language
|
134
|
+
rescue
|
135
|
+
nil
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def run
|
140
|
+
runner.run(self) if runner?
|
141
|
+
end
|
142
|
+
|
143
|
+
def prerequisites #:nodoc:
|
144
|
+
super + @files + classpath
|
145
|
+
end
|
146
|
+
|
147
|
+
private
|
148
|
+
|
149
|
+
def guess_runner
|
150
|
+
runner = Run.select project.compile.language
|
151
|
+
fail 'Unable to guess runner for project.' unless runner
|
152
|
+
runner.new project
|
153
|
+
end
|
154
|
+
|
155
|
+
def associate_with(project)
|
156
|
+
@project ||= project
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
first_time do
|
161
|
+
Project.local_task 'run'
|
162
|
+
end
|
163
|
+
|
164
|
+
before_define(:run => :test) do |project|
|
165
|
+
RunTask.define_task('run').tap do |run|
|
166
|
+
run.send(:associate_with, project)
|
167
|
+
run.enhance([project.compile, project.test]) do |t|
|
168
|
+
# double-enhance to execute the runner last
|
169
|
+
run.enhance { |t| t.run }
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
after_define(:run => :test) do |project|
|
175
|
+
project.run.with project.test.compile.dependencies
|
176
|
+
project.run.with project.test.compile.target if project.test.compile.target
|
177
|
+
end
|
178
|
+
|
179
|
+
# :call-seq:
|
180
|
+
# run(&block) => RunTask
|
181
|
+
#
|
182
|
+
# This method returns the project's run task. It also accepts a block to be executed
|
183
|
+
# when the run task is invoked.
|
184
|
+
def run(&block)
|
185
|
+
task('run').tap do |t|
|
186
|
+
t.enhance &block if block
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
class Project
|
193
|
+
include Run
|
194
|
+
end
|
195
|
+
end
|