Reputation: 11
I'm building a JavaFx project using Eclipse and I have a file structure like this:
Project
│ .classpath
│ .gitignore
│ .project
│ build.fxbuild
│ README.md
│ (sqlite).db (*local database this project operates on)
│
├───.settings
│ ...
│
├───bin
│ ...
│
├───lib
│ ...
│
└───src
├───application
| ...
│ Main.java
│
├───controllers
│ ...
│
├───css
│ ...
│
├───fxml
│ ...
│
└───resources
123.jpg
How do I convert this into a gradle project? I'm totally new to gradle and I have hard time finding documentation to get started.
*I'm using JavaFx 8 and jdk-9.
Upvotes: 1
Views: 1407
Reputation: 15706
I have hard time finding documentation to get started.
Gradle is well-documented, if you google you find a lot of beginner's tutorials as well, and there's lots of examples on GitHub. See https://guides.gradle.org/building-java-applications/
The documentation is quite overwhelming, and you need to familiarize yourself with a bunch of concepts too. As a starter, you need to grasp following concepts:
src/main/java
for Java sources src/main/resources
for resources (get bundled into the JAR/WAR/EAR)src/test/java
for Java test sources src/test/resources
for test resources build.gradle
file defines your project and how it should be built. Each project/artefact has a groupId, artefactId and version.clear
, test
, build
, deploy
, execute gradle tasks
to list all tasks. lib
folder, but rather you declare dependencies to libraries (browse for them on Maven Central. Gradle will take care of the dependency management and download libs and transient dependencies automatically.Here's the generic build.gradle
which I use as a starter for my projects (with a cleaner approach to managing dependencies), for JDK 9/10/11+ you can change the compatibility java version to 9/10/11+:
defaultTasks 'clean', 'build'
apply plugin: 'java'
description = 'Example Java Project'
group = 'org.test'
version = '1.0.0-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava.options.encoding = 'UTF-8'
repositories {
jcenter()
}
ext.libs = [
testbase: [
"junit:junit:4.12"
],
loggingAPI : [
"org.slf4j:slf4j-api:1.7.25"
],
loggingImpl : [
"org.slf4j:jcl-over-slf4j:1.7.25",
"org.slf4j:jul-to-slf4j:1.7.25",
"ch.qos.logback:logback-classic:1.2.3"
]
]
dependencies {
testCompile libs.testbase
compile libs.loggingAPI
compile libs.loggingImpl
}
Upvotes: 3