Fixed a bug in the update site build script.
Wrong class name of LWJGL plugin activator was specified (org.lwjgl.eclipse.Activator, but correct is org.lwjgl.Activator). Now, the current date/time string is added as a qualifier to the LWJGL version, e.g., org.lwjgl_2.8.2.v20111128-1653 instead of org.lwjgl_2.8.2. This simplifies testing and discouples LWJGL versions from plugin versions.
This commit is contained in:
parent
54664ef8cb
commit
b3b9eede8c
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src/java"/>
|
||||
<classpathentry kind="src" path="test/java"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src/java"/>
|
||||
<classpathentry kind="src" path="test/java"/>
|
||||
<classpathentry kind="output" path="anttasks"/>
|
||||
</classpath>
|
||||
|
|
|
@ -9,5 +9,6 @@ Import-Package: org.apache.tools.ant,
|
|||
org.apache.tools.ant.types,
|
||||
org.apache.tools.ant.types.selectors,
|
||||
org.apache.tools.ant.util,
|
||||
org.junit;version="4.8.1"
|
||||
org.junit;version="4"
|
||||
Bundle-Vendor: Lightweight Java Game Library Project
|
||||
Require-Bundle: org.junit;bundle-version="4.8.1"
|
||||
|
|
|
@ -54,7 +54,7 @@ Author: Jens von Pilgrim, developer@jevopi.de
|
|||
|
||||
|
||||
<target name="init">
|
||||
<normalizeversion version="${version}" property="normversion" />
|
||||
<normalizeversion version="${version}" property="normversion" addDateQualifier="yes" />
|
||||
<echo>Building plugins for version ${version}, normalized version ${normversion}</echo>
|
||||
</target>
|
||||
|
||||
|
@ -209,7 +209,7 @@ Bundle-Name: LWJGL Lightweight Java Game Library
|
|||
Bundle-SymbolicName: org.lwjgl
|
||||
Bundle-Version: ${normversion}
|
||||
Bundle-Vendor: ${bundle.vendor}
|
||||
Bundle-Activator: org.lwjgl.eclipse.Activator
|
||||
Bundle-Activator: org.lwjgl.Activator
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime
|
||||
Bundle-ActivationPolicy: lazy
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
******************************************************************************/
|
||||
package org.lwjgl.ant;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.tools.ant.BuildException;
|
||||
import org.apache.tools.ant.Task;
|
||||
|
||||
|
@ -24,7 +27,11 @@ import org.apache.tools.ant.Task;
|
|||
*/
|
||||
public class NormalizeVersion extends Task {
|
||||
|
||||
|
||||
public final static String SEGMENTS[] = { "major", "minor", "service",
|
||||
"qualifier" };
|
||||
|
||||
public final static String VERSION_QUALIFIER_PATTERN = "yyyyMMdd-HHmm";
|
||||
|
||||
/**
|
||||
* name of the property to set
|
||||
*/
|
||||
|
@ -32,6 +39,22 @@ public class NormalizeVersion extends Task {
|
|||
|
||||
protected String version;
|
||||
|
||||
protected boolean addDateQualifier = false;
|
||||
|
||||
/**
|
||||
* @return the addQualifier
|
||||
*/
|
||||
public boolean isAddDateQualifier() {
|
||||
return addDateQualifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i_addQualifier the addQualifier to set
|
||||
*/
|
||||
public void setAddDateQualifier(boolean i_addDateQualifier) {
|
||||
addDateQualifier = i_addDateQualifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the property
|
||||
*/
|
||||
|
@ -57,7 +80,7 @@ public class NormalizeVersion extends Task {
|
|||
* @param i_versionNumber the versionNumber to set
|
||||
*/
|
||||
public void setVersion(String version) {
|
||||
this.version =version;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,6 +95,30 @@ public class NormalizeVersion extends Task {
|
|||
if (version == null) {
|
||||
throw new BuildException("attribute version missing");
|
||||
}
|
||||
String s = getVersion().trim();
|
||||
int sn = 0;
|
||||
boolean qualifier = false;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (s.charAt(i) == '.') {
|
||||
sn++;
|
||||
} else {
|
||||
|
||||
qualifier = !Character.isDigit(s.charAt(i));
|
||||
if (sn < 1 && !Character.isDigit(s.charAt(i))) {
|
||||
|
||||
throw new BuildException(
|
||||
"Wrong version format, must contain only digits in the "
|
||||
+ SEGMENTS[sn] + " segment, was "
|
||||
+ s.substring(0, i) + ">>" + s.charAt(i)
|
||||
+ "<<" + s.substring(i + 1));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((sn > 2 || qualifier) && isAddDateQualifier()) {
|
||||
throw new BuildException(
|
||||
"Cannot add date qualifier, qualifier already specified");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -147,11 +194,11 @@ public class NormalizeVersion extends Task {
|
|||
}
|
||||
n.append(c);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!qualifier) {
|
||||
if (digits.length()>0) {
|
||||
if (digits.length() > 0) {
|
||||
if (snIndex > 0)
|
||||
n.append('.');
|
||||
n.append(digits);
|
||||
|
@ -166,8 +213,25 @@ public class NormalizeVersion extends Task {
|
|||
case 2: // e.g. "1.2.beta
|
||||
n.append(".0");
|
||||
}
|
||||
if (isAddDateQualifier())
|
||||
n.append(createDateQualifier());
|
||||
} else {
|
||||
if (isAddDateQualifier()) {
|
||||
throw new BuildException(
|
||||
"Cannot add date qualifier, qualifier already specified");
|
||||
}
|
||||
}
|
||||
|
||||
return n.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
private String createDateQualifier() {
|
||||
return ".v"
|
||||
+ new SimpleDateFormat(VERSION_QUALIFIER_PATTERN)
|
||||
.format(new Date());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,5 +67,42 @@ public class NormalizeVersionTest {
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testQualifier() {
|
||||
NormalizeVersion t = new NormalizeVersion();
|
||||
t.setProperty("normalized");
|
||||
t.setAddDateQualifier(true);
|
||||
|
||||
t.setVersion("1");
|
||||
String s = t.doExecute();
|
||||
Assert.assertEquals(20, s.length());
|
||||
Assert.assertTrue(s.startsWith("1.0.0"));
|
||||
|
||||
t.setVersion("1.2");
|
||||
s = t.doExecute();
|
||||
Assert.assertEquals(20, s.length());
|
||||
Assert.assertTrue(s.startsWith("1.2.0"));
|
||||
|
||||
t.setVersion("1.2.3");
|
||||
s = t.doExecute();
|
||||
Assert.assertEquals(20, s.length());
|
||||
Assert.assertTrue(s.startsWith("1.2.3"));
|
||||
|
||||
t.setVersion("2.8.2");
|
||||
s = t.doExecute();
|
||||
Assert.assertEquals(20, s.length());
|
||||
Assert.assertTrue(s.startsWith("2.8.2"));
|
||||
|
||||
}
|
||||
|
||||
@Test(expected= BuildException.class) public void dateQualifierWithQualifier() {
|
||||
NormalizeVersion t = new NormalizeVersion();
|
||||
t.setProperty("normalized");
|
||||
t.setAddDateQualifier(true);
|
||||
t.setVersion("1.2.beta");
|
||||
t.doExecute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue