From what I understand here, the "Classpath is incomplete" warning will not appear if I open a folder which has build.gradle file in it.
In my case, I have a build.gradle file but still the pop up appear.
Here is my build.gradle
apply plugin: 'java'
apply plugin: 'application'
mainClassName = 'hello.HelloWorld'
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile "joda-time:joda-time:2.2"
testCompile "junit:junit:4.12"
}
jar {
baseName = 'gs-gradle'
version = '0.1.0'
}
Did I missing something?
Please bear with me this is my first time with Gradle.
Thanks!
I had the same, and fixed it by adding the following to my build.gradle:
apply plugin: 'eclipse'
Related
Trying out to use ObjectBox as java desktop database. However after following the documentation on the web site https://docs.objectbox.io/java-desktop-apps its not working. No MyObjectBox found error.
I am using eclipse ide Version: 2020-09 (4.17.0), Gradle: gradle-6.7.1
ObjectBox seems not creating the model automatically after build (no model folder generated). I have created the class using the Entity annotation, build the project eclipse, nothing happens. Anyone any ideas?
Works in android but not desktop. As i am not familiar with gradle project in eclipse. the following is the build file
buildscript {
ext.objectboxVersion = '2.8.1'
repositories {
jcenter()
}
dependencies {
classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
}
}
apply plugin: 'java-library'
apply plugin: 'io.objectbox'
targetCompatibility = '1.8'
sourceCompatibility = '1.8'
repositories {
jcenter()
}
dependencies {
implementation "io.objectbox:objectbox-linux:$objectboxVersion"
implementation "io.objectbox:objectbox-macos:$objectboxVersion"
implementation "io.objectbox:objectbox-windows:$objectboxVersion"
}
apply plugin: 'io.objectbox'
dependencies {
implementation "io.objectbox:objectbox-java:$objectboxVersion"
annotationProcessor "io.objectbox:objectbox-processor:$objectboxVersion"
}
apply plugin: 'io.objectbox'
Doing apply plugin: 'io.objectbox' three times does not look good. Once is enough. Please check the ObjectBox Java examples for a working setup. In your case have a closer look at the java-main example for standalone Java applications.
This is the basic structure with ... where I left out the details (check the full build.gradle file from the example):
buildscript {
...
}
apply plugin: 'java'
apply plugin: 'application'
targetCompatibility = '1.8'
sourceCompatibility = '1.8'
mainClassName = "io.objectbox.example.Main"
dependencies {
...
}
// Apply plugin after dependencies block so they are not overwritten.
apply plugin: 'io.objectbox'
Maybe checkout the example and start from there?
I have this gradle config:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group 'mygroup'
version '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
...
}
bootJar {
mainClassName = 'mypakeg.Application'
archiveName = 'my-server.jar'
}
sourceSets.configureEach { sourceSet ->
tasks.named(sourceSet.compileJavaTaskName).configure {
options.annotationProcessorGeneratedSourcesDirectory = file("$projectDir/generated/sources/java")
}
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa")
implementation ('org.hibernate:hibernate-jpamodelgen')
annotationProcessor ('org.hibernate:hibernate-jpamodelgen')
implementation('org.projectlombok:lombok')
annotationProcessor 'org.projectlombok:lombok'
}
After build I have folder generated/sources/java with generated files. But Intellij IDE not see this classes. I try click rigth button and marck this folder as root generated classes. But It not helpet becaus:
I have separated module my_server and my_server_main and all classes generated in my_server but my code in my_server_main and if I add dependency to my_server_main I have circular dependency.
How can I generate classes and set path to them?
I have groovy application that i want to pack in executable jar with gradle.
The problem is when the jar is done i have error: Could not find or load main class .
Here is my build.gradle:
group 'com.demo'
version '1.0-SNAPSHOT'
apply plugin: 'groovy'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin:'application'
mainClassName = 'com.demo.App'
buildscript {
repositories {
mavenCentral()
}
dependencies {}
}
repositories {
mavenCentral()
}
// java version dependency
sourceCompatibility = 1.8
targetCompatibility = 1.8
jar {
baseName = 'cim-configurator'
version = '0.1.0'
manifest {
attributes("Build-Time": new Date().format("yyyy-MM-dd HH:mm:ss"),
"Build-Jdk": System.getProperty("java.version"),
"Built-By": System.getProperty("user.name"),
"Created-By": "Gradle",
"Main-Class": "com.demo.App"
)
}
}
Here is the file hierarchy:
com.demo
ActiveMq
App
Database
Rbac
Run.groovy
Service
I think that using uberjar will fix your problem. It worked with similar case for me.
I had this exact same problem in a Groovy & Gradle project. This is the answer that fixed this problem.
TL;DR
Use the Shadow-jar plugin by adding the following plugin to your plugins block in build.gradle:
plugins {
id 'com.github.johnrengelman.shadow' version '5.0.0'
}
Then run ./gradlew shadowJar
You'll get a jar file emailer-all.jar, which can be run.
I have below project structure:
java/
build.gradle
settings.gradle
projectA/
build.gradle
projectB/
build.gradle
When I put below codes in, e.g. projectA's build.gradle,
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
...
everything works fine.
But if I put the above code in Java's build.gradle:
subprojects {
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
...
}
When running gradle clean build, it keeps reporting below error:
Plugin with id 'spring-boot' not found.
Anyone encountered this issue before? And why?
I figured out a solution but don't know why. Will spent some time reading the docs during the weekend...
Change multi-project build.gradle to below:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE")
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
...
}
i.e move buildscript out of subprojects
Try using fully qualified name as below:
plugins{
id 'org.springframework.boot' version '2.0.3.RELEASE'
id 'java'
}
You need to specify version of some plugins, you just have to. But gradle doesn't want multiple different versions, even though you type the same version in multiple files, if they include each other it won't work.
So to fix that you have to move common plugin to the root project, it doesn't matter if some projects don't use it, read further. Here is the trick part, you need to put apply false in the root project to the plugins. Thanks to that it won't be applied to the root and other projects but it will be applied to all of the projects you will add the plugin to.
So in root you would put:
plugins{
id 'org.springframework.boot' version '2.0.3.RELEASE' apply false
}
But in subproject you put it without the version
plugins {
id 'org.springframework.boot'
}
Also don't forget to put include statements in the root project, for all the folders that root needs to apply to.
I am new to gradle.
I am building a project using gradle.
It build successfully without any error. While running the build jar file it is giving classNotFoundException.
I am building a simple spring project from spring.io
However question look similar to this but, could not find a solution. Please help.
edit: This is how my build.gradle looks
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'gs-rest-service'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile("junit:junit")
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
startScripts {
mainClassName = 'Application'
}
springBoot {
mainClass = "Application"
}
You'll need to start the application with the generated start scripts. They will automatically take care of setting up the proper classpath.