I’ve created a Gradle-based Liferay ext plugin project, and this project needs javax websocket API library. In the project’s build.gradle file I’ve included that dependency:
As a consequence of defining that dependency, the javax.websocket-api-1.1.jar has been downloaded and included within Project and External Dependencies section of the plugin project. But when I run the ‘build’ gradle task (–info option) it fails, getting the following errors:
The input changes require a full rebuild for incremental task ':ext:portal-impl-override:compileExtImplJava'.
file or directory '$(TOMCAT_HOME)\webapps\ROOT\WEB-INF\shielded-container-lib', not found
file or directory '$(PROJECT_HOME)\src\main\webapp\WEB-INF\ext-impl\src', not found
Compiling with JDK Java compiler API.
$(PLUGIN_PROJECT\src\extImpl\java\es\gmv\sed\dummy\DummyClass.java:3: error: package javax.websocket does not exist
import javax.websocket.EndpointConfig;
I don’t know what is the purpose of shielded-container-lib folder. Anyway, that folder doesn’t exist within my Tomcat instance. However, what I wonder is why gradle is not looking for the javax.websocket-api-1.1.jar file within the Project and External Dependencies section of the plugin project.
Since I don’t know too much about Gradle, any clarification or help will be really appreciated. Thanks.
Hard to say without more information about your build.
But to start with, you should probably update Gradle.
As it does not complain about compile, you are using an ancient Gradle version.
The compile configuration was deprecated for many many years and finally was removed in 7.0.
Besides that, the error talks about a file in src/extImpl/java.
This usually means that this is in a separate source set called extImpl, not in the main source set.
But compile adds it to the main source set.
So if this is correct, you probably wanted extImplCompile, not compile.
But the main source set could also be configured to look in that directory for sources, so this is where I meant it is hard to say what the problem is without more information about the build.
Thanks for your reply. Trying to provide you with more information…
Gradle version: 6.6.1
Since I’m developing an Liferay EXT plugin, the source code have to be placed in the EXT-plugin related src\extImpl\java folder.
Bear in mind (as described in my initial post) that the task that is failing is the compileExtImplJava task, not compile task.
I’ve just discovered that if I place the javax.websocket-api-1.1.jar file into the $(TOMCAT_HOME)/lib/ext folder, then the build task success. But I see it as a weird workaround because, according to my dependencies section of my build.gradle file, that library should only be used to compile the project, and, moreover, that library is already within the Project and External Dependencies section of the plugin project.
Yeah, as I said. compile is wrong in your case as that adds it to the main source set, not the extImpl source set.
It should be compileExtImpl instead.
The line with the compileOnly directive is intended to make the javax.websocket-api-1.1.jar file be downloaded and included in the Project and External Dependencies section of the plugin project; otherwise, the javax.websocket-api-1.1.jar file is not downloaded and the build process fails. And the line with the extImplCompile directive (if I understood well) is intended to make the build task to look for the javax.websocket-api-1.1.jar file within the the Project and External Dependencies section.
When I run the build task, I’m getting the following error:
> Task :ext:portal-impl-override:compileExtImplJava FAILED
file or directory '$(TOMCAT_HOME)\webapps\ROOT\WEB-INF\shielded-container-lib', not found
Caching disabled for task ':ext:portal-impl-override:compileExtImplJava' because:
Build cache is disabled
Task ':ext:portal-impl-override:compileExtImplJava' is not up-to-date because:
Task has failed previously.
The input changes require a full rebuild for incremental task ':ext:portal-impl-override:compileExtImplJava'.
file or directory '$(TOMCAT_HOME)\webapps\ROOT\WEB-INF\shielded-container-lib', not found
Full recompilation is required because no incremental change information is available. This is usually caused by clean builds or changing compiler arguments.
file or directory '$(PROJECT_HOME)\src\main\webapp\WEB-INF\ext-impl\src', not found
Compiling with JDK Java compiler API.
$(TOMCAT_HOME)\src\extImpl\java\es\gmv\sed\dummy\DummyClass.java:3: error: package javax.websocket does not exist
Neither shielded-container-lib (Tomcat scope) nor ext-impl (project scope) folders do exist.
I’d really appreciate if anyone could clarify to me what I’m doing wrong. Thanks.
The line with the compileOnly directive is intended to make the javax.websocket-api-1.1.jar file be downloaded and included in the Project and External Dependencies section of the plugin project; otherwise, the javax.websocket-api-1.1.jar file is not downloaded and the build process fails.
That should absolutely not be necessary. compileOnly again is for the main source set.
If you just need it in the extImpl source set, then the extImplCompile must be enough.
Why it does not compile with that dependency is hard to say, did you maybe do all that in the wrong build script?
It should be in ext/portal-impl-override/build.gradle (given a normal conventional directory layout.
Can you provide an MCVE that demonstrates your problem? Otherwise it is really hard to say where your error is from the information given.
Create an ext-plugin the way you do (not sure if you’re developing for Liferay platform). In my case, I’m using Liferay Developer Studio 3.9.7-ga8 on java-1.8.0-openjdk-1.8.0.232-1. The foo project structure look like this:
At this point, DummyClass.java is reporting errors as the extImplCompile directive doesn’t download the javax.websocket-api-1.1.jar library into the Project and External Dependencies section of the ext-plugin project. This why I thought it was needed including the CompileOnly directive.
Looking forward to read your impressions about the code shown. Thanks.
not sure if you’re developing for Liferay platform
I don’t even know what Liferay is, so the "C"omplete is not really met.
Can you please provide the MCVE for example as archive, or GitHub repo, or similar.
I’m affraid that if you aren’t developing on Liferay+Tomcat you won’t be able to check it, as the moment you create the ext-plugin (from the core-ext template) the Project and External dependencies section of the project gets filled of Liferay related libraries:
Actually, I wouldn’t care much about the Eclipse view. I wouldn’t touch Eclipse with a five-foot-pole if I can prevent it.
I would just have looked at where your error is in the Gradle setup as it does not compile.
And I would expect that as soon as it works properly in Gradle, it probably also works from Eclipse.
As I don’t have any knowledge on your project, not really.
Any sane Gradle project should have the 4 Gradle wrapper files as part of the sources, so in a typical Gradle build you go to the root project, and there invoke the gradlew script.
But what tasks you have I can just guess also.
You can do ./gradlew tasks to list the tasks though.
Typically it is ./gradlew build to build the typical artifacts of the build.
Or if you just want to check your compile task, ./gradlew :ext:portal-impl-override:compileExtImplJava should be fine as that is what is failing for you.
> Task :ext:foo:tasks
------------------------------------------------------------
Tasks runnable from project :ext:foo
------------------------------------------------------------
Build tasks
-----------
assemble - Assembles the outputs of this project.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
classes - Assembles main classes.
clean - Deletes the build directory.
deploy - Assembles the project and deploys it to Liferay.
extImplClasses - Assembles ext impl classes.
extKernelClasses - Assembles ext kernel classes.
extUtilBridgesClasses - Assembles ext util bridges classes.
extUtilJavaClasses - Assembles ext util java classes.
extUtilTaglibClasses - Assembles ext util taglib classes.
jar - Assembles a jar archive containing the main classes.
testClasses - Assembles test classes.
war - Generates a war archive with all the compiled classes, the web-app content and the libraries.
$>gradlew :ext:foo:extImplClasses
> Task :ext:foo:compileExtImplJava FAILED
file or directory '$(TOMCAT_HOME)\webapps\ROOT\WEB-INF\shielded-container-lib', not found
Caching disabled for task ':ext:foo:compileExtImplJava' because: Build cache is disabled
Task ':ext:foo:compileExtImplJava' is not up-to-date because: Task has failed previously.
The input changes require a full rebuild for incremental task ':ext:foo:compileExtImplJava'.
file or directory '$()\webapps\ROOT\WEB-INF\shielded-container-lib', not found
Full recompilation $(TOMCAT_HOME) required because no incremental change information is available. This is usually caused by clean builds or changing compiler arguments.
file or directory '$(WORKSPACE)\ext\foo\src\main\webapp\WEB-INF\ext-impl\src', not found
Compiling with JDK Java compiler API.
$(WORKSPACE)\ext\foo\src\extImpl\java\es\foo\DummyClass.java:3: error: package javax.websocket does not exist
import javax.websocket.EndpointConfig;
Wouldn’t it be ./gradlew :ext:foo:extImplCompile ?
No, extImplCompile is a configuration on which you declare dependencies that is then for example used for the tasks compileExtImplJava, compileExtImplGroovy , compileExtImplKotlin, and so on. And from your error message you can see that the task that failed is compileExtImplJava.
So, the same errors than in the IDE.
Yeah, expected so.
But as I said, without more information or an MCVE I can only give you hints.
I still suspect you added the dependency in the wrong build script, otherwise it should have been there now.
I added the dependency in the $(WORKSPACE)\ext\foo\build.gradle file. However, when I type $(WORKSPACE)>gradlew :ext:foo:dependencies, i get the following:
> Task :ext:foo:dependenciesace-1\lrws-dxp-7.1-ga1>gradlew :ext:foo:dependencies
> Evaluating settingsITIALIZING [73ms]
------------------------------------------------------------
Project :ext:foo
------------------------------------------------------------
annotationProcessor - Annotation processors and their dependencies for source set 'main'.
No dependencies
apiElements - API elements for main. (n)
No dependencies
archives - Configuration for archive artifacts. (n)
No dependencies
compileClasspath - Compile classpath for source set 'main'.
+--- com.liferay.portal:release.dxp.bom.third.party:7.1.10
+--- com.liferay.portal:release.dxp.bom:7.1.10
\--- com.liferay.portal:release.dxp.bom.compile.only:7.1.10
compileOnly - Compile only dependencies for source set 'main'. (n)
+--- com.liferay.portal:release.dxp.bom.third.party:7.1.10 (n)
+--- com.liferay.portal:release.dxp.bom:7.1.10 (n)
\--- com.liferay.portal:release.dxp.bom.compile.only:7.1.10 (n)
default - Configuration for default artifacts. (n)
+--- com.liferay.portal:release.dxp.bom.third.party:7.1.10 (n)
+--- com.liferay.portal:release.dxp.bom:7.1.10 (n)
\--- com.liferay.portal:release.dxp.bom.compile.only:7.1.10 (n)
extImplAnnotationProcessor - Annotation processors and their dependencies for source set 'ext impl'.
No dependencies
extImplCompileClasspath - Compile classpath for source set 'ext impl'.
\--- javax.websocket:javax.websocket-api:1.1
extImplCompileOnly - Compile only dependencies for source set 'ext impl'. (n)
No dependencies
extImplImplementation - Implementation only dependencies for source set 'ext impl'. (n)
No dependencies
extImplRuntimeClasspath - Runtime classpath of source set 'ext impl'.
\--- javax.websocket:javax.websocket-api:1.1
extImplRuntimeOnly - Runtime only dependencies for source set 'ext impl'. (n)
No dependencies
extKernelAnnotationProcessor - Annotation processors and their dependencies for source set 'ext kernel'.
No dependencies
extKernelCompileClasspath - Compile classpath for source set 'ext kernel'.
No dependencies
extKernelCompileOnly - Compile only dependencies for source set 'ext kernel'. (n)
No dependencies
extKernelImplementation - Implementation only dependencies for source set 'ext kernel'. (n)
No dependencies
extKernelRuntimeClasspath - Runtime classpath of source set 'ext kernel'.
No dependencies
extKernelRuntimeOnly - Runtime only dependencies for source set 'ext kernel'. (n)
No dependencies
extUtilBridgesAnnotationProcessor - Annotation processors and their dependencies for source set 'ext util bridges'.
No dependencies
extUtilBridgesCompileClasspath - Compile classpath for source set 'ext util bridges'.
No dependencies
extUtilBridgesCompileOnly - Compile only dependencies for source set 'ext util bridges'. (n)
No dependencies
extUtilBridgesImplementation - Implementation only dependencies for source set 'ext util bridges'. (n)
No dependencies
extUtilBridgesRuntimeClasspath - Runtime classpath of source set 'ext util bridges'.
No dependencies
extUtilBridgesRuntimeOnly - Runtime only dependencies for source set 'ext util bridges'. (n)
No dependencies
extUtilJavaAnnotationProcessor - Annotation processors and their dependencies for source set 'ext util java'.
No dependencies
extUtilJavaCompileClasspath - Compile classpath for source set 'ext util java'.
No dependencies
extUtilJavaCompileOnly - Compile only dependencies for source set 'ext util java'. (n)
No dependencies
extUtilJavaImplementation - Implementation only dependencies for source set 'ext util java'. (n)
No dependencies
extUtilJavaRuntimeClasspath - Runtime classpath of source set 'ext util java'.
No dependencies
extUtilJavaRuntimeOnly - Runtime only dependencies for source set 'ext util java'. (n)
No dependencies
extUtilTaglibAnnotationProcessor - Annotation processors and their dependencies for source set 'ext util taglib'.
No dependencies
extUtilTaglibCompileClasspath - Compile classpath for source set 'ext util taglib'.
No dependencies
extUtilTaglibCompileOnly - Compile only dependencies for source set 'ext util taglib'. (n)
No dependencies
extUtilTaglibImplementation - Implementation only dependencies for source set 'ext util taglib'. (n)
No dependencies
extUtilTaglibRuntimeClasspath - Runtime classpath of source set 'ext util taglib'.
No dependencies
extUtilTaglibRuntimeOnly - Runtime only dependencies for source set 'ext util taglib'. (n)
No dependencies
implementation - Implementation only dependencies for source set 'main'. (n)
+--- com.liferay.portal:release.dxp.bom.third.party:7.1.10 (n)
+--- com.liferay.portal:release.dxp.bom:7.1.10 (n)
\--- com.liferay.portal:release.dxp.bom.compile.only:7.1.10 (n)
portal - Configures the classpath from the local Liferay bundle.
+--- com.liferay:net.sf.jargs:1.0
+--- com.thoughtworks.qdox:qdox:1.12.1
+--- javax.activation:activation:1.1
+--- javax.servlet:javax.servlet-api:3.0.1
\--- javax.servlet.jsp:javax.servlet.jsp-api:2.3.1
providedCompile - Additional compile classpath for libraries that should not be part of the WAR archive.
No dependencies
providedRuntime - Additional runtime classpath for libraries that should not be part of the WAR archive.
No dependencies
runtimeClasspath - Runtime classpath of source set 'main'.
+--- com.liferay.portal:release.dxp.bom.third.party:7.1.10
+--- com.liferay.portal:release.dxp.bom:7.1.10
\--- com.liferay.portal:release.dxp.bom.compile.only:7.1.10
runtimeElements - Elements of runtime for main. (n)
No dependencies
runtimeOnly - Runtime only dependencies for source set 'main'. (n)
+--- com.liferay.portal:release.dxp.bom.third.party:7.1.10 (n)
+--- com.liferay.portal:release.dxp.bom:7.1.10 (n)
\--- com.liferay.portal:release.dxp.bom.compile.only:7.1.10 (n)
testAnnotationProcessor - Annotation processors and their dependencies for source set 'test'.
No dependencies
testCompileClasspath - Compile classpath for source set 'test'.
+--- com.liferay.portal:release.dxp.bom.third.party:7.1.10
+--- com.liferay.portal:release.dxp.bom:7.1.10
\--- com.liferay.portal:release.dxp.bom.compile.only:7.1.10
testCompileOnly - Compile only dependencies for source set 'test'. (n)
+--- com.liferay.portal:release.dxp.bom.third.party:7.1.10 (n)
+--- com.liferay.portal:release.dxp.bom:7.1.10 (n)
\--- com.liferay.portal:release.dxp.bom.compile.only:7.1.10 (n)
testImplementation - Implementation only dependencies for source set 'test'. (n)
+--- com.liferay.portal:release.dxp.bom.third.party:7.1.10 (n)
+--- com.liferay.portal:release.dxp.bom:7.1.10 (n)
\--- com.liferay.portal:release.dxp.bom.compile.only:7.1.10 (n)
testRuntimeClasspath - Runtime classpath of source set 'test'.
+--- com.liferay.portal:release.dxp.bom.third.party:7.1.10
+--- com.liferay.portal:release.dxp.bom:7.1.10
\--- com.liferay.portal:release.dxp.bom.compile.only:7.1.10
testRuntimeOnly - Runtime only dependencies for source set 'test'. (n)
+--- com.liferay.portal:release.dxp.bom.third.party:7.1.10 (n)
+--- com.liferay.portal:release.dxp.bom:7.1.10 (n)
\--- com.liferay.portal:release.dxp.bom.compile.only:7.1.10 (n)
(n) - Not resolved (configuration is not meant to be resolved)
A web-based, searchable dependency report is available by adding the --scan option.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.