Gradle execution failed for task ':compileTestJava' - java

I have encountered an error when running my Gradle program in Intellij-IDEA. I'm unsure why it gave me an error. I believe one of the dependencies might be deprecated if that's the case. Please enlighten me on this. Thanks. I have posted the Error StackTrace and Build.Gradle files below.
Error StackTrace
Execution failed for task ':compileTestJava'.
> Could not resolve all files for configuration ':testCompileClasspath'.
> Could not find android.arch.persistence.room:runtime:1.1.1.
Required by:
project :
Build.Gradle
plugins {
id 'org.springframework.boot' version '2.3.4.RELEASE'
}
apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'
sourceCompatibility = 1.8
targetCompatibility = 1.8
group 'AbtMainTestControl'
version '1.0-SNAPSHOT'
// Versioning of dependencies
wrapper.gradleVersion = '5.5.1'
def cucumberVersion = '4.7.1'
def junitVersion = '5.5.0'
def restVersion = '4.1.2'
def apacheDrillVersion = '1.17.0'
repositories {
jcenter()
mavenCentral()
}
dependencies {
implementation 'android.arch.persistence.room:runtime:1.1.1'
compile group: 'org.codehaus.jackson', name: 'jackson-core-asl', version: '1.9.13'
compile group: 'com.opencsv', name: 'opencsv', version: '4.0'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.12'
// https://mvnrepository.com/artifact/org.apache.drill.tools/tools-parent
compile group: 'org.apache.drill.tools', name: 'tools-parent', version: "${apacheDrillVersion}", ext: 'pom'
// Cucumber Pretty Report Plugin
compile group: 'de.monochromata.cucumber', name: 'reporting-plugin', version: '3.0.9'
testCompile group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '6.1.0.jre8'
compile group: 'org.apache.commons', name: 'commons-dbcp2', version: '2.7.0'
// Importing ModelMapper Library for DTO
compile 'org.modelmapper:modelmapper:2.3.3'
// Importing Spring Boot Dependency
implementation('org.springframework.boot:spring-boot-starter-web')
implementation('org.springframework.boot:spring-boot-starter-data-jpa')
testImplementation "io.cucumber:cucumber-java:${cucumberVersion}"
testImplementation "io.cucumber:cucumber-junit:${cucumberVersion}"
testImplementation "io.rest-assured:rest-assured:${restVersion}"
testImplementation "io.rest-assured:json-path:${restVersion}"
testImplementation "io.rest-assured:json-schema-validator:${restVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:${junitVersion}"
implementation 'junit:junit:4.12'
//Lombok plugin for DTO
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'
//MapStruct Mapper Framework for serialising DTO
implementation 'org.mapstruct:mapstruct:1.4.0.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.0.Final'
testCompileOnly 'org.projectlombok:lombok:1.18.12'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'
}
configurations {
cucumberRuntime {
extendsFrom testImplementation
}
}
task cucumber() {
dependsOn assemble, compileTestJava
doLast {
javaexec {
main = "io.cucumber.core.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['--plugin',
'pretty',
'--glue',
'gradle.cucumber',
'src/test/resources/features',
]
}
}
}
test {
//useJUnitPlatform()
systemProperty "cucumber.options", System.properties.getProperty("cucumber.options")
}
Note: I have re-posted the Build.Gradle file.

The answer that I thought was that my program focuses on DTO which the dependency that I had an issue with has got nothing to do with my program.
implementation 'android.arch.persistence.room:runtime:1.1.1'
In fact, the dependency includes android as the root word for the dependency which is more catered towards Android which doesn't make any sense with my DTO Program.
So what I did was to remove implementation 'android.arch.persistence.room:runtime:1.1.1' together with annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'. Eventually, the program works fine as I'm already using the MapStruct Annotation Processor to do mapping with DTO.

Related

Gradle unable to detect external dependency in another project

I have a multi-project gradle project with the following structure when running
gradle projects
The CommonUtils is a standalone project while Interceptor uses CommonUtils.
Root project 'main-project'
+--- Project ':CommonUtils'
+--- Project ':Interceptor'
\--- Project ':SearchService'
When running gradle build in main-project, I encountered this error:
Task :Interceptor:compileJava FAILED
In IntelliJ, I noticed it could not detect these 2 imports:
import com.google.gson.Gson;
import com.rometools.rome.feed.rss.Channel;
The build.gradle for CommonUtils is:
plugins {
id 'org.springframework.boot' version '2.2.0.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}
bootJar{
enabled=false
}
jar{
enabled=true
}
ext {
set('springCloudVersion', "Hoxton.SR1")
}
processResources {
def profile = (project.hasProperty('profile') ? project.profile : 'local').toLowerCase()
include "**/"
rename "bootstrap-${profile}.properties","bootstrap.properties"
include "bootstrap.properties"
}
dependencies {
implementation 'com.itextpdf:itextpdf:5.5.13.3'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-starter-config:2.2.0.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation platform('com.amazonaws:aws-java-sdk-bom:1.11.755')
implementation 'com.amazonaws:aws-java-sdk-s3'
implementation 'com.amazonaws:aws-java-sdk-elasticsearch'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'com.amazonaws:aws-java-sdk-sns:1.11.847'
implementation 'com.amazonaws:amazon-sqs-java-messaging-lib:1.0.4'
implementation 'org.springframework.boot:spring-boot-starter-mail:2.2.0.RELEASE'
implementation 'org.json:json:20160810'
implementation 'com.googlecode.json-simple:json-simple:1.1'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'mysql:mysql-connector-java:8.0.13'
implementation 'com.oracle.ojdbc:xmlparserv2:19.3.0.0'
implementation 'org.jsoup:jsoup:1.13.1'
implementation group: 'com.github.dozermapper', name: 'dozer-core', version: '6.5.0'
implementation group: 'com.github.dozermapper', name: 'dozer-spring-boot-starter', version: '6.5.0'
implementation group: 'com.itextpdf', name: 'itext7-core', version: '7.1.10', ext: 'pom'
implementation group: 'com.itextpdf', name: 'html2pdf', version: '2.1.7'
implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
implementation group: 'io.micrometer', name: 'micrometer-registry-elastic', version: '1.1.4'
implementation 'com.rometools:rome:1.18.0'
implementation fileTree(dir: 'libs', include: '*.jar')
implementation 'org.projectlombok:lombok:1.18.24'
implementation 'rome:rome:1.0'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
runtimeOnly('mysql:mysql-connector-java')
testImplementation('org.springframework.boot:spring-boot-starter-test')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
The build.gradle for Interceptor is:
plugins {
id 'org.springframework.boot' version '2.2.0.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}
bootJar{
enabled=false
}
jar{
enabled=true
}
dependencies {
implementation project(':CommonUtils')
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
implementation 'org.apache.commons:commons-io:1.3.2'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'javax.servlet:javax.servlet-api:3.1.0'
}
Is the failed dependency in the Interceptor project? You can either change the problematic dependencies in CommonUtils to be api instead of implementation which would let them be accessible from the Interceptor project or you can add them again to the Interceptor project.

Spring boot kafka application is not start as console app after upgrading gradle and spring boot version

upgradation details.
Spring boot : 2.2.7-RELEASE to 2.4.6
gradle: 4.10.3 to 6.9.2
build.gradle
plugins{
id 'org.springframework.boot' version '2.4.6'
id 'io.spring.dependency-management' version '1.0.11.RELESE'
id 'java'
}
sourceCompatibility ='1.8'
dependency-management{
import {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:2020.0.4"
}
}
dependencies{
implmentation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implmentation 'org.springframework.boot:spring-boot-starter-web'
implmentation 'org.springframework.kafka:spring-kafka'
implmentation 'org.projectlombok.lombok'
testImplmentation 'org.springframework.boot:spring-boot-starter-test'
implmentation 'org.springframework.cloud:spring-cloud-starter-config'
implmentation 'org.springframework.cloud:spring-cloud-starter-bootstrap'
compile 'org.springframework.boot:spring-boot-starter-webflux'
implmentation 'org.springframework.boot:spring-boot-starter-data-jpa'
compile(group: 'org.springframework.boot', name: 'spring-boot-configuaration-processor')
compile(group: 'com.microsoft.sqlserver', name: 'mssql-jdbc' version: '8.3.1.jre8-preview')
runtimeOnly 'com.microsoft.sqlserver:mysql-jdbc'
implmentation 'io.springfox:springfox-swagger2:2.9.2'
implmentation 'io.springfox:springfox-swagger-ui:2.9.2'
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'org.projectreactor:reactor-spring'
implmentation 'io.micrometer:micrometer-registry-prometheus'
implmentation 'javax.mail:mail:1.4'
testImplmentation 'junit:junit'
annotationProcessor 'org.projectlombok:lombok'
}
wrapper{
distribuationUrl = "https://services.gradle.org/distributions/gradle-6.9.2-bin"
}
main class:
#SpringBootApplication(exclude={DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class,HibernateJpaAutoConfiguration.class})
#EnableKafka
#EnableScheduling
public class SpringBootMainClassApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootMainClassApplication.class, args);
}
}
application.properties
server.port=8080
Error:
“ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean“.
enter image description here
Code running fine after adding below properties to application.properties.
spring.main.web-application-type=none
Application is working fine as console app without changing spring.main.web-application-type=none to properties with old version spring boot 2.2.7-RELEASE, Can you please help us to run application without adding new properties?
It is working fine, seems you gradle has lot of errors
Please use this gradle, always love your code as beautiful it could be like a painting :)
plugins {
id "io.spring.dependency-management" version "1.0.11.RELEASE"
id "org.springframework.boot" version "2.4.6"
id "java"
}
sourceCompatibility ='1.8'
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
mavenCentral()
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:2020.0.4"
}
}
dependencies
{
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jdbc'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
implementation group: 'org.springframework.kafka', name: 'spring-kafka'
implementation 'io.springfox:springfox-swagger2:2.9.2'
implementation 'io.springfox:springfox-swagger-ui:2.9.2'
implementation 'org.springframework.cloud:spring-cloud-starter-config'
implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'io.micrometer:micrometer-registry-prometheus'
implementation 'javax.mail:mail:1.4'
compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.24'
compileOnly group: 'org.springframework.boot', name: 'spring-boot-configuaration-processor'
compileOnly group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '8.3.1.jre8-preview'
compileOnly 'org.springframework.boot:spring-boot-starter-webflux'
compileOnly 'org.springframework.boot:spring-boot-starter-actuator'
compileOnly 'org.projectreactor:reactor-spring'
runtimeOnly 'com.microsoft.sqlserver:mysql-jdbc'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'junit:junit'
annotationProcessor 'org.projectlombok:lombok'
}

Error when adding #Entity tag in my entity class run by Java Gradle Program

I'm currently using Gradle program which requires me to implement DTO with 2 Entity Classes but as soon as I add the #Entity tag in one of the entity classes, it says Cannot resolve symbol Entity when I hover the cursor onto it.
Build.Gradle
plugins {
id 'org.springframework.boot' version '2.3.4.RELEASE'
}
apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'
sourceCompatibility = 1.8
targetCompatibility = 1.8
group 'AbtMainTestControl'
version '1.0-SNAPSHOT'
// Versioning of dependencies
wrapper.gradleVersion = '5.5.1'
def cucumberVersion = '4.7.1'
def junitVersion = '5.5.0'
def restVersion = '4.1.2'
def apacheDrillVersion = '1.17.0'
repositories {
jcenter()
mavenCentral()
}
dependencies {
implementation 'android.arch.persistence.room:runtime:1.1.1'
compile group: 'org.codehaus.jackson', name: 'jackson-core-asl', version: '1.9.13'
compile group: 'com.opencsv', name: 'opencsv', version: '4.0'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.12'
// https://mvnrepository.com/artifact/org.apache.drill.tools/tools-parent
compile group: 'org.apache.drill.tools', name: 'tools-parent', version: "${apacheDrillVersion}", ext: 'pom'
// Cucumber Pretty Report Plugin
compile group: 'de.monochromata.cucumber', name: 'reporting-plugin', version: '3.0.9'
testCompile group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '6.1.0.jre8'
compile group: 'org.apache.commons', name: 'commons-dbcp2', version: '2.7.0'
// Importing ModelMapper Library for DTO
compile 'org.modelmapper:modelmapper:2.3.3'
testImplementation "io.cucumber:cucumber-java:${cucumberVersion}"
testImplementation "io.cucumber:cucumber-junit:${cucumberVersion}"
testImplementation "io.rest-assured:rest-assured:${restVersion}"
testImplementation "io.rest-assured:json-path:${restVersion}"
testImplementation "io.rest-assured:json-schema-validator:${restVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:${junitVersion}"
implementation 'junit:junit:4.12'
//Lombok plugin for DTO
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'
//MapStruct Mapper Framework for serialising DTO
implementation 'org.mapstruct:mapstruct:1.4.0.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.0.Final'
testCompileOnly 'org.projectlombok:lombok:1.18.12'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'
}
configurations {
cucumberRuntime {
extendsFrom testImplementation
}
}
task cucumber() {
dependsOn assemble, compileTestJava
doLast {
javaexec {
main = "io.cucumber.core.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['--plugin',
'pretty',
'--glue',
'gradle.cucumber',
'src/test/resources/features',
]
}
}
}
test {
//useJUnitPlatform()
systemProperty "cucumber.options", System.properties.getProperty("cucumber.options")
}
Can someone enlighten me on how to resolve this issue?
Note: This program hasn't been run yet so no StackTrace. Moreover, the implementation of entity classes is not yet completed.
You haven't imported the spring dependencies yet. You need to do that manually, as is shown in the documentation:
dependencies {
implementation('org.springframework.boot:spring-boot-starter-web')
implementation('org.springframework.boot:spring-boot-starter-data-jpa')
}

Syntax Error in query Hibernate OGM 5.4.1 final when jar but running from eclipse, working fine build jar from gradle

When I hit the API from postman, Data needs to be fetched from Mongodb but it's not able to fetch the records from mongodb via hibernate ogm since it's showing error as syntax error in query hibenrateExpection via jar file. but when I try to run it in eclipse, it's able to fetch the records from mongodb. Could someone experienced this issue?
plugins {
id 'org.springframework.boot' version '2.2.6.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
apply plugin: 'java'
apply plugin: 'eclipse'
group = 'com.local.java.programs'
version = '0.0.1'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
all {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
// implementation 'org.springframework.boot:spring-boot-starter-data-mongodb-reactive'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation 'io.projectreactor:reactor-test'
// https://mvnrepository.com/artifact/org.hibernate.ogm/hibernate-ogm-mongodb
compile group: 'org.hibernate.ogm', name: 'hibernate-ogm-mongodb', version: '5.4.1.Final'
// https://mvnrepository.com/artifact/org.hibernate/hibernate-core
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.3.16.Final'
compile('org.springframework.boot:spring-boot-starter-log4j2')
compile'org.springframework.boot:spring-boot-starter-data-mongodb'
compile 'org.springframework.boot:spring-boot-starter-security'
compile 'org.springframework.boot:spring-boot-starter-mail'
// https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt
compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'
// https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
// https://mvnrepository.com/artifact/org.springframework/spring-webflux
compile group: 'org.springframework', name: 'spring-webflux'
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.12'
// https://mvnrepository.com/artifact/io.projectreactor/reactor-test
testCompile group: 'io.projectreactor', name: 'reactor-test', version: '3.3.5.RELEASE'
// https://mvnrepository.com/artifact/org.json/json
compile group: 'org.json', name: 'json', version: '20200518'
}
test {
useJUnitPlatform()
}

spring clound eureka server dependencies error gradle intellij

Am not able to add the spring-cloud-netflix-eureka-server as dependencies in gradle project (IDE Intellij)
please find my build.gradle file below.
plugins {
id 'org.springframework.boot' version '2.3.1.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
id 'war'
}
group = 'com.lti.mod.services'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation('io.jsonwebtoken:jjwt:0.9.1')
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-rest'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.liquibase:liquibase-core'
/*compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'*/
compile('org.springframework.cloud:spring-cloud-netflix-eureka-server:2.1.5.RELEASE')
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'mysql:mysql-connector-java'
annotationProcessor 'org.projectlombok:lombok'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation 'org.springframework.security:spring-security-test'
}
test {
useJUnitPlatform()
}
Please find the gradle build messages below.
> Configure project : The compile configuration has been deprecated for dependency declaration. This will fail with an error in Gradle 7.0. Please use the implementation configuration instead. Consult the upgrading guide for further information: https://docs.gradle.org/6.4.1/userguide/upgrading_version_5.html#dependencies_should_no_longer_be_declared_using_the_compile_and_runtime_configurations
at build_5fewyf5k4gqf0wzmewce4q3ow$_run_closure3.doCall(D:\AngularCourse\core-services\build.gradle:30)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
compile configuration is deprecated in the Gradle 7.0 as your error message says. Please use implementation instead.
Check the docs - https://docs.gradle.org/current/userguide/java_plugin.html#tab:configurations

Categories

Resources