yasuflatland-lf / damascus

⚔️ CRUD boilerplate generator for Liferay DXP
https://yasuflatland-lf.github.io/damascus-doc/
GNU Lesser General Public License v3.0
50 stars 35 forks source link

V1.1.6 - Could not resolve: com.liferay:com.liferay.petra.sql.dsl.api:4.0.0 #107

Closed icarrara closed 3 years ago

icarrara commented 4 years ago

Tried with Liferay Developer Studio both stable release: 3.8.1 and milestone release: 3.9.0 M1. Created Todo example with 'damascus init -c Todo -p com.liferay.sb.test -v 7.3' Imported modules in Liferay workspace Below the errors from IDE console: ` CONFIGURE SUCCESSFUL in 3s Could not resolve: com.liferay:com.liferay.petra.sql.dsl.api:4.0.0

Task :nothing UP-TO-DATE Could not resolve: com.liferay:com.liferay.petra.sql.dsl.api:4.0.0

BUILD SUCCESSFUL in 1m 8s

CONFIGURE SUCCESSFUL in 1s Could not resolve: com.liferay:com.liferay.petra.sql.dsl.api:4.0.0

Task :nothing UP-TO-DATE Could not resolve: com.liferay:com.liferay.petra.sql.dsl.api:4.0.0

BUILD SUCCESSFUL in 3s

CONFIGURE SUCCESSFUL in 1s `

Below the base.json content:

{ "projectName": "Todo", "packageName" : "com.liferay.sb.test", "liferayVersion": "7.3", "useTargetPlatform": "false", "applications": [ { "model" : "Todo", "title" : "Todo Test", "web" : "true", "asset": { "assetTitleFieldName": "todoTitleName", "assetSummaryFieldName": "todoSummaryName", "categories": "true", "discussion": "true", "ratings": "true", "tags": "true", "relatedAssets": "true", "fullContentFieldName": "todofullContent", "workflow": "true", "generateActivity": "true", "trash":"true", "advancedSearch": "true", "exportExcel": "true" }, "fields": [ { "type": "com.liferay.damascus.cli.json.fields.Long", "primary":true, "name": "todoId", "title": "Todo Id", "showFieldInView": "false", "required": "true" }, { "type": "com.liferay.damascus.cli.json.fields.Varchar", "name": "title", "title": "Title", "length": "80", "showFieldInView": "true", "required": "true" }, { "type": "com.liferay.damascus.cli.json.fields.Boolean", "name": "todoBooleanStat", "title": "Todo Boolean Stat" }, { "type": "com.liferay.damascus.cli.json.fields.DateTime", "name": "todoDateTime", "title": "Todo DateTime" }, { "type": "com.liferay.damascus.cli.json.fields.DocumentLibrary", "name": "todoDocumentLibrary", "title": "Todo DocumentLibrary" }, { "type": "com.liferay.damascus.cli.json.fields.Double", "name": "todoDouble", "title": "Todo Double" }, { "type": "com.liferay.damascus.cli.json.fields.Integer", "name": "todoInteger", "title": "Todo Integer" }, { "type": "com.liferay.damascus.cli.json.fields.RichText", "name": "todoRichText", "title": "Todo RichText" }, { "type": "com.liferay.damascus.cli.json.fields.Text", "name": "todoText", "title": "Todo Text" } ], "customValue" : { "your_own_id" : "your_custom_value_for_template_here" }, "replacements" : { "original_string_to_be_replaced" : "replacement_string" } } ] }

yasuflatland-lf commented 4 years ago

@icarrara Thank you for the report. I'll investigate this.

icarrara commented 4 years ago

More information:

In ".damascus\templates\7.3" i changed the below files:

From compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"<#if useTP?? && false == useTP>, version: "**7.2.0**"</#if> To compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"<#if useTP?? && false == useTP>, version: "**7.3.0**"</#if>

Generate the new Todo project the execute "blade deploy" - still the error:

`> Task :modules:todo:todo-api:compileJava Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details.

Task :modules:todo:todo-api:deploy Files of project ':modules:todo:todo-api' deployed to C:\dev\liferay\7.3.3-ce-ga4\e-ws\lr-ws\bundles\osgi\modules

Task :modules:todo:todo-service:compileJava FAILED

FAILURE: Build failed with an exception.

BUILD FAILED in 20s 5 actionable tasks: 5 executed`

icarrara commented 4 years ago

Good news: I read this:


https://liferay.dev/blogs/-/blogs/liferay-portal-7-3-ce-ga4-release-1

Dependency Management

If you are developing on top of Liferay Platform, and want to update your workspace to use de dependencies from this last version, you will just need to use a single dependency artifact. Just add the following line to your build.gradle file:

dependencies { compileOnly group: "com.liferay.portal", name: "release.portal.api", version: "7.3.3-ga4" }

All portal dependencies are now defined with a single declaration. When using an IDE such as Eclipse or IntelliJ all apis are immediately available in autocomplete for immediate use.

I changed the build.gradle of the todo-api module and the red error is gone.

Now I'll try with the todo-service module and I'll update here.

icarrara commented 4 years ago

It worked !

I changed the build.gradle of the todo-api and todo-service moduls.

I removed all Liferay's related dependencies and put the below only statement: compileOnly group: "com.liferay.portal", name: "release.portal.api", version: "7.3.3-ga4"

At the moment I don't changed the todo-web module.

I done a "blade deploy" command and the three modules was compiled successfully:

`C:\dev\liferay\7.3.3-ce-ga4\e-ws\lr-ws\modules\todo>blade deploy

Task :modules:todo:todo-api:compileJava Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details.

Task :modules:todo:todo-api:deploy Files of project ':modules:todo:todo-api' deployed to C:\dev\liferay\7.3.3-ce-ga4\e-ws\lr-ws\bundles\osgi\modules

Task :modules:todo:todo-service:compileJava Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.

Task :modules:todo:todo-service:deploy Files of project ':modules:todo:todo-service' deployed to C:\dev\liferay\7.3.3-ce-ga4\e-ws\lr-ws\bundles\osgi\modules

Task :modules:todo:todo-web:compileJava Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details.

Task :modules:todo:todo-web:buildCSS Using native Sass compiler There are no files to compile

Task :modules:todo:todo-web:deploy Files of project ':modules:todo:todo-web' deployed to C:\dev\liferay\7.3.3-ce-ga4\e-ws\lr-ws\bundles\osgi\modules

BUILD SUCCESSFUL in 1m 31s 16 actionable tasks: 16 executed Gradle "deploy" task succeeded. Updates available to the installed version: 4.0.0.202007030610 -> (Snapshot) 4.0.2.202007311552 Run blade update to install -> (Release) 4.0.1 Run blade update -r to install`

icarrara commented 4 years ago

It confirmed.

I changed the build.gradle of the todo-api and todo-service and todo-web modules.

I removed all Liferay's related dependencies and put the below only statement:

compileOnly group: "com.liferay.portal", name: "release.portal.api", version: "7.3.3-ga4"

I done a "blade deploy" command and the three modules was successfully compiled.

After deploy: I used the Admin portlet and it worked in all CRUD modes. I placed the User portlet in a Widget page and it worked in all CRUD modes.

icarrara commented 4 years ago

I confirm that foollowing the https://liferay.dev/blogs/-/blogs/liferay-portal-7-3-ce-ga4-release-1 under "Dependency Management" section solve the issue.

Solution:

In ".damascus\templates\7.3" i changed the below files: Portlet_XXXXROOT_build.gradle.ftl Portlet_XXXXSVC_build.gradle.ftl Portlet_XXXXWEB_build.gradle.ftl

I removed all Liferay's related dependencies and put the below statement only:

compileOnly group: "com.liferay.portal", name: "release.portal.api"<#if useTP?? && false == useTP>, version: "7.3.3-ga4"</#if>

I attached the three .ftl changed files here: damascus-liferay-7.3-build.gradle.ftl.zip

I generated Todo portlets using damascus init -c Todo -p com.liferay.sb.test -v 7.3 command. I imported the three modules in Liferay Developer Studio v.Version: 3.9.0.202007030640-m1 and there are no red errors. I done a "blade deploy" command and the three modules was successfully compiled. I started Tomcat bundle running Liferay CE v.7.3.3-ga4

After server started: I used the Admin portlet and it worked in all CRUD modes. I placed the User portlet in a Widget Page and it worked in all CRUD modes. I placed the User portlet in a Content Page and it worked in all CRUD modes.

himanshubhandari5 commented 4 years ago

Hi @yasuflatland-lf

As for each 7.3 GA release, different release.portal.api version is there, I have implemented a solution with another command line argument as "-ga" to get the GA version, and based upon that updated the release API version in templates.

Please let me know if this is the correct approach.

Thanks!

yasuflatland-lf commented 4 years ago

@hdbhandari @icarrara

Thank you guys for confirmations and comments. Let me share the context of the current design and my thought below:

Versions for dependencies

Liferay Workspace introduced the BOM for applying the appropriate version for the dependencies a while ago as below.

liferay.workspace.home.dir=/Users/test/bundles/73ce/
liferay.workspace.target.platform.version=7.3.2
target.platform.index.sources=true

This way allows you to just switch BOM to follow the newer bundle, without manually looking up dependencies one by one. Also, this usage would be the default of the Liferay Workspace.

Context

I also wanted to follow the default for generated templates, but the generator needs to run Gradle build during the generating template. The current Liferay Template Library(com.liferay.project.templates:5.0.32) is the last version including versions in generatedbuild.gradle files. I Also considered older versions that are not BOM compatible. The implementation to identify versions looked like time-consuming, and moving forward, BOM may be backported for the old versions. But I also wanted to release the 7.3 templates ASAP. With that said, I ended up choosing hardcoded for the specific version.

However, I now understood that it led to some confusion for users. Meanwhile, I want to keep the implementation as simple as possible so that I can easily support both newer and old templates.

Given these contexts, possible solutions should be as follows:

  1. Make Hardcording version default. As @hdbhandari mentioned, add the parameter to the command line or configuration file under . ./damascus
  2. Make the BOMversion only available for users. When you run the Damascus, if no configuration for identifying BOM (the properties above) are found, throw an error to add them.

I'm more than welcome to other ideas too! Let me ask @dnebinger too!

dnebing commented 4 years ago

BOM support is available from 7.0.6 onward.

I wouldn't try to support older versions that lack BOM support.

yasuflatland-lf commented 4 years ago

@dnebing Thank you for the quick answer! That gives us really good insights.

@hdbhandari @icarrara, with that, said, I'd like to chose 2, only compatible for BOM version. I need to update com.liferay.project.templates library higher than 5.0.32 anytime soon for newer Liferay versions anyways.

icarrara commented 4 years ago

With the Liferay Portal 7.3 CE GA5 Release it seems that things have still changed.

Below an extract from the blog article https://liferay.dev/blogs/-/blogs/liferay-portal-7-3-ce-ga5-release

If you are developing on top of Liferay Platform, you will only need to define a single dependency artifact by adding the following line to each modules build.gradle file: dependencies { compileOnly group: "com.liferay.portal", name: "release.portal.api" }

It is now possible to use the single dependency with target platform meaning during an upgrade it will be possible to update all dependancies to the new version by updating the target platform properties in the projects gradle.property file: liferay.workspace.target.platform.version=7.3.4

icarrara commented 4 years ago

Based on the blog article https://liferay.dev/blogs/-/blogs/liferay-portal-7-3-ce-ga5-release

1) In Liferay Developer Studio IDE, in the Liferay Workspace Project, in 'gradle.properties' added the below properties: liferay.workspace.product = portal-7.3-ga5 liferay.workspace.target.platform.version=7.3.4

2) In Damascus templates:

changed the only Liferay's based dependency to: compileOnly group: "com.liferay.portal", name: "release.portal.api"<#if useTP?? && false == useTP></#if>

3) From 'modules' folder run the command: damascus init -c Todo -p com.liferay.sb.test -v 7.3

4) From 'todo' folder: damascus create

5) From Liferay Developer Studio IDE done the Refresh and Refresh Gradle Project commands - the modules was imported without errors.

6) From 'todo' folder: blade deploy

7) After deployed, both admin and user Todo portles works as usual.

yasuflatland-lf commented 3 years ago

Use BOM with Target Platform from 1.2.0 onward