ivy4r 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +12 -0
- data/Manifest.txt +36 -0
- data/README.txt +92 -0
- data/Rakefile +25 -0
- data/bin/ivy4r +3 -0
- data/lib/buildr/ivy_extension.rb +566 -0
- data/lib/ivy/artifactproperty.rb +34 -0
- data/lib/ivy/artifactreport.rb +24 -0
- data/lib/ivy/buildlist.rb +37 -0
- data/lib/ivy/buildnumber.rb +34 -0
- data/lib/ivy/cachepath.rb +30 -0
- data/lib/ivy/cleancache.rb +20 -0
- data/lib/ivy/configure.rb +29 -0
- data/lib/ivy/findrevision.rb +34 -0
- data/lib/ivy/info.rb +36 -0
- data/lib/ivy/listmodules.rb +35 -0
- data/lib/ivy/makepom.rb +23 -0
- data/lib/ivy/publish.rb +37 -0
- data/lib/ivy/report.rb +33 -0
- data/lib/ivy/resolve.rb +44 -0
- data/lib/ivy/retrieve.rb +27 -0
- data/lib/ivy/settings.rb +15 -0
- data/lib/ivy/target.rb +128 -0
- data/lib/ivy/targets.rb +49 -0
- data/lib/ivy4r.rb +176 -0
- data/test/buildlist/p1/buildfile +0 -0
- data/test/buildlist/p1/ivy.xml +7 -0
- data/test/buildlist/sub/p2/buildfile +0 -0
- data/test/buildlist/sub/p2/ivy.xml +11 -0
- data/test/buildlist/sub/p3/buildfile +0 -0
- data/test/buildlist/sub/p3/ivy.xml +11 -0
- data/test/ivy/ivysettings.xml +11 -0
- data/test/ivy/ivytest.xml +18 -0
- data/test/ivy/test_target.rb +97 -0
- data/test/ivy/test_targets.rb +36 -0
- data/test/test_ivy4r.rb +196 -0
- metadata +113 -0
data/lib/ivy4r.rb
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
require 'antwrap'
|
2
|
+
require 'ivy/targets'
|
3
|
+
|
4
|
+
class Ivy4r
|
5
|
+
VERSION = '0.2.0'
|
6
|
+
|
7
|
+
# Set the ant home directory to load ant classes from if no custom __antwrap__ is provided
|
8
|
+
attr_accessor :ant_home
|
9
|
+
|
10
|
+
# Defines the directory to load ivy libs and its dependencies from
|
11
|
+
attr_accessor :lib_dir
|
12
|
+
|
13
|
+
attr_accessor :project_dir
|
14
|
+
|
15
|
+
# To provide a custom __antwrap__ to use instead of default one
|
16
|
+
attr_writer :ant
|
17
|
+
|
18
|
+
def initialize(*opts)
|
19
|
+
@ant = opts[0] if opts.size == 1
|
20
|
+
raise "To many parameters to create Ivy4r use none, or 1 to set ANT!" if opts.size > 1
|
21
|
+
end
|
22
|
+
|
23
|
+
# Calls the __cleancache__ ivy target with given parameters.
|
24
|
+
def cleancache(*params)
|
25
|
+
Ivy::Cleancache.new(ant).execute(*params)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Calls the __settings__ ivy target with given parameters.
|
29
|
+
def settings(*params)
|
30
|
+
Ivy::Settings.new(ant).execute(*params)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Calls the __configure__ ivy target with given parameters.
|
34
|
+
def configure(*params)
|
35
|
+
Ivy::Configure.new(ant).execute(*params)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Calls the __info__ ivy target with given parameters and returns info as hash.
|
39
|
+
def info(*params)
|
40
|
+
Ivy::Info.new(ant).execute(*params)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Calls the __buildnumber__ ivy target with given parameters and returns info as hash.
|
44
|
+
def buildnumber(*params)
|
45
|
+
Ivy::Buildnumber.new(ant).execute(*params)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Calls the __listmodules__ ivy target with given parameters and returns info as hash.
|
49
|
+
def listmodules(*params) #:nodoc:
|
50
|
+
Ivy::Listmodules.new(ant).execute(*params)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Calls the __makepom__ ivy target with given parameters and returns pom content.
|
54
|
+
def makepom(*params)
|
55
|
+
Ivy::Makepom.new(ant).execute(*params)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Calls the __resolve__ ivy target with given parameters and returns info as hash.
|
59
|
+
def resolve(*params)
|
60
|
+
Ivy::Resolve.new(ant).execute(*params)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Calls the __retrieve__ ivy target with given parameters.
|
64
|
+
def retrieve(*params)
|
65
|
+
Ivy::Retrieve.new(ant).execute(*params)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Calls the __publish__ ivy target with given parameters.
|
69
|
+
def publish(*params)
|
70
|
+
Ivy::Publish.new(ant).execute(*params)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Calls the __cachepath__ ivy target with given parameters and returns
|
74
|
+
# array containing absolute file paths to all artifacts contained in result
|
75
|
+
def cachepath(*params)
|
76
|
+
Ivy::Cachepath.new(ant).execute(*params)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Calls the __findrevision__ ivy target with given parameters and returns
|
80
|
+
# array containing absolute file paths to all artifacts contained in result
|
81
|
+
def findrevision(*params)
|
82
|
+
Ivy::Findrevision.new(ant).execute(*params)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Calls the __artifactproperty__ ivy target with given parameters and returns
|
86
|
+
# map with all defined properties
|
87
|
+
def artifactproperty(*params)
|
88
|
+
Ivy::Artifactproperty.new(ant).execute(*params)
|
89
|
+
end
|
90
|
+
|
91
|
+
# Calls the __buildlist__ ivy target with given parameters and returns
|
92
|
+
# the resulting buildlist
|
93
|
+
def buildlist(*params)
|
94
|
+
Ivy::Buildlist.new(ant).execute(*params)
|
95
|
+
end
|
96
|
+
|
97
|
+
# Calls the __artifactreport__ ivy target with given parameters and returns
|
98
|
+
# the created xml.
|
99
|
+
def artifactreport(*params)
|
100
|
+
Ivy::Artifactreport.new(ant).execute(*params)
|
101
|
+
end
|
102
|
+
|
103
|
+
# Calls the __report__ ivy target with given parameters
|
104
|
+
def report(*params)
|
105
|
+
Ivy::Report.new(ant).execute(*params)
|
106
|
+
end
|
107
|
+
|
108
|
+
# Used to get or set an ant properties
|
109
|
+
# [set] <tt>property['name'] = value</tt> sets the ant property with name to given value no overwrite
|
110
|
+
# [get] <tt>property[matcher]/tt> gets property that is equal via case equality operator (+===+)
|
111
|
+
def property
|
112
|
+
AntPropertyHelper.new(ant_properties)
|
113
|
+
end
|
114
|
+
|
115
|
+
# Returns the __antwrap__ instance to use for all internal calls creates a default
|
116
|
+
# instance if no instance has been set before.
|
117
|
+
def ant
|
118
|
+
@ant ||= ::Antwrap::AntProject.new(:ant_home => ant_home, :name => "ivy-ant",
|
119
|
+
:basedir => Dir.pwd, :declarative => true)
|
120
|
+
init(@ant) if should_init?
|
121
|
+
@ant
|
122
|
+
end
|
123
|
+
|
124
|
+
private
|
125
|
+
def should_init?
|
126
|
+
@init_done.nil? || @init_done == false
|
127
|
+
end
|
128
|
+
|
129
|
+
def init(ant)
|
130
|
+
@init_done = true
|
131
|
+
ant.property :name => 'ivy.project.dir', :value => project_dir
|
132
|
+
ant.path :id => 'ivy.lib.path' do
|
133
|
+
ant.fileset :dir => lib_dir, :includes => '*.jar'
|
134
|
+
end
|
135
|
+
|
136
|
+
ant.typedef :name => "ivy_settings", :classname => "org.apache.ivy.ant.IvyAntSettings", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader', :loaderRef => 'ivy.lib.path.loader'
|
137
|
+
ant.taskdef :name => "ivy_configure", :classname => "org.apache.ivy.ant.IvyConfigure", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
138
|
+
ant.taskdef :name => "ivy_resolve", :classname => "org.apache.ivy.ant.IvyResolve", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
139
|
+
ant.taskdef :name => "ivy_retrieve", :classname => "org.apache.ivy.ant.IvyRetrieve", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
140
|
+
ant.taskdef :name => "ivy_deliver", :classname => "org.apache.ivy.ant.IvyDeliver", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
141
|
+
ant.taskdef :name => "ivy_publish", :classname => "org.apache.ivy.ant.IvyPublish", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
142
|
+
ant.taskdef :name => "ivy_extract", :classname => "org.apache.ivy.ant.IvyExtractFromSources", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
143
|
+
ant.taskdef :name => "ivy_cachepath", :classname => "org.apache.ivy.ant.IvyCachePath", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
144
|
+
ant.taskdef :name => "ivy_cachefileset", :classname => "org.apache.ivy.ant.IvyCacheFileset", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
145
|
+
ant.taskdef :name => "ivy_report", :classname => "org.apache.ivy.ant.IvyReport", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
146
|
+
ant.taskdef :name => "ivy_repreport", :classname => "org.apache.ivy.ant.IvyRepositoryReport", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
147
|
+
ant.taskdef :name => "ivy_var", :classname => "org.apache.ivy.ant.IvyVar", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
148
|
+
ant.taskdef :name => "ivy_check", :classname => "org.apache.ivy.ant.IvyCheck", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
149
|
+
ant.taskdef :name => "ivy_artifactproperty", :classname => "org.apache.ivy.ant.IvyArtifactProperty", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
150
|
+
ant.taskdef :name => "ivy_buildlist", :classname => "org.apache.ivy.ant.IvyBuildList", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
151
|
+
ant.taskdef :name => "ivy_install", :classname => "org.apache.ivy.ant.IvyInstall", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
152
|
+
ant.taskdef :name => "ivy_convertpom", :classname => "org.apache.ivy.ant.IvyConvertPom", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
153
|
+
ant.taskdef :name => "ivy_makepom", :classname => "org.apache.ivy.ant.IvyMakePom", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
154
|
+
ant.taskdef :name => "ivy_artifactreport", :classname => "org.apache.ivy.ant.IvyArtifactReport", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
155
|
+
ant.taskdef :name => "ivy_info", :classname => "org.apache.ivy.ant.IvyInfo", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
156
|
+
ant.taskdef :name => "ivy_addpath", :classname => "org.apache.ivy.ant.AddPathTask", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
157
|
+
ant.taskdef :name => "ivy_listmodules", :classname => "org.apache.ivy.ant.IvyListModules", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
158
|
+
ant.taskdef :name => "ivy_findrevision", :classname => "org.apache.ivy.ant.IvyFindRevision", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
159
|
+
ant.taskdef :name => "ivy_buildnumber", :classname => "org.apache.ivy.ant.IvyBuildNumber", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
160
|
+
ant.taskdef :name => "ivy_cleancache", :classname => "org.apache.ivy.ant.IvyCleanCache", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
161
|
+
end
|
162
|
+
|
163
|
+
def ant_properties
|
164
|
+
ant.project.properties
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
AntPropertyHelper = Struct.new(:ant_properties) do #:nodoc:
|
169
|
+
def []=(name, value) #:nodoc:
|
170
|
+
ant_properties[name] = value
|
171
|
+
end
|
172
|
+
|
173
|
+
def [](matcher) #:nodoc:
|
174
|
+
ant_properties.find {|p| matcher === p[0] }[1]
|
175
|
+
end
|
176
|
+
end
|
File without changes
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<?xml-stylesheet type="text/xsl" href="http://www.ivyrep.org/ivy-doc.xsl"?>
|
3
|
+
<ivy-module version="1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4
|
+
xsi:noNamespaceSchemaLocation="http://incubator.apache.org/ivy/schemas/ivy.xsd">
|
5
|
+
|
6
|
+
<info organisation="blau" module="p1" revision="1.0" />
|
7
|
+
</ivy-module>
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<?xml-stylesheet type="text/xsl" href="http://www.ivyrep.org/ivy-doc.xsl"?>
|
3
|
+
<ivy-module version="1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4
|
+
xsi:noNamespaceSchemaLocation="http://incubator.apache.org/ivy/schemas/ivy.xsd">
|
5
|
+
|
6
|
+
<info organisation="blau" module="p2" revision="1.1" />
|
7
|
+
|
8
|
+
<dependencies>
|
9
|
+
<dependency org="blau" name="p1" rev="1.0" conf="*->default" />
|
10
|
+
</dependencies>
|
11
|
+
</ivy-module>
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<?xml-stylesheet type="text/xsl" href="http://www.ivyrep.org/ivy-doc.xsl"?>
|
3
|
+
<ivy-module version="1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4
|
+
xsi:noNamespaceSchemaLocation="http://incubator.apache.org/ivy/schemas/ivy.xsd">
|
5
|
+
|
6
|
+
<info organisation="blau" module="p3" revision="1.1" />
|
7
|
+
|
8
|
+
<dependencies>
|
9
|
+
<dependency org="blau" name="p2" rev="1.1" conf="*->default" />
|
10
|
+
</dependencies>
|
11
|
+
</ivy-module>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<ivysettings>
|
2
|
+
<property name="myparam" value="myvalue" />
|
3
|
+
<settings defaultCache="/tmp" defaultResolver="ibiblio" checkUpToDate="false" />
|
4
|
+
<resolvers>
|
5
|
+
<ibiblio name="ibiblio" />
|
6
|
+
<filesystem name="internal">
|
7
|
+
<ivy pattern="/tmp/[module]/ivy-[revision].xml" />
|
8
|
+
<artifact pattern="/tmp/[module]/[artifact]-[revision].[ext]" />
|
9
|
+
</filesystem>
|
10
|
+
</resolvers>
|
11
|
+
</ivysettings>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<?xml-stylesheet type="text/xsl" href="http://www.ivyrep.org/ivy-doc.xsl"?>
|
3
|
+
<ivy-module version="1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4
|
+
xsi:noNamespaceSchemaLocation="http://incubator.apache.org/ivy/schemas/ivy.xsd">
|
5
|
+
|
6
|
+
<info organisation="blau" module="testmodule" revision="2.20.0" />
|
7
|
+
|
8
|
+
<configurations defaultconfmapping="client">
|
9
|
+
<conf name="deploy" description="Contains the deployable artifacts for the Project." />
|
10
|
+
<conf name="reports" description="Contains all buildreports for the Project." />
|
11
|
+
<conf name="basic" visibility="private" description="Basic dependencies needed for all configurations."/>
|
12
|
+
<conf name="test" extends="basic" visibility="private" description="Only needed for testing of project."/>
|
13
|
+
</configurations>
|
14
|
+
|
15
|
+
<dependencies>
|
16
|
+
<dependency org="oro" name="oro" rev="2.0.8" conf="*->default" />
|
17
|
+
</dependencies>
|
18
|
+
</ivy-module>
|
@@ -0,0 +1,97 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','..','lib')
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rr'
|
5
|
+
require 'ivy/target'
|
6
|
+
|
7
|
+
class Test::Unit::TestCase
|
8
|
+
include RR::Adapters::TestUnit
|
9
|
+
end
|
10
|
+
|
11
|
+
module Ivy
|
12
|
+
class TargetTest < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def setup
|
15
|
+
Ivy::Target.send("public", :call_nested)
|
16
|
+
@ant = Object.new
|
17
|
+
@target = Ivy::Target.new(@ant)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_call_nested_simple
|
21
|
+
nested = {
|
22
|
+
:fileset => {
|
23
|
+
:includes => 'bla',
|
24
|
+
:excludes => 'blub',
|
25
|
+
:dir => 'anything'
|
26
|
+
}
|
27
|
+
}
|
28
|
+
mock(@ant).fileset(nested[:fileset])
|
29
|
+
|
30
|
+
@target.call_nested(nested)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_call_nested_multiply
|
34
|
+
nested = {
|
35
|
+
:fileset => {
|
36
|
+
:includes => 'bla',
|
37
|
+
:excludes => 'blub',
|
38
|
+
:dir => 'anything'
|
39
|
+
},
|
40
|
+
:other => {
|
41
|
+
:param => 'myparam'
|
42
|
+
}
|
43
|
+
}
|
44
|
+
mock(@ant).fileset nested[:fileset]
|
45
|
+
mock(@ant).other nested[:other]
|
46
|
+
|
47
|
+
@target.call_nested(nested)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_call_nested_list_with_same_method
|
51
|
+
nested = {
|
52
|
+
:fileset => [
|
53
|
+
{
|
54
|
+
:includes => 'bla',
|
55
|
+
:excludes => 'blub',
|
56
|
+
:dir => 'anything'
|
57
|
+
},
|
58
|
+
{
|
59
|
+
:includes => 'otherbla',
|
60
|
+
:excludes => 'otherblub',
|
61
|
+
:dir => 'otheranything'
|
62
|
+
}
|
63
|
+
]
|
64
|
+
}
|
65
|
+
mock(@ant).fileset nested[:fileset][0]
|
66
|
+
mock(@ant).fileset nested[:fileset][1]
|
67
|
+
|
68
|
+
@target.call_nested(nested)
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_call_recursive_nested
|
72
|
+
nested = {
|
73
|
+
:taskdef =>
|
74
|
+
{
|
75
|
+
:name => 'bla',
|
76
|
+
:nested => {
|
77
|
+
:fileset => {
|
78
|
+
:includes => 'bla',
|
79
|
+
:excludes => 'blub',
|
80
|
+
:dir => 'anything'}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
# define the method that yields if a block is given, to test the nested stuff
|
86
|
+
def @ant.taskdef(p)
|
87
|
+
raise "Invalid params to many" unless p.size == 1
|
88
|
+
raise "Wrong parameter value" unless 'bla' == p[:name]
|
89
|
+
raise "missing block for method" unless block_given?
|
90
|
+
yield
|
91
|
+
end
|
92
|
+
mock(@ant).fileset nested[:taskdef][:nested][:fileset]
|
93
|
+
|
94
|
+
@target.call_nested(nested)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','..','lib')
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'ivy/targets'
|
5
|
+
require 'ivy4r'
|
6
|
+
|
7
|
+
module Ivy
|
8
|
+
class TargetsTest < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def setup
|
11
|
+
ivy4r = Ivy4r.new
|
12
|
+
ivy4r.ant_home = File.join(File.dirname(__FILE__), '..', '..', 'jars')
|
13
|
+
ivy4r.lib_dir = ivy4r.ant_home
|
14
|
+
@ivy_test_xml = File.join(File.dirname(__FILE__), 'ivytest.xml')
|
15
|
+
@info = Ivy::Info.new(ivy4r.ant)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_execute_empty_parameters_missing_mandatory_exception
|
19
|
+
assert_raise(ArgumentError) { @info.execute({}) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_execute_validate_with_unkown_parameter_exception
|
23
|
+
assert_raise(ArgumentError) { @info.execute(:unknown_parameter => 'unknown') }
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_execute_simple_file_correct_return_values
|
27
|
+
result = @info.execute(:file => @ivy_test_xml)
|
28
|
+
|
29
|
+
assert_not_nil result
|
30
|
+
%w[ivy.organisation ivy.revision ivy.module].each do |var|
|
31
|
+
assert_equal true, result.keys.member?(var), "Contains key '#{var}', has '#{result.keys.join(', ')}'"
|
32
|
+
end
|
33
|
+
assert_equal 'blau', result['ivy.organisation']
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/test/test_ivy4r.rb
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','..','lib')
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'test/unit'
|
5
|
+
require 'ivy4r'
|
6
|
+
require 'antwrap'
|
7
|
+
require 'fileutils'
|
8
|
+
|
9
|
+
module Ivy
|
10
|
+
class Ivy4rTest < Test::Unit::TestCase
|
11
|
+
|
12
|
+
def setup
|
13
|
+
@ivy4r = Ivy4r.new
|
14
|
+
@ivy4r.ant_home = File.join(File.dirname(__FILE__), '..', 'jars')
|
15
|
+
@ivy4r.lib_dir = @ivy4r.ant_home
|
16
|
+
@ivy_test_xml = File.join(File.dirname(__FILE__), 'ivy', 'ivytest.xml')
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_ant_returns_default_wrapper
|
20
|
+
assert_not_nil @ivy4r.ant
|
21
|
+
assert_kind_of ::Antwrap::AntProject, @ivy4r.ant
|
22
|
+
assert_equal Dir.pwd, @ivy4r.ant.basedir
|
23
|
+
assert_equal true, @ivy4r.ant.declarative
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_ant_returns_always_same_instance
|
27
|
+
first = @ivy4r.ant
|
28
|
+
second = @ivy4r.ant
|
29
|
+
assert_same first, second
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_ant_returns_set_instance_if_provided
|
33
|
+
provided = "bla"
|
34
|
+
@ivy4r.ant = provided
|
35
|
+
@ivy4r.instance_eval("@init_done = true")
|
36
|
+
assert_equal provided, @ivy4r.ant
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_cleancache_returns_nil
|
40
|
+
result = @ivy4r.cleancache
|
41
|
+
|
42
|
+
assert_nil result
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_info_returns_values_for_file
|
46
|
+
result = @ivy4r.info :file => @ivy_test_xml
|
47
|
+
|
48
|
+
assert_not_nil result
|
49
|
+
assert_equal 'blau', result['ivy.organisation']
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_buildnumber_returns_infos
|
53
|
+
result = @ivy4r.buildnumber :organisation => 'oro', :module => 'oro'
|
54
|
+
|
55
|
+
assert_not_nil result
|
56
|
+
assert_equal '2.0.8', result['ivy.revision']
|
57
|
+
assert_equal '2.0.9', result['ivy.new.revision']
|
58
|
+
assert_equal '8', result['ivy.build.number']
|
59
|
+
assert_equal '9', result['ivy.new.build.number']
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_settings_returns_nil
|
63
|
+
result = @ivy4r.settings :file => File.join(File.dirname(__FILE__), 'ivy', 'ivysettings.xml')
|
64
|
+
|
65
|
+
assert_nil result
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_configure_returns_custom_properties
|
69
|
+
result = @ivy4r.configure :file => File.join(File.dirname(__FILE__), 'ivy', 'ivysettings.xml')
|
70
|
+
|
71
|
+
assert_not_nil result
|
72
|
+
assert_equal 'myvalue', result['myparam.ivy.instance']
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_property_setting_getting_to_from_ant
|
76
|
+
# use a java hashmap for testing!!
|
77
|
+
@ivy4r.instance_eval("def ant_properties;@ant_properties||=java.util.HashMap.new;end")
|
78
|
+
name, value = 'name', 'value'
|
79
|
+
@ivy4r.property[name] = value
|
80
|
+
|
81
|
+
assert_equal value, @ivy4r.property[name]
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_resolve_values_for_file
|
85
|
+
result = @ivy4r.resolve :file => @ivy_test_xml
|
86
|
+
|
87
|
+
assert_not_nil result
|
88
|
+
assert_equal 'blau', result['ivy.organisation']
|
89
|
+
assert_equal 4, result['ivy.resolved.configurations'].size, "has: #{result['ivy.resolved.configurations'].join(', ')}"
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_cachepath_using_previous_resolve_contains_jar
|
93
|
+
@ivy4r.resolve :organisation => "oro", :module => "oro", :revision => "2.0.8", :keep => true, :inline => true
|
94
|
+
result = @ivy4r.cachepath :pathid => 'mytestpathid'
|
95
|
+
|
96
|
+
assert_not_nil result
|
97
|
+
assert result.any? {|a| a =~ /.*oro.*\.jar/ && a =~ /.*2\.0\.8*/ }
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_cachepath_with_resolve_contains_jars
|
101
|
+
result = @ivy4r.cachepath :organisation => "oro", :module => "oro", :revision => "2.0.8", :inline => true, :pathid => 'mytestpathid'
|
102
|
+
|
103
|
+
assert_not_nil result
|
104
|
+
assert result.any? {|a| a =~ /.*oro.*\.jar/ && a =~ /.*2\.0\.8*/ }
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_findrevision_found_correct_version
|
108
|
+
result = @ivy4r.findrevision :organisation => "oro", :module => "oro", :revision => "2.0.8"
|
109
|
+
|
110
|
+
assert_equal '2.0.8', result
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_findrevision_not_found_nil
|
114
|
+
result = @ivy4r.findrevision :organisation => "oro", :module => "oro", :revision => "1unknown1"
|
115
|
+
|
116
|
+
assert_nil result
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_artifactproperty_deps_contained
|
120
|
+
@ivy4r.resolve :file => @ivy_test_xml
|
121
|
+
result = @ivy4r.artifactproperty :name => '[organisation]-[module]', :value => '[revision]'
|
122
|
+
|
123
|
+
assert_not_nil result
|
124
|
+
assert result.any? {|k,v| k == 'oro-oro' && v == '2.0.8' }
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_artifactreport_xml_returned
|
128
|
+
target = File.join(Dir.pwd, "temp_test#{Time.new.strftime('%Y%m%d%H%M%S')}")
|
129
|
+
FileUtils.mkdir(target)
|
130
|
+
@ivy4r.resolve :file => @ivy_test_xml
|
131
|
+
result = @ivy4r.artifactreport :tofile => File.join(target, 'test.xml')
|
132
|
+
|
133
|
+
assert_not_nil result
|
134
|
+
assert result =~ /.*<module organisation="oro".*/
|
135
|
+
ensure
|
136
|
+
FileUtils.rm_rf target
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_retrieve_created_dir_with_artifacts
|
140
|
+
target = File.join(Dir.pwd, "temp_test#{Time.new.strftime('%Y%m%d%H%M%S')}")
|
141
|
+
FileUtils.mkdir(target)
|
142
|
+
@ivy4r.resolve :file => @ivy_test_xml
|
143
|
+
result = @ivy4r.retrieve :pattern => "#{target}/[organisation]/[module].[ext]"
|
144
|
+
|
145
|
+
assert_nil result
|
146
|
+
assert Dir.glob(File.join(target, '**/oro.jar')).size > 0, "Contains the artifacts"
|
147
|
+
ensure
|
148
|
+
FileUtils.rm_rf target
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_report_created_reports
|
152
|
+
target = File.join(Dir.pwd, "temp_test#{Time.new.strftime('%Y%m%d%H%M%S')}")
|
153
|
+
FileUtils.mkdir(target)
|
154
|
+
@ivy4r.resolve :file => @ivy_test_xml
|
155
|
+
result = @ivy4r.report :todir => target
|
156
|
+
|
157
|
+
assert_nil result
|
158
|
+
assert Dir.glob(File.join(target, '**/*')).size > 0, "Contains the reports"
|
159
|
+
ensure
|
160
|
+
FileUtils.rm_rf target
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_buildlist_correct_list
|
164
|
+
target = File.join(File.dirname(__FILE__), "buildlist")
|
165
|
+
result = @ivy4r.buildlist :reference => 'testpath', :nested => {
|
166
|
+
:fileset => [
|
167
|
+
{:dir => File.join(target, "sub"), :includes => '**/buildfile'},
|
168
|
+
{:dir => File.join(target, "p1"), :includes => 'buildfile'}
|
169
|
+
]
|
170
|
+
}
|
171
|
+
|
172
|
+
assert_equal 3, result.size
|
173
|
+
result.map! { |file| File.expand_path(file) }
|
174
|
+
assert_equal File.expand_path(File.join(target, "p1", "buildfile")), result[0]
|
175
|
+
assert_equal File.expand_path(File.join(target, "sub", "p2", "buildfile")), result[1]
|
176
|
+
assert_equal File.expand_path(File.join(target, "sub", "p3", "buildfile")), result[2]
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_makepom_returns_content
|
180
|
+
target = File.join(File.dirname(__FILE__), "testpom.xml")
|
181
|
+
result = @ivy4r.makepom :ivyfile => @ivy_test_xml, :pomfile => target, :nested => {
|
182
|
+
:mapping => {:conf => 'default', :scope => 'runtime' }
|
183
|
+
}
|
184
|
+
|
185
|
+
assert_equal IO.read(target), result
|
186
|
+
ensure
|
187
|
+
FileUtils.rm target
|
188
|
+
end
|
189
|
+
|
190
|
+
#def test_listmodules_lists_ivy_stuff
|
191
|
+
# result = @antwrap.listmodules :organisation => '*apache*', :module => '*ivy*', :revision => '2.*',
|
192
|
+
# :matcher => 'glob', :property => 'rums-[organisation][module]', :value => 'found'
|
193
|
+
# assert result.find {|k,v| k =~ /rums-/ && v == 'found'}, "found: #{result.inspect}"
|
194
|
+
#end
|
195
|
+
end
|
196
|
+
end
|