gjp 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/README.md +3 -3
- data/lib/gjp.rb +1 -0
- data/lib/gjp/get_pom.rb +7 -77
- data/lib/gjp/get_source.rb +61 -9
- data/lib/gjp/version.rb +1 -1
- data/lib/gjp/version_matcher.rb +99 -0
- data/spec/data/struts-apps/pom.xml +228 -0
- data/spec/lib/get_pom_spec.rb +1 -46
- data/spec/lib/get_source_spec.rb +21 -7
- data/spec/lib/version_matcher_spec.rb +64 -0
- metadata +7 -2
data/.gitignore
CHANGED
@@ -13,7 +13,8 @@ test/version_tmp
|
|
13
13
|
tmp
|
14
14
|
|
15
15
|
# SPEC generated files
|
16
|
-
spec/data/
|
16
|
+
spec/data/nailgun/com.martiansoftware\:nailgun-all\:0.9.1
|
17
|
+
spec/data/struts-apps/org.apache.struts\:struts2-apps\:
|
17
18
|
|
18
19
|
# YARD artifacts
|
19
20
|
.yardoc
|
data/README.md
CHANGED
@@ -15,9 +15,9 @@ Easiest install is via RubyGems:
|
|
15
15
|
## Usage
|
16
16
|
|
17
17
|
Currently available tools:
|
18
|
-
* `gjp get-pom
|
19
|
-
* `gjp get-source-address
|
20
|
-
* `gjp get-source
|
18
|
+
* `gjp get-pom JAR` will attempt to find an jar's pom.xml (either from the package itself or through search.maven.org);
|
19
|
+
* `gjp get-source-address POM` will attempt to find the SCM Internet address of a pom.xml (from the file itself or through api.github.com);
|
20
|
+
* `gjp get-source POM ADDRESS` downloads the source of a pom.xml's project from its SCM at ADDRESS;
|
21
21
|
|
22
22
|
## Source
|
23
23
|
|
data/lib/gjp.rb
CHANGED
data/lib/gjp/get_pom.rb
CHANGED
@@ -4,9 +4,10 @@ require "digest/sha1"
|
|
4
4
|
require "zip/zip"
|
5
5
|
require "rest_client"
|
6
6
|
require "json"
|
7
|
-
require "text"
|
8
7
|
require "pathname"
|
9
8
|
|
9
|
+
require "gjp/version_matcher"
|
10
|
+
|
10
11
|
# implements the get-pom subcommand
|
11
12
|
class PomGetter
|
12
13
|
|
@@ -51,22 +52,21 @@ class PomGetter
|
|
51
52
|
# returns a pom from search.maven.org with a heuristic name search
|
52
53
|
def self.get_pom_from_heuristic(file)
|
53
54
|
filename = Pathname.new(file).basename.to_s
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
my_version = matches[2]
|
55
|
+
if filename =~ /([^\/]*)\.jar$/
|
56
|
+
my_artifact_id, my_version = VersionMatcher.split_version($1)
|
57
|
+
|
58
58
|
result = repository_search({:q => my_artifact_id}).first
|
59
59
|
if result != nil
|
60
60
|
results = repository_search({:q => "g:\"#{result["g"]}\" AND a:\"#{result["a"]}\"", :core => "gav"})
|
61
61
|
their_versions = results.map {|doc| doc["v"]}
|
62
|
-
best_matched_version = if my_version != nil then best_match(my_version, their_versions) else their_versions.max end
|
62
|
+
best_matched_version = if my_version != nil then VersionMatcher.best_match(my_version, their_versions) else their_versions.max end
|
63
63
|
best_matched_result = (results.select{|result| result["v"] == best_matched_version}).first
|
64
64
|
|
65
65
|
$log.warn("pom.xml for #{file} found on search.maven.org with heuristic search (#{best_matched_result["g"]}:#{best_matched_result["a"]}:#{best_matched_result["v"]})")
|
66
66
|
|
67
67
|
return repository_download(best_matched_result)
|
68
68
|
end
|
69
|
-
|
69
|
+
end
|
70
70
|
end
|
71
71
|
|
72
72
|
# returns a JSON result from search.maven.com
|
@@ -84,75 +84,5 @@ class PomGetter
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
-
# returns the "best match" between a version number and a set of available version numbers
|
88
|
-
# using a heuristic criterion. Idea:
|
89
|
-
# - split the version number in chunks divided by ., - etc.
|
90
|
-
# - every chunk with same index is "compared", differences make up a score
|
91
|
-
# - "comparison" is a subtraction if the chunk is an integer, a string distance measure otherwise
|
92
|
-
# - score weighs differently on chunk index (first chunks are most important)
|
93
|
-
# - lowest score wins
|
94
|
-
def self.best_match(my_version, their_versions)
|
95
|
-
$log.debug("version comparison: #{my_version} vs #{their_versions.join(', ')}")
|
96
|
-
|
97
|
-
my_chunks = my_version.split /[\.\-\_ ~,]/
|
98
|
-
their_chunks_hash = Hash[
|
99
|
-
their_versions.map do |their_version|
|
100
|
-
their_chunks_for_version = their_version.split /[\.\-\_ ~,]/
|
101
|
-
their_chunks_for_version += [nil]*[my_chunks.length - their_chunks_for_version.length, 0].max
|
102
|
-
[their_version, their_chunks_for_version]
|
103
|
-
end
|
104
|
-
]
|
105
|
-
|
106
|
-
max_chunks_length = ([my_chunks.length] + their_chunks_hash.values.map {|chunk| chunk.length}).max
|
107
|
-
|
108
|
-
scoreboard = []
|
109
|
-
their_versions.each do |their_version|
|
110
|
-
their_chunks = their_chunks_hash[their_version]
|
111
|
-
score = 0
|
112
|
-
their_chunks.each_with_index do |their_chunk, i|
|
113
|
-
score_multiplier = 100**(max_chunks_length -i -1)
|
114
|
-
my_chunk = my_chunks[i]
|
115
|
-
score += chunk_distance(my_chunk, their_chunk) * score_multiplier
|
116
|
-
end
|
117
|
-
scoreboard << {:version => their_version, :score => score}
|
118
|
-
end
|
119
|
-
|
120
|
-
scoreboard = scoreboard.sort_by {|element| element[:score]}
|
121
|
-
|
122
|
-
$log.debug("scoreboard: ")
|
123
|
-
scoreboard.each_with_index do |element, i|
|
124
|
-
$log.debug(" #{i+1}. #{element[:version]} (score: #{element[:score]})")
|
125
|
-
end
|
126
|
-
|
127
|
-
winner = scoreboard.first
|
128
|
-
|
129
|
-
if winner != nil
|
130
|
-
return winner[:version]
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
# returns a score representing the distance between two version chunks
|
135
|
-
# for integers, the score is the difference between their values
|
136
|
-
# for strings, the score is the Levenshtein distance
|
137
|
-
# in any case score is normalized between 0 (identical) and 99 (very different/uncomparable)
|
138
|
-
def self.chunk_distance(my_chunk, their_chunk)
|
139
|
-
if my_chunk == nil
|
140
|
-
my_chunk = "0"
|
141
|
-
end
|
142
|
-
if their_chunk == nil
|
143
|
-
their_chunk = "0"
|
144
|
-
end
|
145
|
-
if my_chunk.is_i? and their_chunk.is_i?
|
146
|
-
return [(my_chunk.to_i - their_chunk.to_i).abs, 99].min
|
147
|
-
else
|
148
|
-
return [Text::Levenshtein.distance(my_chunk.upcase, their_chunk.upcase), 99].min
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
class String
|
154
|
-
def is_i?
|
155
|
-
!!(self =~ /^[0-9]+$/)
|
156
|
-
end
|
157
87
|
end
|
158
88
|
|
data/lib/gjp/get_source.rb
CHANGED
@@ -10,20 +10,72 @@ class SourceGetter
|
|
10
10
|
$log.info("downloading: #{address} in #{directory}, pomfile: #{pomfile}")
|
11
11
|
|
12
12
|
dummy, prefix, scm_address = address.split(/^([^:]+):(.*)$/)
|
13
|
-
|
14
13
|
$log.info("prefix: #{prefix}, scm_address: #{scm_address}")
|
15
|
-
|
16
|
-
|
17
|
-
get_source_from_git(scm_address, pomfile, directory)
|
18
|
-
end
|
14
|
+
|
15
|
+
get_source_from_scm(prefix, scm_address, pomfile, directory)
|
19
16
|
end
|
20
17
|
|
21
|
-
# checks out from
|
22
|
-
def self.
|
18
|
+
# checks code out from an scm
|
19
|
+
def self.get_source_from_scm(prefix, scm_address, pomfile, directory)
|
23
20
|
pom = Pom.new(pomfile)
|
24
21
|
dir = File.join(directory, "#{pom.group_id}:#{pom.artifact_id}:#{pom.version}")
|
22
|
+
begin
|
23
|
+
Dir::mkdir(dir)
|
24
|
+
rescue Errno::EEXIST
|
25
|
+
$log.warn("Source directory exists, leaving...")
|
26
|
+
end
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
+
if prefix == "git"
|
29
|
+
get_source_from_git(scm_address, dir, pom.version)
|
30
|
+
elsif prefix == "svn"
|
31
|
+
get_source_from_svn(scm_address, dir, pom.version)
|
32
|
+
end
|
28
33
|
end
|
34
|
+
|
35
|
+
# checks code out of git
|
36
|
+
def self.get_source_from_git(scm_address, dir, version)
|
37
|
+
`git clone #{scm_address} #{dir}`
|
38
|
+
|
39
|
+
Dir.chdir(dir) do
|
40
|
+
tags = `git tag`.split("\n")
|
41
|
+
|
42
|
+
if tags.any?
|
43
|
+
best_tag = get_best_tag(tags, version)
|
44
|
+
$log.info("checking out tag: #{best_tag}")
|
45
|
+
|
46
|
+
`git checkout #{best_tag}`
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# checks code out of svn
|
52
|
+
def self.get_source_from_svn(scm_address, dir, version)
|
53
|
+
`svn checkout #{scm_address} #{dir}`
|
54
|
+
|
55
|
+
Dir.chdir(dir) do
|
56
|
+
tags = `svn ls "^/tags"`.split("\n")
|
57
|
+
|
58
|
+
if tags.any?
|
59
|
+
best_tag = get_best_tag(tags, version)
|
60
|
+
$log.info("checking out tag: #{best_tag}")
|
61
|
+
|
62
|
+
`svn checkout #{scm_address}/tags/#{best_tag}`
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# return the (heuristically) most similar tag to the specified version
|
68
|
+
def self.get_best_tag(tags, version)
|
69
|
+
versions_to_tags =Hash[
|
70
|
+
*tags.map do |tag|
|
71
|
+
[VersionMatcher.split_version(tag)[1], tag]
|
72
|
+
end.flatten
|
73
|
+
]
|
74
|
+
|
75
|
+
$log.info("found the following versions and tags: #{versions_to_tags}")
|
76
|
+
|
77
|
+
best_version = VersionMatcher.best_match(version, versions_to_tags.keys)
|
78
|
+
versions_to_tags[best_version]
|
79
|
+
end
|
29
80
|
end
|
81
|
+
|
data/lib/gjp/version.rb
CHANGED
@@ -0,0 +1,99 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require "text"
|
4
|
+
|
5
|
+
# heuristically matches version strings
|
6
|
+
class VersionMatcher
|
7
|
+
|
8
|
+
# heuristically extracts a version number from a full name
|
9
|
+
# assumes that all leading non-numeric chars are not related the version
|
10
|
+
# returns a version string
|
11
|
+
def self.extract_version(full_name)
|
12
|
+
full_name.sub /^[^0-9]+/, ""
|
13
|
+
end
|
14
|
+
|
15
|
+
# heuristically splits a full name into an artifact name and version string
|
16
|
+
# assumes that version strings begin with a numeric character and are separated
|
17
|
+
# by a ., -, _, ~ or space
|
18
|
+
# returns a [name, version] pair
|
19
|
+
def self.split_version(full_name)
|
20
|
+
matches = full_name.match(/(.*?)(?:[\.\-\_ ~,]?([0-9].*))?$/)
|
21
|
+
if matches != nil and matches.length > 1
|
22
|
+
[matches[1], matches[2]]
|
23
|
+
else
|
24
|
+
[full_string, nil]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# returns the "best match" between a version number and a set of available version numbers
|
29
|
+
# using a heuristic criterion. Idea:
|
30
|
+
# - split the version number in chunks divided by ., - etc.
|
31
|
+
# - every chunk with same index is "compared", differences make up a score
|
32
|
+
# - "comparison" is a subtraction if the chunk is an integer, a string distance measure otherwise
|
33
|
+
# - score weighs differently on chunk index (first chunks are most important)
|
34
|
+
# - lowest score wins
|
35
|
+
def self.best_match(my_version, their_versions)
|
36
|
+
$log.debug("version comparison: #{my_version} vs #{their_versions.join(', ')}")
|
37
|
+
|
38
|
+
my_chunks = my_version.split /[\.\-\_ ~,]/
|
39
|
+
their_chunks_hash = Hash[
|
40
|
+
their_versions.map do |their_version|
|
41
|
+
their_chunks_for_version = their_version.split /[\.\-\_ ~,]/
|
42
|
+
their_chunks_for_version += [nil]*[my_chunks.length - their_chunks_for_version.length, 0].max
|
43
|
+
[their_version, their_chunks_for_version]
|
44
|
+
end
|
45
|
+
]
|
46
|
+
|
47
|
+
max_chunks_length = ([my_chunks.length] + their_chunks_hash.values.map {|chunk| chunk.length}).max
|
48
|
+
|
49
|
+
scoreboard = []
|
50
|
+
their_versions.each do |their_version|
|
51
|
+
their_chunks = their_chunks_hash[their_version]
|
52
|
+
score = 0
|
53
|
+
their_chunks.each_with_index do |their_chunk, i|
|
54
|
+
score_multiplier = 100**(max_chunks_length -i -1)
|
55
|
+
my_chunk = my_chunks[i]
|
56
|
+
score += chunk_distance(my_chunk, their_chunk) * score_multiplier
|
57
|
+
end
|
58
|
+
scoreboard << {:version => their_version, :score => score}
|
59
|
+
end
|
60
|
+
|
61
|
+
scoreboard = scoreboard.sort_by {|element| element[:score]}
|
62
|
+
|
63
|
+
$log.debug("scoreboard: ")
|
64
|
+
scoreboard.each_with_index do |element, i|
|
65
|
+
$log.debug(" #{i+1}. #{element[:version]} (score: #{element[:score]})")
|
66
|
+
end
|
67
|
+
|
68
|
+
winner = scoreboard.first
|
69
|
+
|
70
|
+
if winner != nil
|
71
|
+
return winner[:version]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# returns a score representing the distance between two version chunks
|
76
|
+
# for integers, the score is the difference between their values
|
77
|
+
# for strings, the score is the Levenshtein distance
|
78
|
+
# in any case score is normalized between 0 (identical) and 99 (very different/uncomparable)
|
79
|
+
def self.chunk_distance(my_chunk, their_chunk)
|
80
|
+
if my_chunk == nil
|
81
|
+
my_chunk = "0"
|
82
|
+
end
|
83
|
+
if their_chunk == nil
|
84
|
+
their_chunk = "0"
|
85
|
+
end
|
86
|
+
if my_chunk.is_i? and their_chunk.is_i?
|
87
|
+
return [(my_chunk.to_i - their_chunk.to_i).abs, 99].min
|
88
|
+
else
|
89
|
+
return [Text::Levenshtein.distance(my_chunk.upcase, their_chunk.upcase), 99].min
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
class String
|
95
|
+
def is_i?
|
96
|
+
!!(self =~ /^[0-9]+$/)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
@@ -0,0 +1,228 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!--
|
3
|
+
/*
|
4
|
+
* $Id: pom.xml 1462297 2013-03-28 20:51:02Z lukaszlenart $
|
5
|
+
*
|
6
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
7
|
+
* or more contributor license agreements. See the NOTICE file
|
8
|
+
* distributed with this work for additional information
|
9
|
+
* regarding copyright ownership. The ASF licenses this file
|
10
|
+
* to you under the Apache License, Version 2.0 (the
|
11
|
+
* "License"); you may not use this file except in compliance
|
12
|
+
* with the License. You may obtain a copy of the License at
|
13
|
+
*
|
14
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
15
|
+
*
|
16
|
+
* Unless required by applicable law or agreed to in writing,
|
17
|
+
* software distributed under the License is distributed on an
|
18
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
19
|
+
* KIND, either express or implied. See the License for the
|
20
|
+
* specific language governing permissions and limitations
|
21
|
+
* under the License.
|
22
|
+
*/
|
23
|
+
-->
|
24
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
25
|
+
<modelVersion>4.0.0</modelVersion>
|
26
|
+
<parent>
|
27
|
+
<groupId>org.apache.struts</groupId>
|
28
|
+
<artifactId>struts2-parent</artifactId>
|
29
|
+
<version>2.3.14</version>
|
30
|
+
</parent>
|
31
|
+
<groupId>org.apache.struts</groupId>
|
32
|
+
<artifactId>struts2-apps</artifactId>
|
33
|
+
<packaging>pom</packaging>
|
34
|
+
<name>Webapps</name>
|
35
|
+
<modules>
|
36
|
+
<module>blank</module>
|
37
|
+
<module>jboss-blank</module>
|
38
|
+
<module>mailreader</module>
|
39
|
+
<module>portlet</module>
|
40
|
+
<module>showcase</module>
|
41
|
+
<module>rest-showcase</module>
|
42
|
+
</modules>
|
43
|
+
|
44
|
+
<scm>
|
45
|
+
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_3_14/apps</connection>
|
46
|
+
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_3_14/apps</developerConnection>
|
47
|
+
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_3_14/apps</url>
|
48
|
+
</scm>
|
49
|
+
|
50
|
+
<profiles>
|
51
|
+
<profile>
|
52
|
+
<id>hostedqa</id>
|
53
|
+
<dependencies>
|
54
|
+
<dependency>
|
55
|
+
<groupId>com.hostedqa</groupId>
|
56
|
+
<artifactId>hostedqa-remote-ant</artifactId>
|
57
|
+
<version>1.7</version>
|
58
|
+
<scope>test</scope>
|
59
|
+
</dependency>
|
60
|
+
</dependencies>
|
61
|
+
<repositories>
|
62
|
+
<repository>
|
63
|
+
<id>codehaus</id>
|
64
|
+
<name>codehaus</name>
|
65
|
+
<url>http://repository.codehaus.org</url>
|
66
|
+
</repository>
|
67
|
+
<repository>
|
68
|
+
<id>maven-hostedqa</id>
|
69
|
+
<name>maven-hostedqa</name>
|
70
|
+
<snapshots>
|
71
|
+
<enabled>true</enabled>
|
72
|
+
<updatePolicy>always</updatePolicy>
|
73
|
+
<checksumPolicy>ignore</checksumPolicy>
|
74
|
+
</snapshots>
|
75
|
+
<releases>
|
76
|
+
<enabled>true</enabled>
|
77
|
+
</releases>
|
78
|
+
<url>http://maven.hostedqa.com</url>
|
79
|
+
</repository>
|
80
|
+
</repositories>
|
81
|
+
<build>
|
82
|
+
<resources>
|
83
|
+
<!-- Include resources under src/main/java in WEB-INF/classes -->
|
84
|
+
<resource>
|
85
|
+
<directory>src/main/java</directory>
|
86
|
+
<includes>
|
87
|
+
<include>**/*.properties</include>
|
88
|
+
<include>**/*.xml</include>
|
89
|
+
</includes>
|
90
|
+
</resource>
|
91
|
+
</resources>
|
92
|
+
<plugins>
|
93
|
+
<plugin>
|
94
|
+
<artifactId>maven-antrun-plugin</artifactId>
|
95
|
+
<groupId>org.apache.maven.plugins</groupId>
|
96
|
+
<executions>
|
97
|
+
<execution>
|
98
|
+
<phase>package</phase>
|
99
|
+
<goals>
|
100
|
+
<goal>run</goal>
|
101
|
+
</goals>
|
102
|
+
<configuration>
|
103
|
+
<tasks>
|
104
|
+
<taskdef resource="hostedqatasks" classpathref="maven.plugin.classpath" />
|
105
|
+
<upload file="${project.build.directory}/${project.build.finalName}.war" account="struts" email="${email}" password="${password}" resourceId="${resourceId}" />
|
106
|
+
|
107
|
+
<playsuite suiteId="${suiteId}" clientConfigs="${clientConfigs}" appConfigs="${appConfigs}" account="struts" email="${email}" password="${password}" />
|
108
|
+
</tasks>
|
109
|
+
</configuration>
|
110
|
+
</execution>
|
111
|
+
</executions>
|
112
|
+
<dependencies>
|
113
|
+
<dependency>
|
114
|
+
<groupId>com.hostedqa</groupId>
|
115
|
+
<artifactId>hostedqa-remote-ant</artifactId>
|
116
|
+
<version>1.7</version>
|
117
|
+
</dependency>
|
118
|
+
</dependencies>
|
119
|
+
</plugin>
|
120
|
+
</plugins>
|
121
|
+
</build>
|
122
|
+
</profile>
|
123
|
+
<profile>
|
124
|
+
<id>release</id>
|
125
|
+
<activation>
|
126
|
+
<property>
|
127
|
+
<name>release</name>
|
128
|
+
</property>
|
129
|
+
</activation>
|
130
|
+
<build>
|
131
|
+
<plugins>
|
132
|
+
<plugin>
|
133
|
+
<inherited>true</inherited>
|
134
|
+
<groupId>org.codehaus.mojo</groupId>
|
135
|
+
<artifactId>rat-maven-plugin</artifactId>
|
136
|
+
<executions>
|
137
|
+
<execution>
|
138
|
+
<phase>verify</phase>
|
139
|
+
<goals>
|
140
|
+
<goal>check</goal>
|
141
|
+
</goals>
|
142
|
+
<configuration>
|
143
|
+
<addDefaultLicenseMatchers>false</addDefaultLicenseMatchers>
|
144
|
+
<licenseMatchers>
|
145
|
+
<classNames>
|
146
|
+
<className>rat.analysis.license.ApacheSoftwareLicense20</className>
|
147
|
+
</classNames>
|
148
|
+
</licenseMatchers>
|
149
|
+
<includes>
|
150
|
+
<include>pom.xml</include>
|
151
|
+
</includes>
|
152
|
+
<excludes>
|
153
|
+
<exclude>src/**</exclude>
|
154
|
+
</excludes>
|
155
|
+
</configuration>
|
156
|
+
</execution>
|
157
|
+
</executions>
|
158
|
+
</plugin>
|
159
|
+
</plugins>
|
160
|
+
</build>
|
161
|
+
</profile>
|
162
|
+
</profiles>
|
163
|
+
|
164
|
+
<build>
|
165
|
+
<plugins>
|
166
|
+
<!-- Include source code under WEB-INF/src/java -->
|
167
|
+
<plugin>
|
168
|
+
<artifactId>maven-antrun-plugin</artifactId>
|
169
|
+
<executions>
|
170
|
+
<execution>
|
171
|
+
<id>copy-sources</id>
|
172
|
+
<phase>process-sources</phase>
|
173
|
+
<configuration>
|
174
|
+
<tasks>
|
175
|
+
<copy todir="${project.build.directory}/${project.artifactId}/WEB-INF/src/java" failonerror="false">
|
176
|
+
<fileset dir="${basedir}/src/main/java" />
|
177
|
+
</copy>
|
178
|
+
<copy todir="${project.build.directory}/${project.artifactId}/WEB-INF/src/java" failonerror="false">
|
179
|
+
<fileset dir="${basedir}/src/main/resources" />
|
180
|
+
</copy>
|
181
|
+
</tasks>
|
182
|
+
</configuration>
|
183
|
+
<goals>
|
184
|
+
<goal>run</goal>
|
185
|
+
</goals>
|
186
|
+
</execution>
|
187
|
+
</executions>
|
188
|
+
</plugin>
|
189
|
+
<plugin>
|
190
|
+
<groupId>org.apache.maven.plugins</groupId>
|
191
|
+
<artifactId>maven-war-plugin</artifactId>
|
192
|
+
<configuration>
|
193
|
+
<webResources>
|
194
|
+
<resource>
|
195
|
+
<directory>${basedir}/src/main/resources</directory>
|
196
|
+
<targetPath>META-INF</targetPath>
|
197
|
+
<includes>
|
198
|
+
<include>LICENSE.txt</include>
|
199
|
+
<include>NOTICE.txt</include>
|
200
|
+
</includes>
|
201
|
+
</resource>
|
202
|
+
</webResources>
|
203
|
+
<warSourceExcludes>WEB-INF/classes/LICENSE.txt,WEB-INF/classes/NOTICE.txt</warSourceExcludes>
|
204
|
+
</configuration>
|
205
|
+
</plugin>
|
206
|
+
</plugins>
|
207
|
+
|
208
|
+
<finalName>${project.artifactId}</finalName>
|
209
|
+
|
210
|
+
</build>
|
211
|
+
|
212
|
+
<dependencies>
|
213
|
+
|
214
|
+
<dependency>
|
215
|
+
<groupId>org.apache.struts</groupId>
|
216
|
+
<artifactId>struts2-core</artifactId>
|
217
|
+
<version>${project.version}</version>
|
218
|
+
</dependency>
|
219
|
+
|
220
|
+
<dependency>
|
221
|
+
<groupId>org.springframework</groupId>
|
222
|
+
<artifactId>spring-test</artifactId>
|
223
|
+
<version>${struts2.springPlatformVersion}</version>
|
224
|
+
<scope>test</scope>
|
225
|
+
</dependency>
|
226
|
+
</dependencies>
|
227
|
+
|
228
|
+
</project>
|
data/spec/lib/get_pom_spec.rb
CHANGED
@@ -29,52 +29,7 @@ describe PomGetter do
|
|
29
29
|
pom_path = File.join(dir_path, "pom.xml")
|
30
30
|
jar_path = File.join(dir_path, "nailgun-0.7.1.jar")
|
31
31
|
PomGetter.get_pom(jar_path).should eq(File.read(pom_path))
|
32
|
-
end
|
33
|
-
|
34
|
-
it "computes chunk distances" do
|
35
|
-
PomGetter.chunk_distance(nil, "1").should eq(1)
|
36
|
-
PomGetter.chunk_distance("alpha", nil).should eq(5)
|
37
|
-
|
38
|
-
PomGetter.chunk_distance("1", "1").should eq(0)
|
39
|
-
PomGetter.chunk_distance("1", "9").should eq(8)
|
40
|
-
PomGetter.chunk_distance("1", "999").should eq(99)
|
41
|
-
|
42
|
-
PomGetter.chunk_distance("snap", "SNAP").should eq(0)
|
43
|
-
PomGetter.chunk_distance("snap", "snippete").should eq(5)
|
44
|
-
PomGetter.chunk_distance("snap", "l"*999).should eq(99)
|
45
|
-
|
46
|
-
PomGetter.chunk_distance("1", "SNAP").should eq(4)
|
47
|
-
|
48
|
-
PomGetter.chunk_distance("0", "10").should eq(10)
|
49
|
-
PomGetter.chunk_distance("0", "9").should eq(9)
|
50
|
-
end
|
51
|
-
|
52
|
-
it "finds the best match" do
|
53
|
-
my_version = "1.0"
|
54
|
-
available_versions = ["1.0", "1", "2.0", "1.0.1", "4.5.6.7.8"]
|
55
|
-
PomGetter.best_match(my_version, available_versions).should eq("1.0")
|
56
|
-
|
57
|
-
available_versions = ["3.0", "2.0", "1.0.1"]
|
58
|
-
PomGetter.best_match(my_version, available_versions).should eq("1.0.1")
|
59
|
-
|
60
|
-
available_versions = ["1.snap", "2.0", "4.0.1"]
|
61
|
-
PomGetter.best_match(my_version, available_versions).should eq("1.snap")
|
62
|
-
|
63
|
-
available_versions = ["1.10", "1.9", "2.0", "3.0.1"]
|
64
|
-
PomGetter.best_match(my_version, available_versions).should eq("1.9")
|
65
|
-
|
66
|
-
my_version = "1.snap"
|
67
|
-
available_versions = ["1.snap", "1"]
|
68
|
-
PomGetter.best_match(my_version, available_versions).should eq("1.snap")
|
69
|
-
|
70
|
-
my_version = "1.very-very_very_longish"
|
71
|
-
available_versions = ["1.snap", "1"]
|
72
|
-
PomGetter.best_match(my_version, available_versions).should eq("1.snap")
|
73
|
-
|
74
|
-
my_version = "1.snap"
|
75
|
-
available_versions = []
|
76
|
-
PomGetter.best_match(my_version, available_versions).should be_nil
|
77
|
-
end
|
32
|
+
end
|
78
33
|
end
|
79
34
|
end
|
80
35
|
|
data/spec/lib/get_source_spec.rb
CHANGED
@@ -6,17 +6,31 @@ require "fileutils"
|
|
6
6
|
describe SourceGetter do
|
7
7
|
describe ".get_source_from_git" do
|
8
8
|
it "gets the sources from a git repo" do
|
9
|
-
|
10
|
-
dir_path = File.join("spec", "data", "tomcat")
|
9
|
+
dir_path = File.join("spec", "data", "nailgun")
|
11
10
|
pom_path = File.join(dir_path, "pom.xml")
|
11
|
+
repo_path = File.join(dir_path, "com.martiansoftware:nailgun-all:0.9.1")
|
12
|
+
file_path = File.join(repo_path, "README.md")
|
12
13
|
|
13
|
-
|
14
|
+
FileUtils.rm_rf(repo_path)
|
15
|
+
|
16
|
+
SourceGetter.get_source("git:git@github.com:martylamb/nailgun.git", pom_path, dir_path)
|
17
|
+
|
18
|
+
File.open(file_path).readline.should eq "nailgun\n"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe ".get_source_from_svn" do
|
23
|
+
it "gets the sources from an svn repo" do
|
24
|
+
dir_path = File.join("spec", "data", "struts-apps")
|
25
|
+
pom_path = File.join(dir_path, "pom.xml")
|
26
|
+
repo_path = File.join(dir_path, "org.apache.struts:struts2-apps:")
|
27
|
+
file_path = File.join(repo_path, "showcase", "README.txt")
|
14
28
|
|
15
|
-
repo_path = File.join(dir_path, "org.apache.tomcat:tomcat:7.0.40")
|
16
|
-
file_path = File.join(repo_path, "LICENSE")
|
17
|
-
File.open(file_path).readline.should eq "\n"
|
18
|
-
|
19
29
|
FileUtils.rm_rf(repo_path)
|
30
|
+
|
31
|
+
SourceGetter.get_source("svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_3_14/apps", pom_path, dir_path)
|
32
|
+
|
33
|
+
File.open(file_path).readline.should eq "README.txt - showcase\n"
|
20
34
|
end
|
21
35
|
end
|
22
36
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe VersionMatcher do
|
6
|
+
|
7
|
+
it "splits full names into names and version numbers" do
|
8
|
+
VersionMatcher.split_version("moio-3.2beta1").should eq(["moio", "3.2beta1"])
|
9
|
+
VersionMatcher.split_version("3.2beta1").should eq(["3", "2beta1"])
|
10
|
+
VersionMatcher.split_version("v3.2beta1").should eq(["v", "3.2beta1"])
|
11
|
+
end
|
12
|
+
|
13
|
+
it "extracts version numbers" do
|
14
|
+
VersionMatcher.extract_version("moio-3.2beta1").should eq("3.2beta1")
|
15
|
+
VersionMatcher.extract_version("3.2beta1").should eq("3.2beta1")
|
16
|
+
VersionMatcher.extract_version("v3.2beta1").should eq("3.2beta1")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "computes chunk distances" do
|
20
|
+
VersionMatcher.chunk_distance(nil, "1").should eq(1)
|
21
|
+
VersionMatcher.chunk_distance("alpha", nil).should eq(5)
|
22
|
+
|
23
|
+
VersionMatcher.chunk_distance("1", "1").should eq(0)
|
24
|
+
VersionMatcher.chunk_distance("1", "9").should eq(8)
|
25
|
+
VersionMatcher.chunk_distance("1", "999").should eq(99)
|
26
|
+
|
27
|
+
VersionMatcher.chunk_distance("snap", "SNAP").should eq(0)
|
28
|
+
VersionMatcher.chunk_distance("snap", "snippete").should eq(5)
|
29
|
+
VersionMatcher.chunk_distance("snap", "l"*999).should eq(99)
|
30
|
+
|
31
|
+
VersionMatcher.chunk_distance("1", "SNAP").should eq(4)
|
32
|
+
|
33
|
+
VersionMatcher.chunk_distance("0", "10").should eq(10)
|
34
|
+
VersionMatcher.chunk_distance("0", "9").should eq(9)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "finds the best match" do
|
38
|
+
my_version = "1.0"
|
39
|
+
available_versions = ["1.0", "1", "2.0", "1.0.1", "4.5.6.7.8"]
|
40
|
+
VersionMatcher.best_match(my_version, available_versions).should eq("1.0")
|
41
|
+
|
42
|
+
available_versions = ["3.0", "2.0", "1.0.1"]
|
43
|
+
VersionMatcher.best_match(my_version, available_versions).should eq("1.0.1")
|
44
|
+
|
45
|
+
available_versions = ["1.snap", "2.0", "4.0.1"]
|
46
|
+
VersionMatcher.best_match(my_version, available_versions).should eq("1.snap")
|
47
|
+
|
48
|
+
available_versions = ["1.10", "1.9", "2.0", "3.0.1"]
|
49
|
+
VersionMatcher.best_match(my_version, available_versions).should eq("1.9")
|
50
|
+
|
51
|
+
my_version = "1.snap"
|
52
|
+
available_versions = ["1.snap", "1"]
|
53
|
+
VersionMatcher.best_match(my_version, available_versions).should eq("1.snap")
|
54
|
+
|
55
|
+
my_version = "1.very-very_very_longish"
|
56
|
+
available_versions = ["1.snap", "1"]
|
57
|
+
VersionMatcher.best_match(my_version, available_versions).should eq("1.snap")
|
58
|
+
|
59
|
+
my_version = "1.snap"
|
60
|
+
available_versions = []
|
61
|
+
VersionMatcher.best_match(my_version, available_versions).should be_nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gjp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -162,17 +162,20 @@ files:
|
|
162
162
|
- lib/gjp/logger.rb
|
163
163
|
- lib/gjp/pom.rb
|
164
164
|
- lib/gjp/version.rb
|
165
|
+
- lib/gjp/version_matcher.rb
|
165
166
|
- spec/data/antlr/antlr-2.7.2.jar
|
166
167
|
- spec/data/antlr/pom.xml
|
167
168
|
- spec/data/commons-logging/commons-logging-1.1.1.jar
|
168
169
|
- spec/data/commons-logging/pom.xml
|
169
170
|
- spec/data/nailgun/nailgun-0.7.1.jar
|
170
171
|
- spec/data/nailgun/pom.xml
|
172
|
+
- spec/data/struts-apps/pom.xml
|
171
173
|
- spec/data/tomcat/pom.xml
|
172
174
|
- spec/lib/get_pom_spec.rb
|
173
175
|
- spec/lib/get_source_address_spec.rb
|
174
176
|
- spec/lib/get_source_spec.rb
|
175
177
|
- spec/lib/pom_spec.rb
|
178
|
+
- spec/lib/version_matcher_spec.rb
|
176
179
|
- spec/spec_helper.rb
|
177
180
|
homepage: https://github.com/SilvioMoioli/gjp
|
178
181
|
licenses: []
|
@@ -205,9 +208,11 @@ test_files:
|
|
205
208
|
- spec/data/commons-logging/pom.xml
|
206
209
|
- spec/data/nailgun/nailgun-0.7.1.jar
|
207
210
|
- spec/data/nailgun/pom.xml
|
211
|
+
- spec/data/struts-apps/pom.xml
|
208
212
|
- spec/data/tomcat/pom.xml
|
209
213
|
- spec/lib/get_pom_spec.rb
|
210
214
|
- spec/lib/get_source_address_spec.rb
|
211
215
|
- spec/lib/get_source_spec.rb
|
212
216
|
- spec/lib/pom_spec.rb
|
217
|
+
- spec/lib/version_matcher_spec.rb
|
213
218
|
- spec/spec_helper.rb
|