vic
vic

Reputation: 2818

compileOnly() Couldn't Be Found In A Multi-module Setting

In a multi-module Gradle project, all sub-projects are flat and they don't have any dependencies on others. In the base project directory, the settings.gradle file has the following content:

rootProject.name = 'base-project'
include 'server-1', 'server-2', 'server-3', 'business-app', 'gateway'

When I run "./gradlew build" on the base project directory, I get the following error:

A problem occurred evaluating project ':business-app'.
> Could not find method compileOnly() for arguments [org.projectlombok:lombok] on project ':business-app'.

For a dependency entry in the project's build.gradle file

dependencies {
  ...
  compileOnly('org.projectlombok:lombok')
  ...
}

The error doesn't occur if I run the same build command in the project directory.

I can't find any helpful information online. How to solve this problem?

Upvotes: 0

Views: 2894

Answers (1)

Rene Groeschke
Rene Groeschke

Reputation: 28653

The compileOnly configuration is added to the build context by applying the java plugin. likely you don't have

apply plugin:'java'

for your subproject defined. Adding it should solve that issue.

Upvotes: 2

Related Questions