Syncing of externally generated resources

Answered

Hi,

I have a project containing two modules, java web server based on embeded Jetty (call it Web) and kotlin client compiled to JS (call it Kotlin). Kotlin module is built to dir Kotlin/web/js/ with gradle. I have added this dir as resource for module Web with gradle idea task, it seems to be working well, I can see it in module structure, directory web is marked as "[main] resource root" in project tree. Problem is that Idea sometimes forgets to copy fresh js code to resource dir when I restart Web module. Any idea how to solve it? Thanx :)

0
3 comments

>Problem is that Idea sometimes forgets to copy fresh js code to resource dir when I restart Web module.

What do you mean by "forgets"? Do you mean it works sometimes but sometimes not? When it does not "forget" to this?

If by "restart Web module" you mean restart of Run/Debug Application - on run configuration restart IDE performs the actions tat are specified in Before launch section of run configuration.

>I have added this dir as resource for module Web with gradle idea task

I would rather use Gradle's native means of configuring project structure and build logic and for example created a Gradle task that would copy the resources to Web Server Gradle module after each time you build the client module. For example by adding doLast action for the task that builds the Kotlin JSK module, see Build Lifecycle for more information.

 
0
Avatar
Permanently deleted user

Yes, sometimes it works, sometimes not. It seems it differs between machines, some collegues report it more often. It seems to be random, one day it works well, other they have to remove build dir to make it work and use fresh data. 

I have Build in Before Launch section, I suppose it should copy fresh data to build dir, or not?

We used the similar approach you are suggesting in past, but we experienced similar problems. 

0

>I have Build in Before Launch section, I suppose it should copy fresh data to build dir, or not?

It depends. In a gradle-based java project if you have Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Gradle | Build and run using: set to Gradle, on Build action IDE invokes Gradle's 'classes' task. So if you configure you Gradle build logic and add some custom tasks which are build to this Gradle tasks - they will be invoked as well.

0

Please sign in to leave a comment.