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="javafx.com.sun.javafx.tools.ant">
    <taskdef resource="com/sun/javafx/tools/ant/antlib.xml" uri="javafx:com.sun.javafx.tools.ant"/>
    <fx:jar destfile="foo.jar"/>
</project>

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: http://groovy.codehaus.org/Using+Ant+Libraries+with+AntBuilder 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 {
    antJavafx
}
  dependencies {
    compile ':jfxrt'
    antJavafx ':ant-javafx'
}
  task javaFxPackage << {
    ant.taskdef( resource:"com/sun/javafx/tools/ant/antlib.xml", classpath: configurations.antJavafx.asPath, uri: 'javafx.com.sun.javafx.tools.ant')
          ant.'javafx.com.sun.javafx.tools.ant:jar' (destfile: 'myApp.jar') {
        fileset(dir: 'build/classes/main')
    }
}

Then you can do:

gradle jar

gradle javaFxPackage