public static void testBumpIncludeFile() throws Exception { File tmp = new File("tmp-ws"); if (tmp.exists()) IO.deleteWithException(tmp); tmp.mkdir(); assertTrue(tmp.isDirectory()); try { IO.copy(new File("test/ws"), tmp); Workspace ws = Workspace.getWorkspace(tmp); Project project = ws.getProject("bump-included"); project.setTrace(true); Version old = new Version(project.getProperty("Bundle-Version")); assertEquals(new Version(1, 0, 0), old); project.bump("=+0"); Processor processor = new Processor(); processor.setProperties(project.getFile("include.txt")); Version newv = new Version(processor.getProperty("Bundle-Version")); System.err.println("New version " + newv); assertEquals(1, newv.getMajor()); assertEquals(1, newv.getMinor()); assertEquals(0, newv.getMicro()); } finally { IO.deleteWithException(tmp); } }
public static void testBump() throws Exception { File tmp = new File("tmp-ws"); if (tmp.exists()) IO.deleteWithException(tmp); tmp.mkdir(); assertTrue(tmp.isDirectory()); try { IO.copy(new File("test/ws"), tmp); Workspace ws = Workspace.getWorkspace(tmp); Project project = ws.getProject("p1"); int size = project.getProperties().size(); Version old = new Version(project.getProperty("Bundle-Version")); System.err.println("Old version " + old); project.bump("=+0"); Version newv = new Version(project.getProperty("Bundle-Version")); System.err.println("New version " + newv); assertEquals(old.getMajor(), newv.getMajor()); assertEquals(old.getMinor() + 1, newv.getMinor()); assertEquals(0, newv.getMicro()); assertEquals(size, project.getProperties().size()); assertEquals("sometime", newv.getQualifier()); } finally { IO.deleteWithException(tmp); } }
private int compare(Revision a, Revision b) { if (Arrays.equals(a._id, b._id)) return 0; Version va = getVersion(a); Version vb = getVersion(b); int n = va.compareTo(vb); if (n != 0) return n; if (a.created != b.created) return a.created > b.created ? 1 : -1; for (int i = 0; i < a._id.length; i++) if (a._id[i] != b._id[i]) return a._id[i] > b._id[i] ? 1 : -1; return 0; }
String version(Version version, String mask) { if (version == null) { String v = domain.getProperty("@"); if (v == null) { domain.error( "No version specified for ${version} or ${range} and no implicit version ${@} either, mask=%s", mask); v = "0"; } version = new Version(v); } StringBuilder sb = new StringBuilder(); String del = ""; for (int i = 0; i < mask.length(); i++) { char c = mask.charAt(i); String result = null; if (c != '~') { if (i == 3) { result = version.getQualifier(); } else if (Character.isDigit(c)) { // Handle masks like +00, =+0 result = String.valueOf(c); } else { int x = version.get(i); switch (c) { case '+': x++; break; case '-': x--; break; case '=': break; } result = Integer.toString(x); } if (result != null) { sb.append(del); del = "."; sb.append(result); } } } return sb.toString(); }