Reputation: 287740
I have a pom.xml
that looks like this:
<dependencies>
<dependency>
<groupId>javafx-packager</groupId>
<artifactId>javafx-packager</artifactId>
<version>1.8.0_40</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/ant-javafx.jar</systemPath>
</dependency>
</dependencies>
How do I do the same in Gradle?
Update: I tried doing this:
dependencies {
compile files("${System.getenv('JAVA_HOME')}/../lib/ant-javafx.jar")
}
as suggested by Giuseppe Ricupero, but I'm still getting the compile errors:
>gradle build
> Task :compileJava FAILED
C:\Users\pupeno\Documents\Dashman\code\custom-file-extension-windows-bundler\src\main\java\com\oracle\tools\packager\windows\CustomLauncherFileExtensionAppBundler.java:17: error: cannot find symbol
import static com.oracle.tools.packager.StandardBundlerParam.*;
^
symbol: class StandardBundlerParam
location: package com.oracle.tools.packager
C:\Users\pupeno\Documents\Dashman\code\custom-file-extension-windows-bundler\src\main\java\com\oracle\tools\packager\windows\CustomLauncherFileExtensionAppBundler.java:18: error: cannot find symbol
import static com.oracle.tools.packager.windows.WindowsBundlerParam.*;
^
symbol: class WindowsBundlerParam
location: package com.oracle.tools.packager.windows
C:\Users\pupeno\Documents\Dashman\code\custom-file-extension-windows-bundler\src\main\java\com\oracle\tools\packager\windows\CustomLauncherFileExtensionAppBundler.java:23: error: cannot find symbol
public class CustomLauncherFileExtensionAppBundler extends AbstractImageBundler {
The full pom.xml
I'm trying to convert to Gradle is:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.dynamicfiles.projects.javafx.bundler</groupId>
<artifactId>custom-file-extension-windows-bundler</artifactId>
<version>1.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<developers>
<developer>
<name>Danny Althoff</name>
<email>[email protected]</email>
<url>https://www.dynamicfiles.de</url>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<version.java.source>1.8</version.java.source>
<version.java.target>1.8</version.java.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${version.java.source}</source>
<target>${version.java.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
<manifestEntries>
<display_version>${display_version}</display_version>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javafx-packager</groupId>
<artifactId>javafx-packager</artifactId>
<version>1.8.0_40</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/ant-javafx.jar</systemPath>
</dependency>
</dependencies>
</project>
Update 2: I tried gradle init
like Giuseppe Ricupero recommended and it came up with this build.gradle
:
apply plugin: 'java'
apply plugin: 'maven'
group = 'de.dynamicfiles.projects.javafx.bundler'
version = '1.0.1-SNAPSHOT'
description = """"""
sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
repositories {
maven { url "http://repo.maven.apache.org/maven2" }
}
dependencies {
system group: 'javafx-packager', name: 'javafx-packager', version: '1.8.0_40'
}
but that doesn't work, it throws this error:
> Could not find method system() for arguments [{group=javafx-packager, name=javafx-packager, version=1.8.0_40}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Upvotes: 6
Views: 3882
Reputation: 6272
UPDATE
The gradle init
task automatically (try to?) convert(s) the pom.xml
into the equivalent gradle files. You can try them:
build.gradle
apply plugin: 'java'
apply plugin: 'maven'
group = 'de.dynamicfiles.projects.javafx.bundler'
version = '1.0.1-SNAPSHOT'
description = ""
sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
repositories {
maven { url "http://repo.maven.apache.org/maven2" }
}
dependencies {
system group: 'javafx-packager', name: 'javafx-packager', version:'1.8.0_40'
}
settings.gradle
rootProject.name = 'custom-file-extension-windows-bundler'
If you mix this with the original answer:
apply plugin: 'java'
apply plugin: 'maven'
group = 'de.dynamicfiles.projects.javafx.bundler'
version = '1.0.1-SNAPSHOT'
description = """"""
sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
repositories {
maven { url "http://repo.maven.apache.org/maven2" }
}
dependencies {
compile files("${System.getenv('JAVA_HOME')}/lib/ant-javafx.jar")
}
it works.
Original answer
I think you need just to add a file dep like:
dependencies {
compile files("${System.getenv('JAVA_HOME')}/../lib/ant-javafx.jar")
}
You can see more in the docs.
Upvotes: 4