saladinkzn / gretty

Advanced gradle plugin for running web-apps on jetty and tomcat.
MIT License
2 stars 2 forks source link

Overlays for repository based web apps in a farm #4

Open joankaradimov opened 8 years ago

joankaradimov commented 8 years ago

Hello, Thanks for the effort of supporting this.

I'm having a problem. I want to have an overlay for a webapp in a farm. But the webapp does not come from a subproject. It is a maven artifact. I initially tried something like:

farm {
    webapp 'some-group-id:some-artifact-id:1.2.3', overlay: ':some-project'
}

According to the documentation (here) you can pass web-app-specific properties as named arguments (like this). The list of properties (here) lists overlays as a property. However, this is a method and can not be used in the context of the code snippet above.

I am continuing to read the code of gretty and trying to find a work-around. But it would be great if you have some input on this.

saladinkzn commented 8 years ago

Hey

From fast lookup in gretty source I found out that overlays cannot be used in the way you want to because overlays are detected in afterProjectEvaluate by detecting overlays field on gretty extension (not webconfig-level property). So there's not workaround to make it work in current implementation for war file or maven dependency.

But it can be supported with some coding so I'll try to do my best and provide this feature in 1.2.6 release.

2016-03-31 14:24 GMT+03:00 Joan Karadimov notifications@github.com:

Hello, Thanks for the effort of supporting this.

I'm having a problem. I want to have an overlay for a webapp in a farm. But the webapp does not come from a subproject. It is a maven artifact. I initially tried something like:

farm { webapp 'some-group-id:some-artifact-id:1.2.3', overlay: ':some-project' }

According to the documentation (here http://akhikhl.github.io/gretty-doc/Farm-web-app-list.html#_repository_based_web_app_references) you can pass web-app-specific properties as named arguments (like this http://akhikhl.github.io/gretty-doc/Farms-and-web-app-specific-properties.html#_web_app_specific_properties_override). The list of properties (here http://akhikhl.github.io/gretty-doc/Gretty-configuration.html#_web_app_specific_properties) lists overlays as a property. However, this is a method and can not be used in the context of the code snippet above.

I am continuing to read the code of gretty and trying to find a work-around. But it would be great if you have some input on this.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/saladinkzn/gretty/issues/4

joankaradimov commented 8 years ago

If you have the time to give me some guidelines, I could try to implement that.

saladinkzn commented 8 years ago

I think the easiest way to achieve that is to write a task which explodes war dependency to some temp folder, apply overlays over it and then repackage war archive to some destination.

I would recommend you to create additional property in GrettyExtension named like overlayWars so you can configure it like

gretty { overlayWar 'some-group-id:some-artifact-id:1.2.3', overlays: [ project(':someProjects')] }

Then in org.akhikhl.gretty.GrettyPlugin#addTasks you should check for it and add a task for each detected war. This task should:

  1. Download your war from repository (or if it's a local file, skip this step)
  2. explode your war
  3. apply overlays over it
  4. repackage war to some destination

Then in org.akhikhl.gretty.GrettyPlugin#addTaskDependencies you should check if webApp in your farm is overlayed. If so you should add task dependency for farmStartTask to task you create.

You can use 'explodeWebApps' and 'overlayArchive' as a base line (note that they process war created by war task).

joankaradimov commented 8 years ago

Hey, I'm experiencing some difficulties with this. Should I leave it to you or are you too busy for it?

saladinkzn commented 8 years ago

I'm thinking about a right way to implement this properly so you can leave it to me :)

2016-04-12 16:37 GMT+03:00 Joan Karadimov notifications@github.com:

Hey, I'm experiencing some difficulties with this. Should I leave it to you or are you too busy for it?

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/saladinkzn/gretty/issues/4#issuecomment-208909010

joankaradimov commented 8 years ago

Ok, thanks!

boris-petrov commented 8 years ago

Hello, is there any progress on this?

saladinkzn commented 8 years ago

I've implemented this feature in 1.2.6-SNAPSHOT. Can you please test it in ur use cases?

joankaradimov commented 8 years ago

Thanks!

Sorry, about the delay. Some other higher priority stuff came out. I'll test it in the next day or two and write about this.