rjaros / kvision

Object oriented web framework for Kotlin/JS
https://kvision.io
MIT License
1.2k stars 66 forks source link

trying to generate .pot files #510

Closed CodeServant closed 4 months ago

CodeServant commented 5 months ago

I am trying to generate pot file via ./gradlew :subproject:generatePotFile Everything I did as in here, but it does not seem to work becouse files not appear. gradlew command result is below

BUILD SUCCESSFUL in 1s
2 actionable tasks: 2 up-to-date

The showcase is working normally. Added .getttext.json but not working either. I have no idea what is wrong, please help.

kvision 7.3.1 windows 10 kotlin 1.9.22 gradle 8.5

rjaros commented 5 months ago

There are paths in .gettext.json file (pattern, output). You are building a subproject. Have you adjusted those paths to match your subproject?

CodeServant commented 5 months ago

"output": "src/jsMain/resources/i18n/messages.pot" the file is in my subproject downgraded kotlin to 1.9.20 and works fine but for a while done clean generatePotFile and no file still with kotlin 1.9.20

CodeServant commented 5 months ago

Ok that seems i can generate this .pot file only after i run command gradle subproject:run -t which generate error at first run. Works with kotlin 1.9.22.

rjaros commented 5 months ago

Can you share your project?

CodeServant commented 5 months ago

No sorry. I am planning to do it, but i should consult with receipant and my university. Hope to pass the engineer exam with this. But as i told earlier. First had to run and then generate pot file.

Running .\gradlew.bat clean generatePotFile gives me

Starting a Gradle Daemon, 2 busy and 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
> Task :webCli:generatePotFile FAILED

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':webCli:generatePotFile' (type 'KVGeneratePotTask').
  - In plugin 'io.kvision.gradle.KVisionPlugin$Inject' type 'io.kvision.gradle.tasks.KVGeneratePotTask' property 'getTextExtractBin' specifies file 'C:\Users\macie\IdeaProj
ects\printing-house\build\js\node_modules\gettext-extract\bin\gettext-extract' which doesn't exist.

    Reason: An input file was expected to be present but it doesn't exist.

    Possible solutions:
      1. Make sure the file exists before the task is called.
      2. Make sure that the task which produces the file is declared as an input.

    For more information, please refer to https://docs.gradle.org/8.5/userguide/validation_problems.html#input_file_does_not_exist in the Gradle documentation.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 32s
10 actionable tasks: 7 executed, 3 up-to-date

But when I do .\gradlew.bat generatePotFile after ./gradlew :subproject:run -t works fine.

rjaros commented 5 months ago

I would assume something like this is happening. The generatePotFile task depends on some NPM tools to be installed in the project. These tools are installed by the kotlinNpmInstall gradle task, so it isconfigured as a dependency for generatePotFile. It works with standard, simple project layout - you run generatePotFile, gradle calls kotlinNpmInstall first, the tools get installed and pot generation can do its job. But I see you have kvision project in a subproject. When generatePotFile taks is called, it executes kotlinNpmInstall from the root project. But in the root project you have no kvision dependencies, so the tools are not installed and pot generation fails. To fix the issue you probably should call .\gradlew.bat :subproject:generatePotFile or add task dependencies manually.

a-cosmic-jaw commented 4 months ago

After a while of debugging I have concluded that the KVisionPlugin.apply() function is never run when you conf KVision as a subproject and hence configureNodeEcosystem never gets executed. Anyone know why this is?

edit: And ofc configureProject wont be ran, either!

rjaros commented 4 months ago

Can you share your project?

a-cosmic-jaw commented 4 months ago

Sure can!

I also find the paths of ./css/kvapp.css, ./i18n/messages-en.json, ./i18n/messages-pl.json in App.kt and ./webpack/bin/webpack.js on line 453 in KVisionPlugin.kt (tag:7.3.1) need the ./ before the paths.

rjaros commented 4 months ago

The problem with KVision subproject is caused by the strange behaviour of Kotlin/JS gradle plugin. Despite this plugin being applied in a subproject, it creates some tasks (e.g. kotlinNpmInstall) in the root project. This breaks KVision tasks dependencies. I've fixed this and it should work correctly in the next release.

The problem with paths to resources is different. We can use paths without ./, because all KVision apps define this line in the webpack.config.d/webpack.js:

config.resolve.modules.push("../../processedResources/js/main");

Unfortunately this is a relative path resolved from the root project. You need to change this line to this:

config.resolve.modules.push("../../../addressbook-fullstack-micronaut/build/processedResources/js/main");

and paths without ./ wil work fine.

a-cosmic-jaw commented 4 months ago

Thanks for the feedback! Looking forward to the next release!

rjaros commented 4 months ago

Fixed in 7.4.1