Reputation: 371
i write a javafx andoid application in netbeans with javafxports and gradle. I added the dependencies to gradel, but now i dont know how to add the jars to my project or to use it in my app-code. . .
Do you know how i can us it? I tried searching the www for hours ...
Ok i tried it but i dont get it ...
I did exactly what you said but netbeans still says: package io.netty.bootstrap does not exist
I created a folder unter src/android/ called libs and add my jar there ...
Here are my dependencies:
dependencies {
compile fileTree(dir: 'src/android/libs', include: ['*.jar'])
compile files('src/android/libs/netty-all-4.0.29.Final.jar')
}
FINAL SOLUTION:
compile 'io.netty:netty-all:4.0.24.Final'
to the build.gradle file. (Example for netty JAR-Libary)Thank you to José Pereda for the time and the final solution!
Upvotes: 2
Views: 1639
Reputation: 45486
Based on the edited question, these are a few suggestions for working with dependencies on a JavaFXPorts project.
Dependencies and build.gradle file
According to this, the default dependency configurations compile
and runtime
are supported, and the jfxmobile plugin adds extra configurations for each supported platform like androidCompile
or desktopRuntime
.
To access third party dependencies, from a given repository this should be added:
repositories {
jcenter()
}
dependencies {
compile 'groupId:artifactId:version'
}
Since jcenter()
is a superset of 'mavenCentral()`, you can use any maven dependency that was in the form of:
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0.4</version>
</dependency>
as compile 'groupId:artifactId:version'
. So in this case:
dependencies {
compile 'org.glassfish:javax.json:1.0.4'
}
Local files
Accesing local jars can be done using files
:
dependencies {
compile files('lib/my-jar.jar')
}
having my-jar.jar
at a lib
folder inside your project, but outside the src
folder.
If you want to add several jars:
dependencies {
compile fileTree(dir: 'lib', include: ['*.jar'])
}
Gluon plugin for NetBeans
After any change in the build.gradle
file, it is necessary to reload the project, so the new changes are taken into account, and the new dependencies are retrieved.
Under the Projects view, right click on the Project root and select Reload Project
.
Check also the Dependencies
folders, those should contain the jars included in the build.
Since there are several of these folders, you can see for instance that Compile for android
includes android.jar
and jfxdvk-8u60-b3.jar
. Compile for main
should contain all the jars defined for compile
.
Samples
These are some projects where the build.gradle
contains dependencies, so they are a good way to start with JavaFXPorts.
Upvotes: 3