I was able to finally get a Gradle application project working with Eclipse. (For some odd reason, when you use Eclipse to create Gradle project, it creates a library (i.e. non-executable) one, and has no options to choose other project forms.)
I’m able to not only get it working in Eclipse (i.e. no errors when I “Refresh Gradle project”), but am able to gradle clean build
it as well.
However, when I try to gradle run
it, I face issue:
$ gradle run --args="--jsonConfig cliConfig.json"
> Task :lib:run FAILED
Error: Could not find or load main class com.signaturemd.sposZohoMergeScript.App
Caused by: java.lang.ClassNotFoundException: com.signaturemd.sposZohoMergeScript.App
The build.gradle
lives in child lib
folder, and is defined to be:
plugins {
id 'application'
}
application {
mainClass = 'com.signaturemd.sposZohoMergeScript.App'
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
// SOURCE: ChatGPT AI
task createJar(type: Jar) {
manifest {
attributes 'Main-Class': 'com.signaturemd.sposZohoMergeScript.App'
}
baseName = 'SposZohoMergeScript' // deprecated
from(sourceSets.main.output) {
include '**/*'
}
with jar
}
dependencies {
// Use JUnit Jupiter for testing.
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2'
// This dependency is exported to consumers, that is to say found on their compile classpath.
// api 'org.apache.commons:commons-math3:3.6.1'
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:30.1.1-jre'
// https://mvnrepository.com/artifact/org.apache.poi/poi
implementation 'org.apache.poi:poi:5.2.3'
// https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml
implementation 'org.apache.poi:poi-ooxml:5.2.3'
// https://mvnrepository.com/artifact/org.apache.groovy/groovy-cli-commons
implementation 'org.apache.groovy:groovy-cli-commons:4.0.9'
// https://mvnrepository.com/artifact/org.apache.groovy/groovy-json
implementation 'org.apache.groovy:groovy-json:4.0.9'
}
tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
and my project structure, which I didn’t change from Eclipse Gradle project structure, is like this:
Also, settings.gradle
, which lives in project root folder, was not modified in any way from what Eclipse Gradle plugin generated:
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user manual at https://docs.gradle.org/7.2/userguide/multi_project_builds.html
*/
rootProject.name = 'com.signaturemd.sposZohoMergeScript'
include('lib')
What am I doing wrong in my build.gradle
file or my project structure?