Skip to content
Commits on Source (3)
## Version 1.7, released 16.10.2018
* [FIX] Fixed a regression. Always provide the proper relative paths in archives.
* [FIX] Upgraded deps
* [FIX] Windows fixes
* [ADD] Added example to show file and dirmode
* [ADD] Added support custom snapshot patterns (Thanks to Jamie Magee)
## Version 1.6, released 03.01.2018
* [CHG] Upgraded Commons Compress
......
......@@ -14,8 +14,8 @@ additional native tools installed.
Check the documentation on how to use it with [Maven](http://github.com/tcurdt/jdeb/blob/master/docs/maven.md)
or [Ant](http://github.com/tcurdt/jdeb/blob/master/docs/ant.md). Especially don't forget to check out the
[examples](http://github.com/tcurdt/jdeb/blob/master/src/examples/). Current
[javadocs](http://tcurdt.github.com/jdeb/release/1.6/apidocs/) and a source
[xref](http://tcurdt.github.com/jdeb/release/1.6/xref/) is also available.
[javadocs](http://tcurdt.github.com/jdeb/release/1.7/apidocs/) and a source
[xref](http://tcurdt.github.com/jdeb/release/1.7/xref/) is also available.
## Where to get it
......
jdeb (1.7-1) unstable; urgency=medium
* Team upload.
* New upstream version 1.7
* Update debian/watch to use xz compression
-- tony mancill <tmancill@debian.org> Sat, 27 Jul 2019 21:00:11 -0700
jdeb (1.6-4) unstable; urgency=medium
* Team upload.
......
version=3
version=4
opts="repack,compression=xz" \
https://github.com/tcurdt/jdeb/releases .*/jdeb-([\d\.]+).tar.gz
......@@ -9,7 +9,7 @@ the plugin to your POM like this
<plugin>
<artifactId>jdeb</artifactId>
<groupId>org.vafer</groupId>
<version>1.5</version>
<version>1.7</version>
<executions>
<execution>
<phase>package</phase>
......@@ -47,7 +47,7 @@ Or if you want to build a custom deb file
<extension>
<groupId>org.vafer</groupId>
<artifactId>jdeb</artifactId>
<version>1.5</version>
<version>1.7</version>
</extension>
</extensions>
<pluginManagement>
......@@ -114,7 +114,7 @@ task. To configure the jdeb maven plugin, populate the jdeb configuration
section with any of the following options:
Element | Description | Required
------------- | ---------------------------------------------------------------------------- | -----------------------------------------------------------------
---------------- | ------------------------------------------------------------------------------------------ | -----------------------------------------------------------------
deb | The debian package to be generated | No; defaults to `${buildDirectory}/${artifactId}_${version}.deb`
type | Artifact type | No; defaults to `deb`
classifier | Artifact classifier | No; defaults to ''
......@@ -135,12 +135,12 @@ passphrase | The passphrase to use the key
attach | Attach artifact to project | No; defaults to `true`
snapshotExpand | Expand SNAPSHOT into the content of an environment variable or timestamp. | No; defaults to `false`
snapshotEnv | Name of the environment variable. If it's empty defaults to a timestamp. | No; defaults to `SNAPSHOT`
snapshotTemplate | Template for replacing the SNAPSHOT value. A timestamp format can be provided in brackets. | No;
verbose | Verbose logging | No; defaults to `true`, will be `false` in the future
skip | Indicates if an execution should be skipped | No; defaults to `false`
skipSubmodules | Skip goal on all submodules | No; defaults to `false`
skipPOMs | Skip goal on POM artifacts | No; defaults to `true`
If you use the `dataSet` element, you'll need to populate it with a one or
more `data` elements. A `data` element is used to specify a directory, a
tarball archive, or a file. You can add as many data
......@@ -185,7 +185,7 @@ include a directory, a tarball, and a file in your deb package and then sign it
<plugin>
<artifactId>jdeb</artifactId>
<groupId>org.vafer</groupId>
<version>1.5</version>
<version>1.7</version>
<executions>
<execution>
<phase>package</phase>
......
......@@ -6,8 +6,8 @@
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<additionalparam>-Xdoclint:none</additionalparam>
<mavenVersion>3.5.2</mavenVersion>
<mavenPluginPluginVersion>3.5</mavenPluginPluginVersion>
<mavenVersion>3.5.4</mavenVersion>
<mavenPluginPluginVersion>3.5.2</mavenPluginPluginVersion>
</properties>
<modelVersion>4.0.0</modelVersion>
<groupId>org.vafer</groupId>
......@@ -17,7 +17,7 @@
<maven>3.0</maven>
</prerequisites>
<name>jdeb</name>
<version>1.6</version>
<version>1.7</version>
<description>
This library provides an Ant task and a Maven plugin to create Debian packages from Java builds in a truly cross
platform manner. Build your Debian packages on any platform that has Java support. Windows, Linux, OS X - it doesn't
......@@ -318,7 +318,7 @@
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.10.1</version>
<version>1.10.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
......@@ -345,19 +345,19 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.15</version>
<version>1.18</version>
<!-- <scope>provided</scope> -->
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpg-jdk15on</artifactId>
<version>1.58</version>
<version>1.60</version>
<!-- <scope>provided</scope> -->
</dependency>
<dependency>
<groupId>org.tukaani</groupId>
<artifactId>xz</artifactId>
<version>1.6</version>
<version>1.8</version>
<!-- <scope>provided</scope> -->
</dependency>
<dependency>
......@@ -369,7 +369,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.5</version>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
</dependencies>
......
......@@ -14,7 +14,7 @@
<plugin>
<artifactId>jdeb</artifactId>
<groupId>org.vafer</groupId>
<version>1.5</version>
<version>1.7</version>
<executions>
<execution>
<phase>package</phase>
......@@ -38,6 +38,7 @@
<prefix>/usr/share/jdeb/lib</prefix>
<user>loader</user>
<group>loader</group>
<filemode>640</filemode>
</mapper>
</data>
......@@ -45,7 +46,7 @@
<type>link</type>
<symlink>true</symlink>
<linkName>/usr/share/java/jdeb.jar</linkName>
<linkTarget>/usr/share/jdeb/lib/${project.build.finalName}.jar</linkTarget>
<linkTarget>lib/${project.build.finalName}.jar</linkTarget>
</data>
<data>
......@@ -71,6 +72,7 @@
<type>perm</type>
<user>loader</user>
<group>loader</group>
<filemode>750</filemode>
</mapper>
</data>
......
......@@ -56,8 +56,10 @@ public final class PermMapper implements Mapper {
}
public TarArchiveEntry map( final TarArchiveEntry entry ) {
final String name = entry.getName();
entry.setName(prefix + '/' + Utils.stripPath(strip, name));
entry.setName(Utils.joinUnixPath(
prefix,
Utils.stripPath(strip, entry.getName()
)));
// Set ownership
if (uid > -1) {
......
......@@ -252,6 +252,13 @@ public class DebMojo extends AbstractMojo {
@Parameter(defaultValue = "SNAPSHOT")
private String snapshotEnv;
/**
* Template for replacing the SNAPSHOT value. A timestamp format can be provided in brackets.
* prefix[yyMMdd]suffix -> prefix151230suffix
*/
@Parameter
private String snapshotTemplate;
/**
* If verbose is true more build messages are logged.
*/
......@@ -419,7 +426,7 @@ public class DebMojo extends AbstractMojo {
* @return the Maven project version
*/
private String getProjectVersion() {
return Utils.convertToDebianVersion(getProject().getVersion(), this.snapshotExpand, this.snapshotEnv, session.getStartTime());
return Utils.convertToDebianVersion(getProject().getVersion(), this.snapshotExpand, this.snapshotEnv, this.snapshotTemplate, session.getStartTime());
}
/**
......
......@@ -72,7 +72,8 @@ public abstract class AbstractDataProducer implements DataProducer {
public void produceDir( final DataConsumer consumer,
final String dirName ) throws IOException {
TarArchiveEntry entry = Producers.defaultDirEntryWithName(dirName);
final String name = dirName.endsWith("/") ? dirName : dirName + "/";
TarArchiveEntry entry = Producers.defaultDirEntryWithName(name);
entry = map(entry);
entry.setSize(0);
Producers.produceDirEntry(consumer, entry);
......
......@@ -84,6 +84,28 @@ public final class Utils {
return s.substring(x + 1);
}
private static String joinPath(char sep, String ...paths) {
final StringBuilder sb = new StringBuilder();
for (String p : paths) {
if (p == null) continue;
if (p.startsWith("/")) {
sb.append(p);
} else {
sb.append(sep);
sb.append(p);
}
}
return sb.toString();
}
public static String joinUnixPath(String ...paths) {
return joinPath('/', paths);
}
public static String joinLocalPath(String ...paths) {
return joinPath(File.separatorChar, paths);
}
public static String stripLeadingSlash( final String s ) {
if (s == null) {
return s;
......@@ -116,6 +138,10 @@ public final class Utils {
int level = 0;
for (char c : pExpression.toCharArray()) {
if (c == open[wo]) {
if (wc > 0) {
sb.append(close, 0, wc);
}
wc = 0;
wo++;
if (open.length == wo) {
// found open
......@@ -129,6 +155,10 @@ public final class Utils {
last = open;
}
} else if (c == close[wc]) {
if (wo > 0) {
sb.append(open, 0, wo);
}
wo = 0;
wc++;
if (close.length == wc) {
// found close
......@@ -198,6 +228,20 @@ public final class Utils {
return filteredFile.toByteArray();
}
private static String formatSnapshotTemplate( String template, Date timestamp ) {
int startBracket = template.indexOf('[');
int endBracket = template.indexOf(']');
if(startBracket == -1 || endBracket == -1) {
return template;
} else {
// prefix[yyMMdd]suffix
final String date = new SimpleDateFormat(template.substring(startBracket + 1, endBracket)).format(timestamp);
String datePrefix = startBracket == 0 ? "" : template.substring(0, startBracket);
String dateSuffix = endBracket == template.length() ? "" : template.substring(endBracket + 1);
return datePrefix + date + dateSuffix;
}
}
/**
* Convert the project version to a version suitable for a Debian package.
* -SNAPSHOT suffixes are replaced with a timestamp (~yyyyMMddHHmmss).
......@@ -205,21 +249,26 @@ public final class Utils {
* such that the version is always ordered before the final or GA release.
*
* @param version the project version to convert to a Debian package version
* @param template the template used to replace -SNAPSHOT, the timestamp format is in brackets,
* the rest of the string is preserved (prefix[yyMMdd]suffix -> prefix151230suffix)
* @param timestamp the UTC date used as the timestamp to replace the SNAPSHOT suffix.
*/
public static String convertToDebianVersion( String version, boolean apply, String envName, Date timestamp ) {
public static String convertToDebianVersion( String version, boolean apply, String envName, String template, Date timestamp ) {
Matcher matcher = SNAPSHOT_PATTERN.matcher(version);
if (matcher.matches()) {
version = matcher.group(1) + "~";
if (apply) {
final String envValue = System.getenv(envName);
if(template != null && template.length() > 0) {
version += formatSnapshotTemplate(template, timestamp);
} else if (envValue != null && envValue.length() > 0) {
version += envValue;
} else {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
final String snapshot = (envValue != null && envValue.length() > 0)
? envValue
: dateFormat.format(timestamp);
version += snapshot;
version += dateFormat.format(timestamp);
}
} else {
version += "SNAPSHOT";
}
......@@ -283,20 +332,20 @@ public final class Utils {
// The user's roaming profile on Windows, via environment
final String windowsRoaming = System.getenv("APPDATA");
if (windowsRoaming != null) {
locations.add(joinPaths(windowsRoaming, "gnupg", "secring.gpg"));
locations.add(joinLocalPath(windowsRoaming, "gnupg", "secring.gpg"));
}
// The user's local profile on Windows, via environment
final String windowsLocal = System.getenv("LOCALAPPDATA");
if (windowsLocal != null) {
locations.add(joinPaths(windowsLocal, "gnupg", "secring.gpg"));
locations.add(joinLocalPath(windowsLocal, "gnupg", "secring.gpg"));
}
// The Windows installation directory
final String windir = System.getProperty("WINDIR");
if (windir != null) {
// Local Profile on Windows 98 and ME
locations.add(joinPaths(windir, "Application Data", "gnupg", "secring.gpg"));
locations.add(joinLocalPath(windir, "Application Data", "gnupg", "secring.gpg"));
}
}
......@@ -307,18 +356,18 @@ public final class Utils {
// if the environment variables above have failed
// Roaming profile on Vista and later
locations.add(joinPaths(home, "AppData", "Roaming", "gnupg", "secring.gpg"));
locations.add(joinLocalPath(home, "AppData", "Roaming", "gnupg", "secring.gpg"));
// Local profile on Vista and later
locations.add(joinPaths(home, "AppData", "Local", "gnupg", "secring.gpg"));
locations.add(joinLocalPath(home, "AppData", "Local", "gnupg", "secring.gpg"));
// Roaming profile on 2000 and XP
locations.add(joinPaths(home, "Application Data", "gnupg", "secring.gpg"));
locations.add(joinLocalPath(home, "Application Data", "gnupg", "secring.gpg"));
// Local profile on 2000 and XP
locations.add(joinPaths(home, "Local Settings", "Application Data", "gnupg", "secring.gpg"));
locations.add(joinLocalPath(home, "Local Settings", "Application Data", "gnupg", "secring.gpg"));
}
// *nix, including OS X
if (home != null) {
locations.add(joinPaths(home, ".gnupg", "secring.gpg"));
locations.add(joinLocalPath(home, ".gnupg", "secring.gpg"));
}
return locations;
......@@ -350,32 +399,6 @@ public final class Utils {
throw new FileNotFoundException(message.toString());
}
/**
* Join together path elements with File.separator. Filters out null
* elements.
*
* @param elements The path elements to join
* @return elements concatenated together with File.separator
*/
public static String joinPaths(String... elements) {
StringBuilder builder = new StringBuilder();
boolean first = true;
for (String element : elements) {
// Skip null elements
if (element == null) {
// This won't change the value of first if we skip elements
// in the beginning of the array
continue;
}
if (!first) {
builder.append(File.separatorChar);
}
builder.append(element);
first = false;
}
return builder.toString();
}
/**
* Returns true if string is null or empty.
*/
......
......@@ -61,13 +61,21 @@ public final class DataProducerFilesTestCase extends Assert {
return false;
}
final TarArchiveEntry e = (TarArchiveEntry) o;
return e.getSize() == f.length()
final String name = "/usr/include/" + f.getName();
boolean matches =
e.getSize() == f.length()
&& e.getLongGroupId() == 0
&& e.getLongUserId() == 0
&& "root".equals(e.getUserName())
&& "root".equals(e.getGroupName())
&& ("/usr/include/" + f.getName()).equals(e.getName())
&& name.equals(e.getName())
;
// System.out.println("matches:" + matches);
return matches;
}
public void describeTo(final Description description) {
......@@ -99,19 +107,34 @@ public final class DataProducerFilesTestCase extends Assert {
}
final TarArchiveEntry e = (TarArchiveEntry) o;
// Turns out compress is stripping the drive letter
// https://github.com/apache/commons-compress/blob/master/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java#L1337
// Which is bad - but needs to be fixed there.
// We have to work around in the test for now.
final String s = f.getAbsolutePath().replace(File.separator, "/").replace("C:/", "/");
final String name = f.getAbsolutePath().replace(File.separator, "/");
return e.getSize() == f.length()
boolean matches =
e.getSize() == f.length()
&& e.getLongGroupId() == 0
&& e.getLongUserId() == 0
&& "root".equals(e.getUserName())
&& "root".equals(e.getGroupName())
&& s.equals(e.getName())
&& name.equals(e.getName())
;
// System.out.println("matches:" + matches);
// if (!matches) {
// System.out.println("f.size:" + f.length());
// System.out.println("e.size:" + e.getSize());
// System.out.println("f.name:" + name);
// System.out.println("e.name:" + e.getName());
// System.out.println("e.uid:" + e.getLongUserId());
// System.out.println("e.gid:" + e.getLongGroupId());
// System.out.println("e.uid:" + e.getUserName());
// System.out.println("e.gid:" + e.getGroupName());
// }
return matches;
}
public void describeTo(final Description description) {
......
......@@ -42,14 +42,14 @@ public final class DataProducerPathTemplateTestCase extends Assert {
@Test
public void testTypical() throws Exception {
String[] paths = { "/var/log", "/var/lib" };
String[] paths = { "/var/log/", "/var/lib/" };
dataProducer = new DataProducerPathTemplate(paths, INCLUDES, EXCLUDES, mappers);
dataProducer.produce(captureDataConsumer);
assertEquals(2, captureDataConsumer.invocations.size());
CaptureDataConsumer.Invocation invocation = captureDataConsumer.invocations.get(0);
assertEquals(invocation.dirname, "/var/log");
assertEquals(invocation.dirname, "/var/log/");
assertEquals(invocation.gid, 0);
assertEquals(invocation.group, "root");
assertEquals(invocation.linkname, "");
......@@ -59,7 +59,7 @@ public final class DataProducerPathTemplateTestCase extends Assert {
assertEquals(invocation.user, "root");
invocation = captureDataConsumer.invocations.get(1);
assertEquals(invocation.dirname, "/var/lib");
assertEquals(invocation.dirname, "/var/lib/");
assertEquals(invocation.gid, 0);
assertEquals(invocation.group, "root");
assertEquals(invocation.linkname, "");
......
......@@ -60,10 +60,21 @@ public final class PGPSignerTestCase extends Assert {
signer.clearSign(input, os);
final byte[] output = fixCRLF(os.toByteArray());
final int from = expectedOutputStr.indexOf("iEYEAREC");
final int until = expectedOutputStr.indexOf("=aAAT") + 5;
Arrays.fill(output, from, until, (byte) '?');
Arrays.fill(expectedOutput, from, until, (byte) '?');
final int sign_from = expectedOutputStr.indexOf("iEYEAREC");
final int sign_until = expectedOutputStr.indexOf("=aAAT") + 5;
Arrays.fill(output,
sign_from, sign_until, (byte) '?');
Arrays.fill(expectedOutput,
sign_from, sign_until, (byte) '?');
final int version_from = expectedOutputStr.indexOf("v1.");
final int version_until = expectedOutputStr.indexOf("\n", sign_from) - 1;
Arrays.fill(output,
version_from, version_until, (byte) '?');
Arrays.fill(expectedOutput,
version_from, version_until, (byte) '?');
assertEquals(new String(expectedOutput), new String(output));
}
......
......@@ -53,12 +53,25 @@ public final class FilteredFileTestCase extends Assert {
@Test
public void testTokenSubstitutionWithinOpenCloseTokens() throws Exception {
InputStream in = new ReaderInputStream(new StringReader("#!/bin/bash\nif [[ -z \"$(grep [[artifactId]] /etc/passwd )\" ]] ; then\n"));
HashMap<String, String> table = new HashMap<String, String>() {{
put("#!/bin/bash\nif [[ -z \"$(grep [[artifactId]] /etc/passwd )\" ]] ; then\n",
"#!/bin/bash\nif [[ -z \"$(grep jdeb /etc/passwd )\" ]] ; then\n");
put("#!/usr/bin/python3 -B\nline = line.replace(\'@ALLOW_BATCH_FILTER@\', config[self.client][\'ALLOW_BATCH_FILTER\'])\n",
"#!/usr/bin/python3 -B\nline = line.replace(\'@ALLOW_BATCH_FILTER@\', config[self.client][\'ALLOW_BATCH_FILTER\'])\n");
}};
for (Map.Entry<String,String> pair : table.entrySet()){
String input = pair.getKey();
String expected = pair.getValue();
InputStream in = new ReaderInputStream(new StringReader(input));
FilteredFile placeHolder = new FilteredFile(in, variableResolver);
String actual = placeHolder.toString();
assertEquals("", "#!/bin/bash\nif [[ -z \"$(grep jdeb /etc/passwd )\" ]] ; then\n", actual);
assertEquals("unexpected resolve for " + input, expected, actual);
}
}
@Test
......
......@@ -28,6 +28,13 @@ import org.junit.Assert;
public final class UtilsTestCase extends Assert {
@Test
public void testJoinPath() throws Exception {
assertEquals("", "/foo/bar", Utils.joinUnixPath(null, "foo", "bar"));
assertEquals("", "/foo/bar", Utils.joinUnixPath(null, "/foo", "/bar"));
assertEquals("", "/foo/bar", Utils.joinUnixPath(null, "foo/bar"));
}
@Test
public void testStripPath() throws Exception {
assertEquals("foo/bar", Utils.stripPath(0, "foo/bar"));
......@@ -77,8 +84,10 @@ public final class UtilsTestCase extends Assert {
VariableResolver resolver = new MapVariableResolver(variables);
String input, result;
// main case
String result = Utils.replaceVariables(resolver, "Version: [[version]]", "[[", "]]");
result = Utils.replaceVariables(resolver, "Version: [[version]]", "[[", "]]");
assertEquals("Version: 1.2.3", result);
// multiple variables in the same expression
......@@ -89,8 +98,13 @@ public final class UtilsTestCase extends Assert {
result = Utils.replaceVariables(resolver, "if [[ \"${HOST_TYPE}\" -eq \"admin\" ]] ; then", "[[", "]]");
assertEquals("if [[ \"${HOST_TYPE}\" -eq \"admin\" ]] ; then", result);
// collision with python syntax
input = "c[t][\'A\']";
result = Utils.replaceVariables(resolver, input, "[[", "]]");
assertEquals(input, result);
// end of line https://github.com/tcurdt/jdeb/issues/154
String input = "if [ -e some_file ]";
input = "if [ -e some_file ]";
result = Utils.replaceVariables(resolver, input, "[[", "]]");
assertEquals(input, result);
......@@ -125,47 +139,57 @@ public final class UtilsTestCase extends Assert {
public void testVersionConversion() {
Calendar cal = new GregorianCalendar(2013, Calendar.FEBRUARY, 17);
cal.setTimeZone(TimeZone.getTimeZone("UTC"));
assertEquals("should match", "1.0", Utils.convertToDebianVersion("1.0", false, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0~SNAPSHOT", Utils.convertToDebianVersion("1.0+SNAPSHOT", false, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0~SNAPSHOT", Utils.convertToDebianVersion("1.0-SNAPSHOT", false, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0~20130217000000", Utils.convertToDebianVersion("1.0+SNAPSHOT", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0~RC2", Utils.convertToDebianVersion("1.0-RC2", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0~alpha3", Utils.convertToDebianVersion("1.0-alpha3", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0~Beta+4", Utils.convertToDebianVersion("1.0.Beta-4", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0~milestone+4", Utils.convertToDebianVersion("1.0-milestone-4", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0~a+4", Utils.convertToDebianVersion("1.0-a-4", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0~a+4", Utils.convertToDebianVersion("1.0a-4", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0~b+4", Utils.convertToDebianVersion("1.0-b-4", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0~rc7", Utils.convertToDebianVersion("1.0rc7", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0~M1", Utils.convertToDebianVersion("1.0.M1", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0~M2", Utils.convertToDebianVersion("1.0-M2", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0~M3", Utils.convertToDebianVersion("1.0M3", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+prj+3", Utils.convertToDebianVersion("1.0-prj_3", false, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+prj+3~SNAPSHOT", Utils.convertToDebianVersion("1.0-prj_3+SNAPSHOT", false, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+prj+3~SNAPSHOT", Utils.convertToDebianVersion("1.0-prj_3-SNAPSHOT", false, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+prj+3~20130217000000", Utils.convertToDebianVersion("1.0-prj_3+SNAPSHOT", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+prj+3~RC2", Utils.convertToDebianVersion("1.0-prj_3-RC2", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+prj+3~alpha3", Utils.convertToDebianVersion("1.0-prj_3-alpha3", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+prj+3~Beta+4", Utils.convertToDebianVersion("1.0-prj_3.Beta-4", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+prj+3~milestone+4", Utils.convertToDebianVersion("1.0-prj_3-milestone-4", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+prj+3~a+4", Utils.convertToDebianVersion("1.0-prj_3-a-4", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+prj+3~b+4", Utils.convertToDebianVersion("1.0-prj_3-b-4", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+prj+3~rc7", Utils.convertToDebianVersion("1.0-prj_3-rc7", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+prj+3~M1", Utils.convertToDebianVersion("1.0-prj_3.M1", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+prj+3~M2", Utils.convertToDebianVersion("1.0-prj_3-M2", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+prj~M3", Utils.convertToDebianVersion("1.0-prj_M3", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+prj+~M3", Utils.convertToDebianVersion("1.0-prj__-M3", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+prj+.+~M3", Utils.convertToDebianVersion("1.0-prj_._-M3", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+prj+3+~M3", Utils.convertToDebianVersion("1.0-prj_3:M3", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+prj+3+c+~20130217000000", Utils.convertToDebianVersion("1.0-prj_3-c++-SNAPSHOT", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+prj+3+c+~20130217000000", Utils.convertToDebianVersion("1.0-prj_3-c+++++++-SNAPSHOT", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+MMM+3", Utils.convertToDebianVersion("1.0-MMM-3", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+aaa+3", Utils.convertToDebianVersion("1.0-aaa-3", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0+bbb+3", Utils.convertToDebianVersion("1.0-bbb-3", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0aaa+3", Utils.convertToDebianVersion("1.0aaa-3", true, "SNAPSHOT", cal.getTime()));
assertEquals("should match", "1.0", Utils.convertToDebianVersion("1.0", false, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0~SNAPSHOT", Utils.convertToDebianVersion("1.0+SNAPSHOT", false, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0~SNAPSHOT", Utils.convertToDebianVersion("1.0-SNAPSHOT", false, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0~20130217000000", Utils.convertToDebianVersion("1.0+SNAPSHOT", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0~RC2", Utils.convertToDebianVersion("1.0-RC2", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0~alpha3", Utils.convertToDebianVersion("1.0-alpha3", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0~Beta+4", Utils.convertToDebianVersion("1.0.Beta-4", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0~milestone+4", Utils.convertToDebianVersion("1.0-milestone-4", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0~a+4", Utils.convertToDebianVersion("1.0-a-4", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0~a+4", Utils.convertToDebianVersion("1.0a-4", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0~b+4", Utils.convertToDebianVersion("1.0-b-4", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0~rc7", Utils.convertToDebianVersion("1.0rc7", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0~M1", Utils.convertToDebianVersion("1.0.M1", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0~M2", Utils.convertToDebianVersion("1.0-M2", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0~M3", Utils.convertToDebianVersion("1.0M3", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+prj+3", Utils.convertToDebianVersion("1.0-prj_3", false, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+prj+3~SNAPSHOT", Utils.convertToDebianVersion("1.0-prj_3+SNAPSHOT", false, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+prj+3~SNAPSHOT", Utils.convertToDebianVersion("1.0-prj_3-SNAPSHOT", false, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+prj+3~20130217000000", Utils.convertToDebianVersion("1.0-prj_3+SNAPSHOT", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+prj+3~RC2", Utils.convertToDebianVersion("1.0-prj_3-RC2", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+prj+3~alpha3", Utils.convertToDebianVersion("1.0-prj_3-alpha3", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+prj+3~Beta+4", Utils.convertToDebianVersion("1.0-prj_3.Beta-4", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+prj+3~milestone+4", Utils.convertToDebianVersion("1.0-prj_3-milestone-4", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+prj+3~a+4", Utils.convertToDebianVersion("1.0-prj_3-a-4", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+prj+3~b+4", Utils.convertToDebianVersion("1.0-prj_3-b-4", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+prj+3~rc7", Utils.convertToDebianVersion("1.0-prj_3-rc7", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+prj+3~M1", Utils.convertToDebianVersion("1.0-prj_3.M1", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+prj+3~M2", Utils.convertToDebianVersion("1.0-prj_3-M2", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+prj~M3", Utils.convertToDebianVersion("1.0-prj_M3", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+prj+~M3", Utils.convertToDebianVersion("1.0-prj__-M3", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+prj+.+~M3", Utils.convertToDebianVersion("1.0-prj_._-M3", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+prj+3+~M3", Utils.convertToDebianVersion("1.0-prj_3:M3", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+prj+3+c+~20130217000000", Utils.convertToDebianVersion("1.0-prj_3-c++-SNAPSHOT", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+prj+3+c+~20130217000000", Utils.convertToDebianVersion("1.0-prj_3-c+++++++-SNAPSHOT", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+MMM+3", Utils.convertToDebianVersion("1.0-MMM-3", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+aaa+3", Utils.convertToDebianVersion("1.0-aaa-3", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0+bbb+3", Utils.convertToDebianVersion("1.0-bbb-3", true, "SNAPSHOT", null, cal.getTime()));
assertEquals("should match", "1.0aaa+3", Utils.convertToDebianVersion("1.0aaa-3", true, "SNAPSHOT", null, cal.getTime()));
}
public void testVersionConversionWithTemplate() {
Calendar cal = new GregorianCalendar(2013, Calendar.FEBRUARY, 17);
assertEquals("should match", "1.0~20130217000000", Utils.convertToDebianVersion("1.0+SNAPSHOT", true, "SNAPSHOT", "[yyyyMMddHHmmss]", cal.getTime()));
assertEquals("should match", "1.0~130217000000", Utils.convertToDebianVersion("1.0+SNAPSHOT", true, "SNAPSHOT", "[yyMMddHHmmss]", cal.getTime()));
assertEquals("should match", "1.0~20130217", Utils.convertToDebianVersion("1.0+SNAPSHOT", true, "SNAPSHOT", "[yyyyMMdd]", cal.getTime()));
assertEquals("should match", "1.0~100.20130217", Utils.convertToDebianVersion("1.0+SNAPSHOT", true, "SNAPSHOT", "100.[yyyyMMdd]", cal.getTime()));
assertEquals("should match", "1.0~100.20130217.50", Utils.convertToDebianVersion("1.0+SNAPSHOT", true, "SNAPSHOT", "100.[yyyyMMdd].50", cal.getTime()));
assertEquals("should match", "1.0~100.20130217.foo", Utils.convertToDebianVersion("1.0+SNAPSHOT", true, "SNAPSHOT", "100.[yyyyMMdd].foo", cal.getTime()));
}
@Test
......