How do I set up my JavaFX project as a Gradle build? - eclipse

I've created a new JavaFX project via the e(fx)clipse plugin, then staged and committed to Git. Following that I tried to run it and got a 'class not found' error - needed to add JavaFX to the --module-path in VM arguments. But it still won't run:
Error: Could not find or load main class Files\Java\AdoptOpenJDK\javafx-sdk-13.0.2\lib
Caused by: java.lang.ClassNotFoundException: Files\Java\AdoptOpenJDK\javafx-sdk-13.0.2\lib
Then I noticed that I have no build files in the project tree - no pom.xml or build.gradle, etc.
I decided to build with Gradle (previously only used Maven). After a lot of hunting on the net I did the following:
Project context menu -> Configure -> Add Gradle nature (this didn't visibly do anything, but the option is no longer available).
In the Gradle Tasks view, run init. (This ran fine until it got to Execute setupProjectLayout for :init. This got stuck and I let it sit for about 20 mins, but there was no activity (checked task manager to confirm)).
There must be something fundamental that I'm missing here, surely it shouldn't be this difficult. How can I get this project to build in Gradle?

The Gradle init task is an interactive task to generate a new Gradle project. If you run it from the IDE but have no way to provide answers to the prompts from Gradle, it will indeed wait forever on an input.

You do not need a CLI for input.
After you run the gradle task in the "Gradle Tasks" view you switch to the "Console" view and you are presented with the questions by gradle init. You answer those questions and finish the task.
Working Directory: /path/to/your/project/thenewgradleproject
Gradle user home: /home/user/.gradle
Gradle Distribution: Gradle wrapper from target build
Gradle Version: 6.8
Java Home: /usr/lib/jvm/java-11-openjdk-amd64
JVM Arguments: None
Program Arguments: None
Build Scans Enabled: false
Offline Mode Enabled: false
Gradle Tasks: init
> Task :wrapper UP-TO-DATE
Select type of project to generate:
1: basic
2: application
3: library
4: Gradle plugin
Enter selection (default: basic) [1..4]
> Task :init
Select build script DSL:
1: Groovy
2: Kotlin
Enter selection (default: Groovy) [1..2]
Project name (default: thenewgradleproject):
> Task :init
Get more help with your project: Learn more about Gradle by exploring our samples at https://docs.gradle.org/6.8/samples
BUILD SUCCESSFUL in 53s
2 actionable tasks: 1 executed, 1 up-to-date

Related

* What went wrong: A problem occurred evaluating project ':app'. > org/bouncycastle/operator/OperatorCreationException

In Every flutter build, even in a fresh one, I'm getting the same error1
lib/main.dart:1
FAILURE: Build failed with an exception.
* Where:
Build file '/home/aabirsark/Desktop/projects/rx_converter/android/app/build.gradle' line: 24
* What went wrong:
A problem occurred evaluating project ':app'.
> org/bouncycastle/operator/OperatorCreationException
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 28s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
Pls help me with this... I'm really stuck with it and can't make more progress pls help!!!
6 Steps:
click on Project Structure (folder with 3 dot icon next to Stop icon).
Project Structure --> Project Settings --> Project
under Project SDK: Select Android API 30 Platform
click Apply --> OK
click on Project Structure (folder with 3 dot icon next to Stop icon).
Project Structure --> Project Settings --> Modules
click + icon --> Apply --> OK
Use latest Gradle
Set the JDK version to Embedded JDK
For MAC:
Android Studio > Preferences... > Build, Execution, Deployment > Build Tools > Gradle Under Gradle JDK
choose the Embedded JDK option. Click OK.
For windows:
select File > Settings... > Build, Execution, Deployment > Build Tools > Gradle Under Gradle JDK
choose the Embedded JDK option.
--add-opens If you have to allow code on the class path to do deep reflection to access nonpublic members, then use the --add-opens runtime option.
Some libraries do deep reflection, meaning setAccessible(true), so they can access all members, including private ones. You can grant this access using the --add-opens option on the java command line. No warning messages are generated as a result of using this option.
If --illegal-access=deny, and you see IllegalAccessException or InaccessibleObjectException messages at runtime, you could use the --add-opens runtime option, basing the arguments upon the information shown in the exception message.
config jvm option Since version 9, the Java compiler can be configured to produce bytecode for an older Java version while making sure the code does not use any APIs from a more recent version. Gradle now supports this release flag on CompileOptions directly for Java compilation. This option takes precedence over the properties described below.
Due to a bug in Java 9 that was fixed in Java 10, Gradle cannot leverage the release flag when compiling with Java 9.
This should solve..

How to run pre build gradle java project in intellij

I have been using eclipse. Recently, I started using intellij IDE.
My project is core java project with gradle as build tool. In eclipse, i used to build the project through command like and import it into the project. Then i used to run it without any issues.
One of the below command i used to use frequently.
gradle -s --refresh dependencies clean build eclipse -x findbugsMain -x checkstyleMain
gradle -s --refresh dependencies clean build -x findbugsMain -x checkstyleMain
gradle build -x findbugsMain -x checkstyleMain
Now when i try imported my projects as module in intellij and try to run, it tries to build everything again and fails with error.
I do not want intellij to build the project again but to use the already build one which i did through command line.
If you build form command line first, then build from IDE with Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Gradle | Build and run using option set to Gradle, IDE will reuse previous build cache results, provided that there were no changes since last Gradle build. It is important to note 2 things:
Build from IDE should be invoked as Build | Build action, not Rebuild. The Rebuild IDE action is not the same as Gradle clean build task. With clean build Gradle will re-use cache (if enabled) and will not rebuild all the classes and process all the resources if there were no changes. In case of the IDE Rebuild action - IDE will mark previous build results as "dirty" and will recompile all the classes and resources.
The Gradle you configure for the project in IDE settings must be the same as you use in command line. To be sure the same Gradle is used it is easier of all to configure to use Gradle wrapper for project.
Also if you do not want for the IDE to build at all you can remove Make action from Before launch section of your Run/Debug Configuration.

gradle.properties in project build directory not read via Eclipse/Buildship - command line works fine

I use the latest Eclipse (version 4.12) with Buildship Gradle Integration 3.0.
I can see the tasks in the Gradle Tasks view, but I cannot run the tasks successfully.
When I run a task from the command line then it works fine.
When I run a task by double clicking the task in the Gradle Tasks view then the task fails with the following error message:
java.lang.IllegalArgumentException: Pfad[src] existiert nicht.
This translates to
java.lang.IllegalArgumentException: Path[src] does not exist.
src is a directory defined in the project's gradle.properties file as follows:
GEN_ROOT_PATH=src
The project's gradle.properties file is in the same directory as the build.gradle script.
In the build.gradle file I refer to the property as project.GEN_ROOT_PATH
I believe that is what is what the exception complains about when I run the task from the Gradle Tasks view.
I do not understand, and I could not find helpful information in the internet to solve this issue.
As I said before, the tasks can be run successfully in the command line.
The tasks fail when run in Eclipse. Does anyone have an idea what the issue can be? How can I approach a possible solution?

Gradle Build Configuration help - Eclipse Oxygen

I'm using eclipse oxygen and i was trying to run Gradle Buid on build.gradle file. I have installed Buildship Gradle Integration 2.0 and also configured the dependencies. The issue is when i right click on build.gradle and try to run as, i don't have the option Grade Build.
Instead of right-clicking the build.gradle file use the Gradle Tasks view to execute a Gradle task:
Window > Show View > Others...: Gradle > Gradle Tasks
Double-click a task
See also my short video on how to execute a Gradle task.

Eclipse PDE headless build fails with: failed to create task or type eclipse.generateFeature

I want to build an Eclipse RCP application with a PDE headless build. When I run the Ant script of the build it fails with the following error message:
failed to create task or type eclipse.generateFeature
Cause: The name is undefined.
I found the solution in the discussion here:
It is important to run the Ant script of the build within the same JRE as the workspace because otherwise the PDE Ant tasks cannot be found:
Right click on the Ant script (build.xml) > Run As > Ant Build … > JRE tab of the wizard > switch to option: 'Run in the same JRE as the workspace'