javafx-packager ...">

How to add a "system" dependency in Gradle?

I have 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 this:

 dependencies { compile files("${System.getenv('JAVA_HOME')}/../lib/ant-javafx.jar") } 

as suggested by Giuseppe Ricupero, but I still get compilation 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:

 <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> fibrefox@dynamicfiles.de </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 , as Giuseppe Ricupero recommended, and he 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 this does not work, it causes 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. 
+5
source share
1 answer

UPDATE

The gradle init task gradle init automatically (try?) Convert (s) pom.xml to equivalent gradle files. You can try:

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

It seems to me that you just need to add the file, for example:

 dependencies { compile files("${System.getenv('JAVA_HOME')}/../lib/ant-javafx.jar") } 

You can see more in the docs .

+2
source

Source: https://habr.com/ru/post/1274812/


All Articles