View Full Version : Ant 1.8.1 and Jarbundler task
MCroft
10-26-2010, 05:44 AM
hello, old friends, long time, etc...
A recent MacOSX Java update broke the current jarbundler task in build.xml (probably due to the classpath changes in ANT 1.8.1, but that's just my theory).
I installed the latest jarbundler (2.1.0) from http://www.informagen.com/JarBundler/ and it fixed the xerxes dependency (amongst other things) and it runs fine. The version on sourceforge is way out of date.
I recommend that we change the version of jarbundler in the util/macosx directory and change build.xml to reference the new version. I've only tested this with my up-to-date system. It could also be dependent on the version of ANT, if that's a concern...
Output of the error, for the curious:
/Users/mcroft/Projects/kolmafia/build.xml:223: java.lang.NoClassDefFoundError: org/apache/xml/serialize/OutputFormat
at net.sourceforge.jarbundler.PropertyListWriter.writ eFile(Unknown Source)
at net.sourceforge.jarbundler.JarBundler.writeInfoPli st(Unknown Source)
at net.sourceforge.jarbundler.JarBundler.execute(Unkn own Source)
at org.apache.tools.ant.UnknownElement.execute(Unknow nElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execut e(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:39 0)
at org.apache.tools.ant.Target.performTasks(Target.ja va:411)
at org.apache.tools.ant.Project.executeSortedTargets( Project.java:1397)
at org.apache.tools.ant.Project.executeTarget(Project .java:1366)
at org.apache.tools.ant.helper.DefaultExecutor.execut eTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Projec t.java:1249)
at org.apache.tools.ant.Main.runBuild(Main.java:801)
at org.apache.tools.ant.Main.startAnt(Main.java:218)
at org.apache.tools.ant.launch.Launcher.run(Launcher. java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher .java:109)
Caused by: java.lang.ClassNotFoundException: org.apache.xml.serialize.OutputFormat
at org.apache.tools.ant.AntClassLoader.findClassInCom ponents(AntClassLoader.java:1361)
at org.apache.tools.ant.AntClassLoader.findClass(AntC lassLoader.java:1311)
at org.apache.tools.ant.AntClassLoader.loadClass(AntC lassLoader.java:1064)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 48)
... 19 more
Total time: 9 seconds
Is that related to this (http://kolmafia.us/showthread.php?5151-build.xml-147-error)?
MCroft
10-26-2010, 05:59 AM
No, it's not that but it's got the same root cause. My problem is the mac jarbundler command. I've got a script that runs 'ant daily jarbundler'. The daily works fine (so effectively I've got the jar file you're pointing me to) but the jarbundler task fails because of the xerxes dependency in the old jarbundler and the classpath handling change in ANT 1.8.x
I'm not looking to grab builds, but to have my nightly builds bundled into an executable app, so the jarbundler task has to work.
Veracity
10-26-2010, 02:35 PM
OK. Revision 8516 updates to the new jarbundler task
MCroft
10-27-2010, 01:04 PM
That fixed my issue (thank you!), but I noticed that the "dmg" target has it's own jarbundler command, still using 1.9. Is this on purpose? You may want to give it a dependency on the jarbundler target, so that it doesn't get out of sync...
Veracity
10-27-2010, 02:01 PM
I've not gotten the dmg target to work for many years; the "hdiutil" task stopped working for me many major releases ago of OS X. Does it work for you?
MCroft
10-27-2010, 02:19 PM
Haven't even tried, since I'm building just for myself, but I can look at it.
There are two web pages I've found that talk about how to do this in leopard/snow leopard.
http://www.rkuntz.org/pmwiki.php?n=Code.AntDiskImage
http://www.informagen.com/JarBundler/DiskImage.html
If this is of value, I could try to make this work using ideally the first and less-ideally the second method.
MCroft
10-27-2010, 06:17 PM
Yep, the one in the build.xml didn't work. The first problem was with the paths (a basedir vs. working dir issue). The second problem was with not putting the .app in the source directory.
This works for me (10.6.4, latest java/xcode, etc.). I had to use the exec cp rather than the copy task because the copy task doesn't save the permissions (specifically the execute bit).
<!-- ========================== -->
<!-- create an OSX disk image -->
<!-- ========================== -->
<target name="dmg" depends="init,update,jar,jarbundler">
<exec executable="rm" dir="${dist}">
<arg line="-rf KoLmafia" />
</exec>
<mkdir dir="${dist}/KoLmafia"/>
<symlink action="single" link="${dist}/KoLmafia/Applications" resource="/Applications" />
<exec executable="cp" dir="${dist}">
<arg line="-a ${basedir}/${dist}/KoLMafia.app ${basedir}/${dist}/KoLmafia/" />
</exec>
<delete file="${basedir}/${dmgfile}"/>
<exec executable="hdiutil" dir="${dist}">
<arg line="create ${basedir}/${dmgfile} -srcfolder ${basedir}/${dist}/KoLmafia -volname KoLmafia" />
</exec>
<exec executable="rm" dir="${dist}">
<arg line="-rf KoLmafia" />
</exec>
</target>
Veracity
10-28-2010, 06:30 PM
Interesting. I included that and I get some errors, but it continued past them. The errors appear to come from having obsolete stuff in ~/Library/Plug-ins/DiskImages (which was created back in 2004) which hdiutil tries to load and fails, since it can't find the right architecture. I moved that directory out of the way and now hdiutil works fine with no errors.
I'll check it in, as an example, though I still won't use it for spinning releases, for now, since I currently have to manually rename "KoLmafia.app" to "KoLmafia-14.4.app", for example. Ditto for the .jar, .tar.dmg, and .exe files. Obviating that will require more build-file hackery.
MCroft
10-28-2010, 08:37 PM
I'll check it in, as an example, though I still won't use it for spinning releases, for now, since I currently have to manually rename "KoLmafia.app" to "KoLmafia-14.4.app", for example. Ditto for the .jar, .tar.dmg, and .exe files. Obviating that will require more build-file hackery.
Glad to help. My ANT skills go to waste since I moved jobs and my new team is all MAVEN-y.
If you have a christmas list of build.xml changes you'd like, I'd be happy to see what I can do...
Veracity
10-28-2010, 09:22 PM
OK, thanks! Here is (some of) my current procedure for creating the files I need to upload for a release:
3) Edit KoLConstants.java and set VERSION_NAME and VERSION_DATA appropriately.
(And if REVISION is not null, make it null. ant edits this file to insert the current revision before a non-dist build and restores it afterwards - unless you ^C the build. I've done that. It's a mistake.)
Check in KoLConstants.txt
4) Generate the release notes, such as they are. build.xml has a "notes" target which runs src/net/sourceforge/kolmafia/utilities/ReleaseNotes.java. This reads "history.txt" from the ROOT_LOCATION and writes "release.txt" in the same place.
history.txt is the output of "svn log"
release.txt is the "abbreviated revision history" complete with bbcode links to the sourceforge revision.
% svn update
% svn log > ~/Library/Application\ Support/KoLmafia/history.txt
% ant notes
- edit generated release notes (~/Library/Application\ Support/KoLmafia/release.txt) to have only the new revisions in the release
- Prepend holatuwol's release announcement (util/boilerplate.txt)
Voila! You have the text of the announcement to be posted on kolmafia.us, once the release is available.
5) Generate the four files we will upload to sourceforge.
% ant clean
% ant dist
This creates KoLmafia.app, KoLmafia.exe, KoLmafia.jar, and KoLmafia.tar.gz.
Note that unlike "ant daily", these do NOT include the release in the file name. I'm not sure how to make the buildfile do that; the daily builds call on snversion to get the revision, but we'd need to extract the major version ourself from KoLConstants.java.
% mv dist/KoLmafia.jar dist/KoLmafia-14.0.jar
% mv dist/KoLmafia.app dist/KoLmafia-14.0.app
% mv dist/KoLmafia.exe dist/KoLmafia-14.0.exe
% mv dist/KoLmafia.tar.gz dist/KoLmafia-14.0.tar.gz
Note also that this produces a Macintosh app bundle, but not a disk image, even though there is a "dmgfile" target in the build file. This is partly because we don't have the correct name for the .app, but also because I was unable to get "hdiutil" to work.
% mkdir dist/KoLmafia-14.0
% ln -s /Applications dist/KoLmafia-14.0/Applications
% mv dist/KoLmafia-14.0.app dist/KoLmafia-14.0
Find dist/KoLmafia-14.0 in the finder. Drag that folder to Disk Utility. When it prompts for a place to save the image, put it in dist/KoLmafia-14.0.dmg
% rm -rf dist/KoLmafia-14.0
The dist directory now has exactly the files you need: KoLmafia-14.0.dmg, KoLmafia-14.0.exe, KoLmafia-14.0.jar, and KoLmafia-14.0.tar.gz.
At step 3, I update KoLConstants.java with the new major version number and date and check it in.
At step 4, I get the svn log and run a utility on it to make release notes. I have to manually edit it to remove all the revisions up to and including the one in which I bumped the revision for LAST release, but that's not too hard.
I could use some help at step 5. I'd like KoLmafia.jar, KoLmafia.app (inside the disk image), KoLmafia.dmg, KoLmafia.exe, and KoLmafia.tar.gz to all automatically have the major version number as part of the names. Thus, if KoLConstants.java says we are version 14.4, KoLmafia-14.4.dmg should have KoLmafia-14.4.app in it, and so on.
Given the ability to do that, "ant dist" could be coded to make precisely the 4 files I need to upload, all named appropriately.
If you can figure out how to do that, I'd be grateful. :)
MCroft
10-29-2010, 01:06 AM
I haven't really gotten going on it, but some of those constants are hilarious...
MCroft
10-29-2010, 06:49 AM
So, as usual the caveat is it works for me (10.6.4, latest java, ant 1.8.1) and may not be 100% backwards compatible. I haven't run the win .exe at all.
The filterchain I used are Ant 1.6.2 or newer and the way to get the version depends on grep being there (all Unix systems, probably not windows systems). It might be cleaner to put the version in an ANT properties file and insert it in the KoLConstants, but that wasn't what we talked about. Any questions about why I changed things, let me know.
<project name="KoLmafia" default="debug" basedir=".">
<!-- ========================================== -->
<!-- set the global properties for this build -->
<!-- ========================================== -->
<property name="root" value="."/>
<property name="src" value="src"/>
<property name="lib" value="lib"/>
<property name="util" value="util"/>
<property name="build" value="build"/>
<property name="dist" value="dist"/>
<property name="docs" value="${dist}/docs"/>
<property name="KoLConstants" value="${src}/net/sourceforge/kolmafia/KoLConstants.java"/>
<property name="main" value="net.sourceforge.kolmafia.KoLmafia"/>
<property name="synopsis" value="An alternate interface to Kingdom of Loathing"/>
<property environment="env"/>
<!-- Setting the version string. This breaks on platforms where we don't have grep... -->
<exec executable="grep" outputproperty="KoLVersion">
<arg value="VERSION_NAME" />
<arg value="${KoLConstants}" />
<redirector>
<outputfilterchain>
<replacestring from='public static final String VERSION_NAME = ' to=""/>
<replacestring from='KoLmafia v' to=""/>
<deletecharacters chars=';\"'/>
<trim/>
</outputfilterchain>
</redirector>
</exec>
<property name="KoLVersionedBaseFileName" value="${ant.project.name}-${KoLVersion}"/>
<property name="jarfile" value="${dist}/${KoLVersionedBaseFileName}.jar"/>
<property name="tarfile" value="${dist}/${KoLVersionedBaseFileName}.tar.gz"/>
<property name="appfile" value="${dist}/${KoLVersionedBaseFileName}.app"/>
<property name="dmgfile" value="${dist}/${KoLVersionedBaseFileName}.dmg"/>
<property name="debfile" value="${dist}/${KoLVersionedBaseFileName}.deb"/>
<property name="exefile" value="${dist}/${KoLVersionedBaseFileName}.exe"/>
<!-- classpath -->
<path id="classpath.compile">
</path>
<!-- ========================================== -->
<!-- create directories used by other targets -->
<!-- ========================================== -->
<target name="init">
<tstamp/>
<mkdir dir="${build}"/>
<mkdir dir="${dist}"/>
</target>
<!-- ==================================== -->
<!-- displays the current version from ${KoLConstants} -->
<!-- ==================================== -->
<target name="printversion">
<echo message="version: ${KoLVersion}" />
<echo message="version: ${KoLVersion_partial_NAME}" />
</target>
<!-- ==================================== -->
<!-- sets the default compiler to Jikes -->
<!-- ==================================== -->
<target name="jikeshome" if="env.JIKES_HOME">
<property name="build.compiler" value="jikes" />
<echo message="Set compiler: ${env.JIKES_HOME}" />
</target>
<!-- ================================== -->
<!-- reports the current Java version -->
<!-- ================================== -->
<target name="javahome" if="env.JAVA_HOME">
<exec executable="java" failifexecutionfails="false">
<arg value="-version"/>
</exec>
</target>
<!-- ================================== -->
<!-- update files from the repository -->
<!-- ================================== -->
<target name="update">
<exec executable="svn" failifexecutionfails="false">
<arg value="update"/>
<arg value="${root}"/>
</exec>
</target>
<!-- ================================== -->
<!-- update files from the repository -->
<!-- ================================== -->
<target name="version">
<exec executable="svnversion" outputproperty="revision" failifexecutionfails="false">
<arg value="-n"/>
<arg value="${root}"/>
</exec>
<property name="revision" value="0"/>
<echo message="Current revision: ${revision}"/>
</target>
<!-- ======================= -->
<!-- clean up object files -->
<!-- ======================= -->
<target name="clean">
<delete dir="${build}" failonerror="false"/>
<delete dir="${docs}" failonerror="false"/>
<delete failonerror="false">
<fileset dir="${dist}">
<include name="${ant.project.name}*"/>
</fileset>
</delete>
<symlink action="delete" link="${dist}/${KoLVersionedBaseFileName}/Applications" failonerror="false" />
<delete dir="${appfile}" failonerror="false"/>
</target>
<!-- ================================ -->
<!-- clean up KoLmafia object files -->
<!-- ================================ -->
<target name="start">
<delete dir="${build}/net/sourceforge/kolmafia" failonerror="false"/>
<delete dir="${docs}" failonerror="false"/>
<delete dir="${appfile}" failonerror="false"/>
<delete failonerror="false">
<fileset dir="${dist}">
<include name="${ant.project.name}*"/>
</fileset>
</delete>
<antcall target="init"/>
</target>
<!-- ====================== -->
<!-- generate class files -->
<!-- ====================== -->
<target name="compile" depends="init,jikeshome,javahome">
<javac srcdir="${src}" destdir="${build}"
source="1.4"
failonerror="false" debug="on"
debuglevel="lines,vars,source" deprecation="off"
nowarn="on" includeantruntime="false">
<classpath refid="classpath.compile"/>
</javac>
<copy todir="${build}" preservelastmodified="true">
<fileset dir="${src}">
<exclude name="**/*.java"/>
</fileset>
</copy>
<copy todir="${build}" preservelastmodified="true">
<fileset dir="${lib}">
<exclude name="**/*.jar"/>
</fileset>
</copy>
</target>
<!-- ========================================== -->
<!-- generate a zipped TAR of the source code -->
<!-- ========================================== -->
<target name="tar" depends="init">
<tar destfile="${tarfile}" basedir="${root}" compression="gzip">
<exclude name="build/**"/>
<exclude name="dist/**"/>
</tar>
</target>
<!-- =========================== -->
<!-- generate the standard JAR -->
<!-- =========================== -->
<target name="jar" depends="init,version">
<replace file="${KoLConstants}"
token="REVISION = null" value='REVISION = "${revision}"'/>
<antcall target="compile"/>
<replace file="${KoLConstants}"
token='REVISION = "${revision}"' value="REVISION = null"/>
<jar destfile="${jarfile}"
basedir="${build}"
update="true" index="true" compress="true">
<manifest>
<attribute name="Main-Class" value="${main}"/>
</manifest>
</jar>
</target>
<!-- =========================== -->
<!-- generate the standard EXE -->
<!-- =========================== -->
<target name="jsmooth" depends="init,update,jar">
<move file="${util}/windows/build.jsmooth" tofile="${util}/windows/tmp.build.jsmooth" />
<replace file="${util}/windows/tmp.build.jsmooth" token="dist/KoLmafia.exe" value='${exefile}'/>
<replace file="${util}/windows/tmp.build.jsmooth" token="dist/KoLmafia.jar" value='${jarfile}'/>
<taskdef name="jsmooth" classname="net.charabia.jsmoothgen.ant.JSmoothGen" classpath="${util}/windows/jsmoothgen-ant.jar" />
<jsmooth project="${util}/windows/tmp.build.jsmooth" skeletonroot="${util}/windows/skeletons"/>
<delete file="${util}/windows/tmp.build.jsmooth"/>
</target>
<!-- ================================ -->
<!-- generate an application bundle -->
<!-- ================================ -->
<target name="jarbundler" depends="init,update,jar">
<taskdef name="jarbundler" classname="net.sourceforge.jarbundler.JarBundler" classpath="${util}/macosx/jarbundler-2.1.0.jar" />
<jarbundler dir="${dist}" name="${KoLVersionedBaseFileName}" mainclass="net.sourceforge.kolmafia.KoLmafia" jar="${jarfile}" icon="${util}/macosx/limeglass.icns" vmoptions="-Xincgc" />
</target>
<!-- ========================== -->
<!-- create an OSX disk image -->
<!-- ========================== -->
<target name="dmg" depends="init,update,jar,jarbundler">
<mkdir dir="${dist}/${KoLVersionedBaseFileName}"/>
<symlink action="single" link="${dist}/${KoLVersionedBaseFileName}/Applications" resource="/Applications" />
<exec executable="cp" dir="${dist}">
<arg line="-a ${basedir}/${appfile} ${basedir}/${dist}/${KoLVersionedBaseFileName}/" />
</exec>
<delete file="${basedir}/${dmgfile}"/>
<exec executable="hdiutil" dir="${dist}">
<arg line="create ${basedir}/${dmgfile} -srcfolder ${basedir}/${dist}/${KoLVersionedBaseFileName} -volname ${KoLVersionedBaseFileName}" />
</exec>
<exec executable="rm" dir="${dist}">
<arg line="-rf KoLmafia*" />
</exec>
</target>
<!-- ========================== -->
<!-- create a Debian package -->
<!-- ========================== -->
<target name="debian" depends="init,update,version,jar,desktop">
<taskdef name="deb" classname="com.googlecode.ant_deb_task.Deb" classpath="${util}/debian/ant-deb.jar" />
<deb todir="${dist}" package="kolmafia" priority="optional" section="games" depends="sun-java6-jre">
<version upstream="${revision}" debian="${revision}"/>
<maintainer name="Veracity" email="veracity@hambo.com"/>
<description synopsis="${synopsis}">${synopsis}</description>
<tarfileset file="${jarfile}" prefix="usr/lib" filemode="755"/>
<tarfileset file="${build}/kolmafia.desktop" prefix="usr/share/applications"/>
<tarfileset file="util/debian/kol.xpm" prefix="usr/share/pixmaps"/>
<tarfileset file="util/debian/kol" prefix="usr/bin" filemode="755"/>
</deb>
</target>
<!-- ============================= -->
<!-- create Debian desktop entry -->
<!-- ============================= -->
<target name="desktop">
<taskdef name="desktopentry" classname="com.googlecode.ant_deb_task.DesktopEntry" classpath="${util}/debian/ant-deb.jar" />
<desktopentry toFile="build/kolmafia.desktop" name="${ant.project.name}" comment="${synopsis}" exec="/usr/bin/kol" icon="kol.xpm" terminal="false" type="Application" categories="Game;RolePlaying" />
</target>
<!-- ================================ -->
<!-- generate the alpha testing JAR -->
<!-- ================================ -->
<target name="debug" depends="start,version">
<replace file="${KoLConstants}"
token="RELEASED = true" value='RELEASED = false'/>
<antcall target="jar"/>
<replace file="${KoLConstants}"
token="RELEASED = false" value='RELEASED = true'/>
</target>
<!-- ============================ -->
<!-- generate a daily build JAR -->
<!-- ============================ -->
<target name="daily" depends="clean,init,update,version">
<replace file="${KoLConstants}"
token="REVISION = null" value='REVISION = "${revision}"'/>
<replace file="${KoLConstants}"
token="RELEASED = true" value='RELEASED = false'/>
<antcall target="compile"/>
<replace file="${KoLConstants}"
token='REVISION = "${revision}"' value="REVISION = null"/>
<replace file="${KoLConstants}"
token="RELEASED = false" value='RELEASED = true'/>
<jar destfile="${dist}/${ant.project.name}-${revision}.jar"
basedir="${build}"
update="true" index="true" compress="true">
<manifest>
<attribute name="Main-Class" value="${main}"/>
</manifest>
</jar>
</target>
<!-- =========================== -->
<!-- generate the distribution -->
<!-- =========================== -->
<target name="dist" depends="clean,init,update">
<antcall target="tar"/>
<antcall target="jar"/>
<antcall target="jsmooth"/>
<antcall target="jarbundler"/>
<antcall target="dmg"/>
</target>
<!-- ================================================== == -->
<!-- runs program with all needed libraries in the path -->
<!-- ================================================== == -->
<target name="exec" depends="jar">
<java fork="true" jar="${jarfile}" dir="${dist}">
<jvmarg value="-Xincgc" />
</java>
</target>
<!-- ============================================== -->
<!-- generates the release notes for the archive -->
<!-- ================================================== == -->
<target name="notes" depends="jar">
<java fork="true" classname="net.sourceforge.kolmafia.utilities.ReleaseNotes" classpath="${jarfile}" dir="${dist}" />
</target>
<!-- ======================================= -->
<!-- generate the javadocs from sourcecode -->
<!-- ======================================= -->
<target name="javadoc" depends="init">
<mkdir dir="${docs}"/>
<mkdir dir="${docs}/api"/>
<javadoc sourcepath="${src}" destdir="${docs}" packagenames="*">
<link href="http://java.sun.com/j2se/1.4.2/docs/api/"/>
<classpath>
<pathelement location="${lib}"/>
<pathelement location="${build}"/>
</classpath>
</javadoc>
</target>
</project>
MCroft
10-29-2010, 06:54 AM
At step 4, I get the svn log and run a utility on it to make release notes. I have to manually edit it to remove all the revisions up to and including the one in which I bumped the revision for LAST release, but that's not too hard.
So, it's not too hard to trim, but if you know what revision you want to start from, you can type "svn log -r1234:HEAD". that's what I use in my applescript to get and run daily builds.
Theraze
10-29-2010, 07:12 AM
The last two posts both point strongly (to me, at least) at a .properties file being an excellent idea, as MCroft mentioned... works great for substitution, OS independent, and probably makes the svn log bit easier.
Veracity
10-30-2010, 03:29 AM
Any way to do this without grep? OS X and Linux users sail along without a blink, but Windows users are halted in their tracks.
MCroft
10-30-2010, 03:49 AM
True, very few of them have cygwin or unxutils.
I see three options
1: find an existing java based grep task for ANT. I didn't have much luck with this, but I didn't spend a lot of time looking.
2: make a java based grep task for ANT.
3: rework the process flow.
#3 is what Theraze and I were discussing earlier. The way this would work, instead of updating the version string in KoLConstants.java, you'd update the version string in a new file called KoLmafia_build.properties and add <property file="KoLmafia_build.properties" prefix="bp"/> to the top of the build.xml
Then before we use KoLConstants, we do a token substitution to place the VERSION_NAME in it as well as setting all the other variables.
That's the approach I'd recommend.
StDoodle
10-30-2010, 02:07 PM
True, very few of them have cygwin or unxutils.
Pfft, I've never compiled a daily build nor done a fraction of the programmy-stuff the rest of you do, and I have cygwin. Doesn't seem an onerous requirement for those willing to compile their own builds to me, but hey-- it's me! :P
EDIT to note: apologies, this wasn't meant to be taken all that seriously. FWIW, I didn't get sleep last night.
fronobulax
10-30-2010, 02:24 PM
My personal opinion is that we have crossed a line if we are now going to require Windows builders to install Cygwin or some form of grep just to compile and build. My sense of compartmentalization notes that the problem originally existed when building for Macs and that suggests that the optimal solution would be one that leaves the status quo unchanged for non-Mac users.
I'm inclined to endorse MCroft's #3 above.
Grotfang
10-30-2010, 02:57 PM
Doesn't seem an onerous requirement for those willing to compile their own builds to me
Going to have to agree with fronobulax (and I think, Veracity) on this one. I use cygwin, but I don't see why it should be a requirement for building mafia. Ant and subversion are essential for the routine, so naturally installing these makes sense. Adding yet another barrier to entry for individuals wanting to compile builds themselves would make me sad. For open source software, an interested and engaged user base is essential. I think we have that here -- a large number of people use mafia and are willing to give feedback (even if it is poorly presented now and again). That is a Good Thing. However, the more people who are able to look at the code themselves, the more people giving feedback can do extra things such as post patches, comment on the code and also be inspired to learn more about how the system works. This improves the quality of communication between the development team and the users.
The simpler it is to be involved in a project, the better. The biggest step in increasing involvement is learning how to maintain a working copy and build the software yourself.
MCroft
10-30-2010, 04:55 PM
I use cygwin, but I don't see why it should be a requirement for building mafia.
Unless I'm quite wrong, y'all are misstating the scope. Building should be unaffected. This change only affects the command make a complete set of cross-platform distributable packages (ant dist, not ant build). I still think it should be further improved, and I can do it any of the ways I suggested (not today, off to my wife's 25th HS reunion, wherein I will meet strangers who knew her at age 14), but I didn't want to change the way the dist process worked without hearing how the maintainers wanted it.
Hope that's clearer.
Alhifar
10-30-2010, 05:20 PM
The build currently fails on windows without cygwin using ANY target, not just dist.
Theraze
10-30-2010, 06:30 PM
Yeah... and even if you do have cygwin installed (I do, as I code in C and C++ a fair bit) it fails if you're compiling with Ant and haven't put the cygwin bin folder into the main path...
Veracity
10-30-2010, 06:53 PM
It might be cleaner to put the version in an ANT properties file and insert it in the KoLConstants, but that wasn't what we talked about.
At your leisure, let's do it this way. I currently have to edit KoLConstants every time I spin a new release. Changing, instead, build.properties (or whatever) - and having that be directly usable by the build file and automatically inserted into KoLConstants - would be the same, from the release-spinner's viewpoint. Plus OS independence.
wrldwzrd89
10-30-2010, 08:57 PM
Yay! I'm liking these proposed build changes - they'll make compiling KoLmafia.exe or what have you SO much simpler. It'll also make maintenance easier... but don't forget to use Windows conventions (CR+LF) in text files, in case Windows users want to open them up in Notepad - it doesn't understand Unix-style LF only, for example.
Dudicle
10-31-2010, 12:09 AM
Dadnab! I was halfway looking into building my own files to tinker with, and even got some help on the subject. Then again this might be the perfect time!
I'm installing ant for the first time today on my Mac. Come to think of it, I think this is the first time I've installed ant at all! :D
I know it is rather unlikely, but is there any way that I might be able to help?
~Dudicle
EDIT: I didn't realize that you can't format your posts, and removed said formatting.
Grotfang
10-31-2010, 11:31 AM
Unless I'm quite wrong, y'all are misstating the scope. Building should be unaffected.
As Alhifar said, you are quite wrong.
% ant daily
Buildfile: build.xml
BUILD FAILED
C:\Users\Ben\Documents\KoLmafia\source\kolmafia\bu ild.xml:25: Execute failed: java.io.IOException: Cannot run program "grep": CreateProcess error=2, The system cannot find the file specified
Total time: 0 seconds
MCroft
10-31-2010, 07:57 PM
As Alhifar said, you are quite wrong.
Oops. My bad. Thought I'd avoided that. Sorry.
MCroft
11-01-2010, 06:24 AM
Once more, with four part harmony and feeling. Implemented as discussed, with a properties file and no grep. It does use regexreplace. Hopefully the requirement to have a regular expression parser in the classpath is a given these days, otherwise we may need to find one to include.
I'd love to have a windows user check the dist target, the daily target, and the .exe version to make sure they work.
All these files need to be saved without the .txt extension. I don't know if the text editor handled line endings as requested.
Grotfang
11-01-2010, 09:32 AM
I'd love to have a windows user check the dist target, the daily target, and the .exe version to make sure they work.
Thanks for the quick response.
First time through:
% ant daily
Buildfile: build.xml
clean:
[delete] Deleting directory C:\Users\Ben\Documents\KoLmafia\source\kolmafia\bu ild
[symlink] Removing symlink: dist/KoLmafia-14.4/Applications
[symlink] java.io.FileNotFoundException: No such symlink: dist\KoLmafia-14.4\Applications
BUILD FAILED
C:\Users\Ben\Documents\KoLmafia\source\kolmafia\bu ild.xml:100: delete doesn't support the "removeNotFollowedSymlinks" attribute
Total time: 54 seconds
That time through most of the time was spent on a delay between [delete] (having deleted the build directory) and [symlink]. On subsequent attempts:
% ant daily
Buildfile: build.xml
clean:
[symlink] Removing symlink: dist/KoLmafia-14.4/Applications
[symlink] java.io.FileNotFoundException: No such symlink: dist\KoLmafia-14.4\Applications
BUILD FAILED
C:\Users\Ben\Documents\KoLmafia\source\kolmafia\bu ild.xml:100: delete doesn't support the "removeNotFollowedSymlinks" attribute
Total time: 0 seconds
I know very little about ant, so I'm afraid that's the best I can do re assistance. Thank you for working to resolve this -- it is appreciated.
MCroft
11-01-2010, 01:38 PM
...
I know very little about ant, so I'm afraid that's the best I can do re assistance. Thank you for working to resolve this -- it is appreciated.
Ben,
Thank you for testing this. That's a very useful report. The delete property started supporting "removeNotFollowedSymlinks" in ANT 1.8.0. I removed that and also changed the properties file so that Windows users can edit it more easily if their text editors don't support unix style line endings.
The downside is that I can't seem to get the delete task to remove the staging directory we create to make the disk image. I think that's harmless, but vexing. Anyone have any ideas?
Theraze
11-01-2010, 09:52 PM
Builds a KoLmafia-14.4.jar file for me in Windows. I'll stare at the delete a bit... is that always failing to delete properly, or just a specific build target?
Edit: Note: build.xml also has the *nix line endings.
Assuming that the delete problem you're talking about is from changing:
<target name="clean">
<delete dir="${build}" failonerror="false"/>
<delete dir="${docs}" failonerror="false"/>
<delete failonerror="false">
<fileset dir="${dist}">
<include name="${ant.project.name}*"/>
</fileset>
</delete>
<symlink action="delete" link="${dist}/${KoLVersionedBaseFileName}/Applications" failonerror="false" />
<delete dir="${appfile}" failonerror="false"/>
</target>to this:
<target name="clean">
<delete dir="${build}" failonerror="false"/>
<delete dir="${docs}" failonerror="false"/>
<symlink action="delete" link="${dist}/${version-name}/Applications" failonerror="false" />
<delete dir="${appfile}" failonerror="false" />
<!-- Really important not to follow the symlink to /Applications and delete it...-->
<delete failonerror="false">
<fileset dir="${dist}" defaultexcludes="no" followsymlinks="false" />
</delete>
</target>
Any chance part of the issue is the difference in primacy? In the old code, dist is deleted first, then the symlink... *ponders* Is that what you're saying... as it stood, it was possible for the build to wipe out your Applications folder? If so, why didn't it do it for everyone in the past? Maybe because you've skipped the part for
<include name="${ant.project.name}*"/>in the updated files?
MCroft
11-02-2010, 04:33 AM
Builds a KoLmafia-14.4.jar file for me in Windows. I'll stare at the delete a bit... is that always failing to delete properly, or just a specific build target?
So the problem only came up after the dmg target got fixed and put back in the dist target. It's an artifact of that process creating an intermediate directory to build the disk image from. The first time I got that target working, it started deleting stuff from /Applications, which is sorta important.
For me, it leaves artifacts in dist when I type ant dist followed by ant clean. An ideal clean target leaves the system the way it would be following a fresh svn checkout and it's vexing that I can't make it so.
Edit: Note: build.xml also has the *nix line endings.
will fix!
Theraze
11-02-2010, 04:44 AM
Would a specific include help, like it had before?
MCroft
11-02-2010, 04:59 AM
Would a specific include help, like it had before?
I tried it, and it didn't. However, I did look at parameters for the delete task and found I needed to specify includeemptydirs="true". Properly cleaning version coming up...
Theraze
11-02-2010, 05:30 AM
Seems that it's generating both an empty directory and the one that actually gets used... fairly certain the empty one isn't supposed to happen, but... long as it cleans, that works. :)
MCroft
11-02-2010, 06:52 AM
Added automatically setting REVISION to null
Changed line endings in the build.xml file
Fixed the clean target to remove empty directories
As usual, I would be pleased to hear from anyone trying this on platforms I don't use.
I'm looking at automating the notes creation. It's taking me longer than I expected because of the build putting the release notes in different places on different platforms.
There are at least two options:
1: I get off my lazy butt and code it like the app does, just in ANT
2: we re-work that to put the history.txt and release.txt somewhere else like ${build} or ${dist}
Theraze
11-02-2010, 07:05 AM
Buildfile: C:\kolmafia\build.xml
BUILD FAILED
C:\kolmafia\build.xml:384: Unexpected text "-->"
Compiles if you remove the bad comment-end.
MCroft
11-02-2010, 07:13 AM
Famous last words... "I'll just add a comment. That won't need to be retested."
Fixed, and thank you for testing this.
Theraze
11-02-2010, 07:32 AM
Compiled for me.
Compiled for myself also.
Grotfang
11-02-2010, 02:42 PM
And for me. Ant dist produces the .exe, .jar, .tar.gz, then fails while producing the .app.
jarbundler:
[jarbundler] Creating application bundle: C:\Users\Ben\Documents\KoLmafia\source\kolmafia\di st\KoLmafia-14.4.app
BUILD FAILED
C:\Users\Ben\Documents\KoLmafia\source\kolmafia\bu ild.xml:215: Cannot copy Java Application Stub: java.io.FileNotFoundException: \System\Library\Frameworks\JavaVM.framework\Versio ns\Current\Resources\MacOS\JavaApplicationStub (The system cannot find the path specified)
Total time: 59 seconds
I don't think it ever could produce the .app, so I count this a success. Ant daily and ant jar work perfectly.
Nice work!
Alhifar
11-03-2010, 03:30 PM
Apparently clean now deletes all sessions/preferences/scripts/etc. folders. I have always in the past simply run ant daily to update kolmafia and then ran mafia from the dist folder. Luckily, I have a backup of most things, but not my session or chat logs now. Should I change how I do things, or can this be changed?
MCroft
11-03-2010, 04:08 PM
Apparently clean now deletes all sessions/preferences/scripts/etc. folders. I have always in the past simply run ant daily to update kolmafia and then ran mafia from the dist folder. Luckily, I have a backup of most things, but not my session or chat logs now. Should I change how I do things, or can this be changed?
Ow, sorry about that. The old 'clean' deleted KoLMafia from the dist directory. The new 'clean' deletes everything from the dist directory. We could easily change it back, but it's usually considered a "best practice" to have clean get rid of all files created by a buildfile.
Powered by vBulletin® Version 4.2.0 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.