SpringBoot 2 Migration from 1.5 Dependencies Error - java

I am working to migrate from Springboot 1.5 to 2.1. Our project has a main build.gradle file and then four subprojects (acceptance, application, shared, integration) with build.gradle it in. The problem is that the "shared" subproject is dependent on models from the "application" subproject and no longer seems to be able to pick them up. In IntelliJ I can tell it to import the models and it accepts that but when I do a "gradle clean build" it fails for the following:
C:\code\java\workspace\brokerage-customer\shared\src\test\java\com\##MASKED##\brokerage\customer\util\OrgTrustUtil.java:563: error: cannot find symbol
public static BrokerageCustomer generateExpectedBrokerageCustomer() {
^
symbol: class BrokerageCustomer
location: class OrgTrustUtil
I am new to using gradle (used maven in the past). The build.gradle file for shared is:
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
bootJar {
enabled = false
}
dependencies {
// testCompile project(':application').sourceSets.main.output
}
Note that I have commented out the testCompile line as it was fine in 1.5 but errors in 2.1.
I am kind of assuming the issue is with the testCompile having to be commented out but I have not found how to keep it since it errors when I try to build.
I found the issue was that I had not applied the dependency manager plugin. Adding this made it work:
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
bootJar {
enabled = false
}
dependencies {
testCompile project(':application').sourceSets.main.output
}

I found the issue was that I had not applied the dependency manager plugin. Adding this made it work:
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
bootJar {
enabled = false
}
dependencies {
testCompile project(':application').sourceSets.main.output
}

Related

Drools kie-maven-plugin error message using Gradle "plugin with id 'kie-maven-plugin' not found."

I've gotten the kie-maven-plugin to work with maven, but when using it with gradle I get the error plugin with id 'kie-maven-plugin' not found. I've added the kie-maven-plugin coordinates to both the plugin repository section as well as the project dependencies section with no luck (as well as either/or). Am I getting the apply plugin line right?
In buildscript -> repositories -> dependencies section:
classpath 'org.kie:kie-maven-plugin:7.35.0.Final'
In allprojects section:
apply plugin: 'kie-maven-plugin'
In allprojects -> dependencies section:
compile group: 'org.kie', name: 'kie-maven-plugin', version: "7.35.0.Final"
I've also tried the following to no avail:
apply plugin: 'org.kie.maven.plugin'
apply plugin: 'kie'
apply plugin: 'org.kie'
apply plugin: 'org.kie.kie'
apply plugin: 'org.kie.kie-maven-plugin'
apply plugin: 'org.kie:kie-maven-plugin'
apply plugin: 'org.kie.maven.plugin.ValidateDMNMojo'

"Classpath is incomplete" warning still appear even though a build.gradle exist

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'

Failed to apply plugin "com.google.gms.google-services"

Here is my project build.gradle:
buildscript {
...
dependencies {
...
classpath 'com.google.gms:google-services:3.1.0'
}
}
In one of the module's build.gradle I have this:
apply plugin: 'com.google.gms.google-services'
which results into the following error:
Could not get unknown property 'LibraryVariants' for object of type com.android.build.gradle.LibraryExtension.
Fun fact, if I set google-services version to 3.0.0, this specific error disappears, but Gradle asks me to downgrade versions of other google libraries, but I really do not want to do that.
How do I deal with these LibraryVariants?
You only set apply plugin: 'com.google.gms.google-services' in the app module, and in no other modules.
You must add one dependencies in your build.gradle(Project:project_name)
classpath 'com.google.gms:google-services:3.1.0'
And add in your build.gradle(build.gradle:Module app)
apply plugin: 'com.google.gms.google-services'
dependencies {
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
}
apply plugin: 'com.google.gms.google-services'

Apt for Java subproject

I am developing an Android project. I have a plain java subproject. I would like to activate the apt process for this java subproject. My gradle file:
project(':subproject') {
apply plugin: 'java'
apply plugin: 'android-apt'
dependencies {
compile files('../app/libs/sqliteannotations-api-0.1-SNAPSHOT.jar')
apt files('../app/libs_annotations/sqliteannotations-0.1-SNAPSHOT-jar-with-dependencies.jar')
}
}
but I get this error:
The android or android-library plugin must be applied to the project
Add apply plugin: 'com.android.application' if you are working on an app.
Add apply plugin: 'com.android.library' if you are working on a library.

plugin with id spring-boot not found in parent build.gradle

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.

Categories