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.
To add a dependency to your project, specify a dependency configuration such as implementation in the dependencies block of your module's build.gradle file.
Gradle can consume dependencies available in the local Maven repository. Declaring this repository is beneficial for teams that publish to the local Maven repository with one project and consume the artifacts by Gradle in another project. Gradle stores resolved dependencies in its own cache.
It is a programmer error to create any circular dependencies among a set of operations. Doing so can cause a deadlock among the operations and may freeze your program.
Perform a Gradle sync/reload properties is part of the Gradle build. Consequently, after you have edited it, you need to ensure the IDE gets the changes. Android Studio: Run the “Sync Project with Gradle Files” action (via ctrl / cmd + shift + A ), or click the elephant + arrow icon in the toolbar.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With