- add ant task to update NetBeans module dependencies from a base platforms module versions
- cleanup some stuff in the ant tasks, add local test code for downloading external wiki images (inactive)

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10191 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 12 years ago
parent d7ab4f8dcf
commit dbef55b6f9
  1. BIN
      sdk/ant-jme/lib/CopyLibs-2/org-netbeans-modules-java-j2seproject-copylibstask.jar
  2. 3
      sdk/ant-jme/lib/nblibraries.properties
  3. 126
      sdk/ant-jme/nbproject/build-impl.xml
  4. 4
      sdk/ant-jme/nbproject/genfiles.properties
  5. 2
      sdk/ant-jme/src/com/jme/ant/FixWikiLinks.java
  6. 27
      sdk/ant-jme/src/com/jme/ant/LoadWikiImages.java
  7. 169
      sdk/ant-jme/src/com/jme/ant/UpdateNetBeansDependencies.java
  8. 1
      sdk/ant-jme/src/com/jme/ant/ant-jme.properties
  9. BIN
      sdk/ant-lib/ant-jme.jar

@ -1,5 +1,6 @@
libs.ANT.classpath=\
${base}/ANT/ant.jar
libs.CopyLibs.classpath=\
${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar
${base}/CopyLibs-2/org-netbeans-modules-java-j2seproject-copylibstask.jar
libs.CopyLibs.displayName=CopyLibs Task
libs.CopyLibs.prop-version=1.0

@ -523,39 +523,66 @@ is divided into following sections:
</sequential>
</macrodef>
</target>
<target if="${junit.available}" name="-init-macrodef-junit-debug">
<target if="${junit.available}" name="-init-macrodef-junit-debug" unless="${nb.junit.batch}">
<macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${main.class}" name="testClass"/>
<attribute default="" name="testMethod"/>
<element name="customize2" optional="true"/>
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
<attribute default="**" name="testincludes"/>
<attribute default="" name="testmethods"/>
<element name="customize" optional="true"/>
<sequential>
<property location="${build.test.results.dir}/TEST-@{testClass}.xml" name="test.report.file"/>
<delete file="${test.report.file}"/>
<mkdir dir="${build.test.results.dir}"/>
<condition else="" property="junit.methods.arg" value="methods=@{testMethod}">
<isset property="test.method"/>
</condition>
<j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
<customize>
<arg value="@{testClass}"/>
<arg value="${junit.methods.arg}"/>
<arg value="showoutput=true"/>
<arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
<arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
<customize2/>
</customize>
</j2seproject3:debug>
<property name="junit.forkmode" value="perTest"/>
<junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
<test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
<mapper from="test-sys-prop.*" to="*" type="glob"/>
</syspropertyset>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<jvmarg value="-ea"/>
<jvmarg line="${debug-args-line}"/>
<jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
<customize/>
</junit>
</sequential>
</macrodef>
</target>
<target if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
<macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
<attribute default="**" name="testincludes"/>
<attribute default="" name="testmethods"/>
<element name="customize" optional="true"/>
<sequential>
<property name="junit.forkmode" value="perTest"/>
<junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
<batchtest todir="${build.test.results.dir}"/>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
<mapper from="test-sys-prop.*" to="*" type="glob"/>
</syspropertyset>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<jvmarg value="-ea"/>
<jvmarg line="${debug-args-line}"/>
<jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
<customize/>
</junit>
</sequential>
</macrodef>
</target>
<target depends="-init-macrodef-junit-debug" if="${junit.available}" name="-init-macrodef-junit-debug-impl">
<target depends="-init-macrodef-junit-debug,-init-macrodef-junit-debug-batch" if="${junit.available}" name="-init-macrodef-junit-debug-impl">
<macrodef name="test-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${main.class}" name="testClass"/>
<attribute default="" name="testMethod"/>
<element implicit="true" name="customize2" optional="true"/>
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
<attribute default="**" name="testincludes"/>
<attribute default="" name="testmethods"/>
<element implicit="true" name="customize" optional="true"/>
<sequential>
<j2seproject3:junit-debug testClass="@{testClass}" testMethod="@{testMethod}">
<customize2/>
<j2seproject3:junit-debug excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
<customize/>
</j2seproject3:junit-debug>
</sequential>
</macrodef>
@ -588,7 +615,7 @@ is divided into following sections:
</macrodef>
</target>
<target depends="-init-macrodef-testng-debug" if="${testng.available}" name="-init-macrodef-testng-debug-impl">
<macrodef name="test-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
<macrodef name="testng-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${main.class}" name="testClass"/>
<attribute default="" name="testMethod"/>
<element implicit="true" name="customize2" optional="true"/>
@ -599,22 +626,49 @@ is divided into following sections:
</sequential>
</macrodef>
</target>
<target depends="-init-macrodef-junit-debug-impl,-init-macrodef-testng-debug-impl" name="-init-macrodef-test-debug">
<target depends="-init-macrodef-junit-debug-impl" if="${junit.available}" name="-init-macrodef-test-debug-junit">
<macrodef name="test-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
<attribute default="**" name="testincludes"/>
<attribute default="" name="testmethods"/>
<attribute default="${main.class}" name="testClass"/>
<attribute default="" name="testMethod"/>
<sequential>
<j2seproject3:test-debug-impl testClass="@{testClass}" testMethod="@{testMethod}">
<j2seproject3:test-debug-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
<customize>
<classpath>
<path path="${run.test.classpath}"/>
</classpath>
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg line="${run.jvmargs}"/>
<jvmarg line="${run.jvmargs.ide}"/>
</customize>
</j2seproject3:test-debug-impl>
</sequential>
</macrodef>
</target>
<target depends="-init-macrodef-testng-debug-impl" if="${testng.available}" name="-init-macrodef-test-debug-testng">
<macrodef name="test-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
<attribute default="**" name="testincludes"/>
<attribute default="" name="testmethods"/>
<attribute default="${main.class}" name="testClass"/>
<attribute default="" name="testMethod"/>
<sequential>
<j2seproject3:testng-debug-impl testClass="@{testClass}" testMethod="@{testMethod}">
<customize2>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
<mapper from="test-sys-prop.*" to="*" type="glob"/>
</syspropertyset>
</customize2>
</j2seproject3:test-debug-impl>
</j2seproject3:testng-debug-impl>
</sequential>
</macrodef>
</target>
<target depends="-init-macrodef-test-debug-junit,-init-macrodef-test-debug-testng" name="-init-macrodef-test-debug"/>
<!--
pre NB7.2 profiling section; consider it deprecated
-->
@ -775,6 +829,9 @@ is divided into following sections:
<path path="${run.classpath.without.build.classes.dir}"/>
<chainedmapper>
<flattenmapper/>
<filtermapper>
<replacestring from=" " to="%20"/>
</filtermapper>
<globmapper from="*" to="lib/*"/>
</chainedmapper>
</pathconvert>
@ -1252,13 +1309,14 @@ is divided into following sections:
TEST DEBUGGING SECTION
=======================
-->
<target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
<target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test">
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>
<j2seproject3:test-debug testClass="${test.class}"/>
<j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testincludes="${javac.includes}"/>
</target>
<target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test-method">
<target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test-method">
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>
<j2seproject3:test-debug testClass="${test.class}" testMethod="${test.method}"/>
<fail unless="test.method">Must select some method in the IDE or set test.method</fail>
<j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testMethod="${test.method}" testincludes="${test.class}" testmethods="${test.method}"/>
</target>
<target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
<j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>

@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.38.2.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=dd1578ef
nbproject/build-impl.xml.script.CRC32=e46589cd
nbproject/build-impl.xml.stylesheet.CRC32=5183f3c0@1.51.1.46
nbproject/build-impl.xml.script.CRC32=a6e22d49
nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46

@ -40,6 +40,8 @@ public class FixWikiLinks extends Task {
line = line.replaceAll("/wiki/lib/exe/fetch\\.php/([^>]*):([^>]*):([^>]*)\"", "nbdocs:/" + helpPath + "$1/$2/$3\"");
line = line.replaceAll("/wiki/lib/exe/fetch\\.php/([^>]*):([^>]*)\"", "nbdocs:/" + helpPath + "$1/$2\"");
line = line.replaceAll("/wiki/lib/exe/fetch\\.php/([^>]*)\"", "nbdocs:/" + helpPath + "$1\"");
// line = line.replaceAll("/wiki/lib/exe/fetch\\.php?([^>]*)\"", "nbdocs:/" + helpPath + "external/$1\"").replaceAll("[_[^\\w\\däüö:ÄÜÖ\\/\\+\\-\\. ]]", "_");
line = line.replaceAll("<a href=([^>]*)><img src=\"([^\"]*)\"([^>]*)></a>", "<img src=\"$2\">");
line = line.replaceAll("<img src=\"([^>]*)\\?([^>]*)\">", "<img src=\"$1\">");
// vvvv------v

@ -38,6 +38,8 @@ public class LoadWikiImages extends Task {
if (endIdx >= 0) {
String link = line.substring(idx + 10, endIdx);
int wikidx = link.indexOf("/wiki/lib/exe/fetch.php/");
//int extidx = link.indexOf("/wiki/lib/exe/fetch.php?");
int extidx = -1;
if (wikidx >= 0) {
String name = link.replaceAll("/wiki/lib/exe/fetch\\.php/", "");
int markIdx = name.indexOf("?");
@ -48,7 +50,30 @@ public class LoadWikiImages extends Task {
URL url = new URL(host + link);
InputStream in = url.openStream();
File file = new File(getLocation().getFileName().replaceAll("build.xml", "") + File.separator + targetFolder + File.separator + name.replaceAll("/", File.separator));
log("Getting: " + host + link);
log("Getting image: " + host + link);
log("To: " + file);
File parent = file.getParentFile();
parent.mkdirs();
FileOutputStream out = new FileOutputStream(file);
int byte_ = in.read();
while (byte_ != -1) {
out.write(byte_);
byte_ = in.read();
}
in.close();
out.close();
}else if(extidx >= 0){
String name = link.replaceAll("/wiki/lib/exe/fetch\\.php\\?([^>]*);media=([^>]*)\"", "");
int markIdx = name.indexOf("?");
if (markIdx >= 0) {
name = name.substring(0, markIdx);
}
//make external folder and clean filename
name = "external/" + name.replaceAll("[_[^\\w\\däüöÄÜÖ\\/\\+\\-\\. ]]", "_");
URL url = new URL(host + link);
InputStream in = url.openStream();
File file = new File(getLocation().getFileName().replaceAll("build.xml", "") + File.separator + targetFolder + File.separator + name.replaceAll("/", File.separator));
log("Getting external image: " + host + link);
log("To: " + file);
File parent = file.getParentFile();
parent.mkdirs();

@ -0,0 +1,169 @@
package com.jme.ant;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.LogLevel;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
/**
*
* @author normenhansen
*/
public class UpdateNetBeansDependencies extends Task {
File projectFile;
File platformFolder;
private HashMap<String, String> versionMap = new HashMap<String, String>();
@Override
public void execute() throws BuildException {
if (projectFile == null || platformFolder == null) {
throw new BuildException("Please set projectfile and version");
}
clearVesionMap();
gatherVersionMap(platformFolder);
try {
boolean change = false;
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(projectFile);
Element project = doc.getDocumentElement();
if (project == null) {
return;
}
Element configuration = findChildElement(project, "configuration");
if (configuration == null) {
return;
}
Element data = findChildElement(configuration, "data");
if (data == null) {
return;
}
Element deps = findChildElement(data, "module-dependencies");
if (deps == null) {
return;
}
NodeList list = deps.getElementsByTagName("dependency");
for (int i = 0; i < list.getLength(); i++) {
Element elem = (Element) list.item(i);
Element base = findChildElement(elem, "code-name-base");
if (base != null) {
Element runDep = findChildElement(elem, "run-dependency");
if (runDep != null) {
Element specVersion = findChildElement(runDep, "specification-version");
if (specVersion != null) {
String name = base.getTextContent().trim();
String version = specVersion.getTextContent().trim();
String newVersion = versionMap.get(name);
if (newVersion != null && !newVersion.equals(version)) {
specVersion.setTextContent(newVersion);
change = true;
log("Updating dependency in for " + name + " to " + newVersion);
} else {
log("Unknown " + name + ", cannot update dependency.", LogLevel.WARN.getLevel());
}
}
}
}
}
if (change) {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(projectFile);
transformer.transform(source, result);
OutputStreamWriter out = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(projectFile, true)));
out.write("\n");
out.close();
}
} catch (Exception ex) {
throw new BuildException("Error changing file: " + ex);
}
}
public void setProjectFile(File projectFile) {
this.projectFile = projectFile;
}
public void setPlatformFolder(File platformFolder) {
this.platformFolder = platformFolder;
}
private void clearVesionMap() {
versionMap.clear();
}
private void gatherVersionMap(File baseFolder) {
File[] packages = baseFolder.listFiles();
for (File pkg : packages) {
if (pkg.isDirectory()) {
for (File utr : pkg.listFiles()) {
if (utr.isDirectory() && utr.getName().equals("update_tracking")) {
File[] xmls = utr.listFiles();
for (File file : xmls) {
if (file.getName().toLowerCase().endsWith(".xml")) {
parseModules(file);
}
}
}
}
}
}
}
private void parseModules(File file) {
try {
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(file);
if (doc == null) {
return;
}
Element moduleElement = doc.getDocumentElement();
if (moduleElement == null || !moduleElement.getTagName().equalsIgnoreCase("module")) {
return;
}
Element versionElement = findChildElement(moduleElement, "module_version");
if (versionElement == null) {
return;
}
String name = moduleElement.getAttribute("codename");
int idx = name.indexOf("/");
if (idx != -1) {
name = name.substring(0, idx);
}
String version = versionElement.getAttribute("specification_version");
versionMap.put(name, version);
} catch (SAXException ex) {
Logger.getLogger(UpdateNetBeansDependencies.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(UpdateNetBeansDependencies.class.getName()).log(Level.SEVERE, null, ex);
} catch (ParserConfigurationException ex) {
Logger.getLogger(UpdateNetBeansDependencies.class.getName()).log(Level.SEVERE, null, ex);
}
}
private Element findChildElement(Element parent, String name) {
if (parent == null) {
return null;
}
org.w3c.dom.Node ret = parent.getFirstChild();
while (ret != null && (!(ret instanceof Element) || !ret.getNodeName().equals(name))) {
ret = ret.getNextSibling();
}
return (Element) ret;
}
}

@ -1,3 +1,4 @@
loadwikiimages=com.jme.ant.LoadWikiImages
fixwikilinks=com.jme.ant.FixWikiLinks
updatesdkdeps=com.jme.ant.UpdateSdkDependencies
updatenbdeps=com.jme.ant.UpdateNetBeansDependencies

Binary file not shown.
Loading…
Cancel
Save