1

I’m extending a Liferay 7 portal by adding a new “basic” app under the standard modules/apps directory:

liferay-portal/
└── modules/
    └── apps/
        └── basic/
            ├── basic-api/
            │   └── build.gradle
            └── basic-rest-impl/
                └── build.gradle

I want basic-rest-impl to depend on basic-api. Both modules compile fine if I run them individually, but when I run my usual ant all the Gradle deploy step for basic-rest-impl always fails.

[beanshell] Executing Gradle task: deploy
...
FAILURE: Build failed with an exception.

* Where:
Build file '/home/me/dev/projects/liferay-portal/modules/apps/basic/basic-rest-impl/build.gradle' line: 12

* What went wrong:
A problem occurred evaluating project ':apps:basic:basic-rest-impl'.
> Project with path ':apps:basic:basic-api' could not be found in project ':apps:basic:basic-rest-impl'.

What I’ve tried

  1. Declaring the dependency
    In basic-rest-impl/build.gradle I have:

    dependencies {     
      compile project(':apps:basic:basic-api')
      compileOnly group: 'com.liferay', name: 'portal-kernel', version: '7.4.0'     
      // … 
    } 
    
  2. Including sub-modules
    I created modules/apps/basic/settings.gradle with:

    include ':apps:basic:basic-api' 
    include ':apps:basic:basic-rest-impl'
    
  3. Applying Liferay defaults
    In the root build.gradle (liferay-portal folder) I have:

    apply plugin: "com.liferay.app.defaults.plugin" 
    
  4. Cache cleaning
    Ran ant all-clean and gradle --stop && gradle clean build --refresh-dependencies.

Despite all that, Gradle still cannot see the basic-api project when invoked through Ant’s deploy task.


My question

What Gradle (or Liferay) configuration am I missing so that

compile project(':apps:basic:basic-api') 

is resolved correctly when I run ant all? In other words, how do I tell the Gradle build that my new modules/apps/basic folder is part of the multi-project build so that basic-rest-impl can find basic-api?

1 Answer 1

0

I see several issues in your setup:

  • In order to build a new module for Liferay, you should use a Liferay Workspace. What you document looks like you're building the whole project from scratch - which is inefficient and unnecessary.

  • The version of portal-kernel does not follow the whole product versioning, but it's a semantic version that gets bumped up every time an API changes. As of today, portal-kernel is at version 162.0.0, while you list 7.4 - which is the (rather marketing oriented) release number for the whole project (assuming you're referring to the Open Source Liferay Portal) and not the (technical) kernel's version.

With Liferay Workspace, you'd configure it to compile against a certain version of Liferay Portal (e.g. by setting liferay.workspace.product=portal-7.4-ga132 in gradle.properties), then you won't have to figure out portal-kernel's version - this magic is done for you by gradle.

With Liferay Workspace, resolving the dependency should work the way you described it in your question - though the apps folder is typically not used within individual custom extensions. Also, you wouldn't need ant all, just gradlew deploy should suffice. Optionally, you could also use blade as Liferay Workspace's wrapper for gradle.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.