How do I use ant xmlns in gradle?

I’m migrating a build system from Ant to Gradle. It uses JavaFX 2.0 (so the Gradle JavaFX 1.0 plugin is irrelevant), which has some special requirements for jar building. It includes these bits:

<project xmlns:fx="">
    <taskdef resource="com/sun/javafx/tools/ant/antlib.xml" uri=""/>
    <fx:jar destfile="foo.jar"/>

How do I reference the Ant fx:jar task from Gradle?

Gradle is using groovy’s AntBuilder so please take a look at AntBuilder’s ways of dealing with namespaces. Quick google on my side reveals this: Haven’t tested it so hopefully it will be useful :slight_smile:

apply plugin: 'java'
  repositories {
    flatDir {
        dirs 'C:\Program Files\Oracle\JavaFX 2.0 SDK\tools', 'C:\Program Files\Oracle\JavaFX 2.0 SDK\rt\lib'
  configurations {
  dependencies {
    compile ':jfxrt'
    antJavafx ':ant-javafx'
  task javaFxPackage << {
    ant.taskdef( resource:"com/sun/javafx/tools/ant/antlib.xml", classpath: configurations.antJavafx.asPath, uri: '')
          ant.'' (destfile: 'myApp.jar') {
        fileset(dir: 'build/classes/main')

Then you can do:

gradle jar

gradle javaFxPackage