I created a new Spring boot application with Intellij Idea. It has dependencies on some Jars which are our own. My Gradle file looks like this.
plugins {
id 'org.springframework.boot' version '2.5.0'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'com.company'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
compile files('lib/Common.jar')
compile files('lib/ConnectionManager.jar')
compile files('lib/LogManager.jar')
compile files('lib/Licensing.jar')
compile files('lib/Messaging.jar')
compile files('lib/Communication.jar')
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
implementation 'org.springframework.boot:spring-boot-starter-data-rest'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.microsoft.sqlserver:mssql-jdbc'
runtimeOnly 'com.oracle.database.jdbc:ojdbc8'
runtimeOnly 'mysql:mysql-connector-java'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
}
test {
useJUnitPlatform()
}
I tried to add dependencies of jar files using
compile files('lib/Common.jar')
compile files('lib/ConnectionManager.jar')
compile files('lib/LogManager.jar')
compile files('lib/Licensing.jar')
compile files('lib/Messaging.jar')
compile files('lib/Communication.jar')
This approach has worked in applications developed previously. I noticed that they were using Gradle version 6.xxx. Now this new app has Gradle version 7.xx.
I am getting following errors:
A problem occurred evaluating root project 'xxxxx'.
> Could not find method compile() for arguments [file collection] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* 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.
How can I fix this?