Message Boards

Gradle build fails when using com.liferay.ext.plugin

thumbnail
Asier Del Pozo, modified 4 Years ago.

Gradle build fails when using com.liferay.ext.plugin

Junior Member Posts: 78 Join Date: 11/12/07 Recent Posts
I created an ext plugin using Liferay Developer Studio 3.6.2 (not using blade or liferay-workspace). It created everything apparently fine, including the build.gradle file.
I add to the project  UserLocalServiceImpl from Liferay's 7.2 portal code, in the extImpl section. Nothing new.
If I add the dependencies for UserLocalServiceImpl , this is what build.gradle looks like:
buildscript {
    dependencies {
        classpath group: "com.liferay", name: "com.liferay.gradle.plugins", version: "4.0.23"
    }
    repositories {
        maven {
            url "https://repository-cdn.liferay.com/nexus/content/groups/public"
        }
    }
}
apply plugin: "com.liferay.ext.plugin"
apply plugin: "eclipse"
eclipse {
    classpath {
        plusConfigurations += [configurations.portal]
    }
}
repositories {
    maven {
        url "https://repository-cdn.liferay.com/nexus/content/groups/public"
    }
}
dependencies {
    compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'
    compileOnly group: 'javax.mail', name: 'mail', version: '1.4'
}

When running "gradlew deploy", the build will fail due to not finding the classes in javax.mail. Same dependencies added to a regular OSGI module, it works. 
What's wrong?
thumbnail
Olaf Kock, modified 4 Years ago.

RE: Gradle build fails when using com.liferay.ext.plugin

Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent Posts
Asier Del Pozo:

When running "gradlew deploy", the build will fail due to not finding the classes in javax.mail. Same dependencies added to a regular OSGI module, it works. 
What's wrong?
Pardon my ignorance: I believe that the approach to use an ext is wrong. (this is a safe assumption in more than 95% of ext plugins I've seen, thus it's my suggestion number 1)
Apparently you want to introduce some mail processing into UserLocalService.
Mail processing shouldn't be done synchronously anyway, in order to not slow down day-to-day operations. And UserLocalService additions shouldn't be done in an ext, but rather in a ServiceWrapper.
Unless I see a hint that points into the other direction, my suggestion is to implement a ServiceWrapper that drops a message on the MessageBus. Then implement the receiving end that asynchronously handles the required mail.
thumbnail
Asier Del Pozo, modified 4 Years ago.

RE: Gradle build fails when using com.liferay.ext.plugin

Junior Member Posts: 78 Join Date: 11/12/07 Recent Posts
Olaf,
I totally agree that ext is something to be avoided. The deal is that we need to allow duplicated email addresses. Using a Wrapper for this makes it necessary to actually replicate almost everything from the original service in the wrapper, because there is no validation implementation that we can override safely due to a design decision. So more than a wrapper, we would have a wrapper that is actually a copy of the wrapped class.

In any case, the issue is that the ext doesn't even compile. It looks like the issue is that the dependencies that I am adding to build.gradle are ignored. I am not using the liferay-workspace, but just adding a Liferay Module Project from a war-core-ext template using the Liferay Developer Studio, and gradle build doesn't work. Any ideas why?

Best,
Asier
thumbnail
David H Nebinger, modified 4 Years ago.

RE: Gradle build fails when using com.liferay.ext.plugin

Liferay Legend Posts: 14916 Join Date: 9/2/06 Recent Posts
"The deal is that we need to allow duplicated email addresses."

That's fine, but there's no reason to abuse or change Liferay for this...

I've done similar things by storing the real email address(es) separately from Liferay's table and then use fake but unique values in Liferay's store.  You can then use a user local service wrapper to resolve the storage and lookup issues and index post processors to update the indexing.

Would I really implement this requirement over using an EXT plugin? Absolutely. EXTs really should be avoided that strongly.
thumbnail
Asier Del Pozo, modified 4 Years ago.

RE: Gradle build fails when using com.liferay.ext.plugin

Junior Member Posts: 78 Join Date: 11/12/07 Recent Posts
To be clear... I am not modifying anything (yet). Just copied the UserLocalServiceImpl to the newly created ext plugin (using the LDS), added the dependencies to the build.gradle, tried to build, would not work.
thumbnail
Gregory Amerson, modified 4 Years ago.

RE: Gradle build fails when using com.liferay.ext.plugin

Liferay Legend Posts: 1123 Join Date: 2/16/10 Recent Posts
I like Dave's idea of UserLocalServiceWrapper.  Much more upgrade friendly approach.  If you ever plan to upgrade liferay, do yourself a favor and use UserLocalServiceWrapper instead of ext-plugin.
thumbnail
Asier Del Pozo, modified 4 Years ago.

RE: Gradle build fails when using com.liferay.ext.plugin

Junior Member Posts: 78 Join Date: 11/12/07 Recent Posts
Thanks for your inputs! We all agree that using the ext is something to avoid. But it still is a tool that is available in 7.2, and the point of this post is that the ext building doesn't work.
This is how I can reproduce it with Liferay Developer Studio 3.6.2:1) Create a  Liferay Module Project
2) Use a war-core-ext template
3) Add UserLocalServiceImpl from the Liferay code4) Add dependencies to the build file.5) Build it.
The dependencies in the build file are ignored.
thumbnail
Gregory Amerson, modified 4 Years ago.

RE: Gradle build fails when using com.liferay.ext.plugin

Liferay Legend Posts: 1123 Join Date: 2/16/10 Recent Posts
How are you adding the dependencies to the build file?  can you post an example of what you are trying that doesn't work? 
thumbnail
Asier Del Pozo, modified 4 Years ago.

RE: Gradle build fails when using com.liferay.ext.plugin

Junior Member Posts: 78 Join Date: 11/12/07 Recent Posts
It is in the first entry of this thread, that's the actual build.gradle file. 
Lan Zhang, modified 3 Years ago.

RE: Gradle build fails when using com.liferay.ext.plugin

New Member Posts: 21 Join Date: 5/16/11 Recent Posts
Hi Asier,I am having the same problem. Did you solve your issue? If so, can you post your solution?Thank you!!