Skip to content

Instantly share code, notes, and snippets.

@tcurdt
Last active June 19, 2018 20:41
Show Gist options
  • Save tcurdt/9275523 to your computer and use it in GitHub Desktop.
Save tcurdt/9275523 to your computer and use it in GitHub Desktop.
towards the jdeb 2.0 syntax
<target name="package" depends="jar">
<taskdef name="deb" classname="org.vafer.jdeb.ant.DebAntTask"/>
<deb destfile="${build.dir}/${ant.project.name}.deb" verbose="true">
<control>
<package>(no default)</package>
<version>(no default)</version>
<section>(default 'misc')</section>
<priority>(default 'low')</priority>
<architecture>(default 'all')</architecture>
<maintainer>(no default)</maintainer>
<pre-inst src="${basedir}/someshell.sh"/>
<pre-rm src="${basedir}/someshell.sh"/>
<post-inst src="${basedir}/someshell.sh"/>
<post-rm src="${basedir}/someshell.sh"/>
</control>
<data>
... see maven
</data>
</deb>
</target>
<plugin>
<artifactId>jdeb</artifactId>
<groupId>org.vafer</groupId>
<version>2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jdeb</goal>
</goals>
<configuration>
<verbose>true</verbose>
<token open="[[" close="]]"/>
<control>
<package>(default from pom)</package>
<version>(default from pom)</version>
<section>(default 'misc')</section>
<priority>(default 'low')</priority>
<architecture>(default 'all')</architecture>
<maintainer>(default from pom)</maintainer>
<pre-inst src="${basedir}/someshell.sh"/>
<pre-rm src="${basedir}/someshell.sh"/>
<post-inst src="${basedir}/someshell.sh"/>
<post-rm src="${basedir}/someshell.sh"/>
</control>
<!-- defaults:
dir: own=root:root mod=750
file: own=root:root mod=640 token=no compress=no
-->
<data>
<dir>
<dir>
<name>usr</name>
<own>root:root</own>
<mod>755</mod>
<dir>
<name>bin</bin>
<file>
<name>test</test>
<own>root:root</own>
<mod>755</mod>
<src>${basedir}/someshell.sh</src>
<token>yes|no</token>
</file>
<file>
<name>test-as-link</test>
<own>root:root</own>
<mod>755</mod>
<type>symbolic</type>
<target>test</target>
</file>
</dir>
<dir>
<name>lib</bin>
<file>
<name>${project.build.finalName}.jar</test>
<mod>755</mod>
<src>${project.build.directory}/${project.build.finalName}.jar</src>
</file>
<file>
<name>${project.build.finalName}.man.gz</test>
<mod>755</mod>
<src>somepath</src>
<compress>gzip</compress>
</file>
</dir>
<dir>
<name>doc</bin>
<src>${basedir}/docs</src>
<own>auto</own>
<mod>auto</mod>
<dir>
<name>examples</bin>
<src>${basedir}/examples.tgz</src>
<own>auto</own>
<mod>auto</mod>
</dir>
</dir>
</dir>
</data>
<!-- rules for defaults -->
<rules>
<match>
<src>*.man</src> or <dst>*.man.gz</dst>
<file>
<own>root:root</own>
<mod>640</mod>
<token>yes</token>
<compress>gzip</compress>
</file>
<dir>
<own>tcurdt:tcurdt</own>
</dir>
</match>
</rules>
</configuration>
</execution>
</executions>
</plugin>
@michael-schnell
Copy link

Hi there,

I think re-using the syntax of ANT FileSet/PatternSet/Selectors is a good idea. It's well documented and widely kown. It should also be possible to use the ANTcode as a library for doing parts of the work.

In general I'd prefer to have a separate XML file for the configuration that is only referenced in ANT's build.xml or Maven's pom.xml. This way it's easily possible to work standolone, in a build system or even in an IDE (Example: Eclipse Plugin). Parsing and also writing the separated XML is easy if it's done using JAXB. We could also provide an XML schema (XSD) for the configuration that makes manual editing easier.

I'm personally interested in creating a small UI for JDeb 2.0 using JavaFX.

What do you think?

Cheers,
Michael

@tcurdt
Copy link
Author

tcurdt commented Dec 15, 2014

@michael-schnell the problem with external files is the use of ant's file selectors or variable expansions. It would make many things much easier though. Feel free to come up with an example.

@michael-schnell
Copy link

Hi,

I created a small experimental project:
https://github.com/michael-schnell/experimental-jaxb-ant

The following file loads the XML and executes an ANT copy task:
https://github.com/michael-schnell/experimental-jaxb-ant/blob/master/src/test/java/org/fuin/examples/anttryout/CopyTaskExample.java

When I created it, I dived into the depth of the Ant source and it remembered me why I finally moved to Maven... ;-)

XML "if-else" stuff like this is pretty ugly:
<includesfile name="some-file"/>
<includesfile name="${some-other-file}" if="some-other-file"

The JavaDoc is also odd:
/** Appends excludes to the current list of exclude patterns.*/
public void setExcludes(String excludes) { ... }
(Why is the name "setExcludes" if it means "addExclude"?)

I'm not sure if it makes sense (or even is possible) to clone all of the Ant data structures.
Maybe it's better to define some kind ob subset just keeping the best of it.

Cheers,
Michael

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment