Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
Trunk
-
None
-
None
-
None
Description
Gradle provides some useful standard plugins for packaging applications via the ‘distribution’ and ‘application’ plugins.
- The ‘distribution’ plugin [1] is providing a straightforward and easy way to distribute OFBiz with its dependencies which is convenient in a deployment context. This is achieved by the new ‘distTar’ and ‘distZip’ tasks.
- The ‘application’ plugin [2] is complementing the ‘distribution’ plugin by adding both a robust shell script and a batch script inside the distribution archives to allow launching OFBiz easily.
[1] https://docs.gradle.org/current/userguide/distribution_plugin.html
[2] https://docs.gradle.org/current/userguide/application_plugin.html
Attachments
Attachments
- OFBIZ-10866_Use-the-application-and-distribution-plugin.patch
- 3 kB
- Mathieu Lirzin
Activity
Hello Jacques,
you are correct, I have rebased my patch on top of trunk
Thanks Mathieu, great stuff!
I suggest we don't create both archives (zip=271MB, tar=391MB) each time we run OFBiz, please find attached your modified patch, thanks.
It adds
tasks.distZip.enabled = false tasks.distTar.enabled = false
To create one or both simply comment out one or both added lines and run OFBiz (g ofbiz). Yes, AFAIK you still need to run OFBiz to create one or both archives. More at https://discuss.gradle.org/t/distribution-plugin-generate-only-a-tar-or-avoid-generate-zip/18124/10
I agree we should not build those archives when running ofbiz, I have simply overlooked that this was happening for traditional ./gradlew ofbiz ... rule based commands since the new run target is not affected by that issue.
Regarding how to disable the undesired behaviour, a simple solution is to adapt the createOfbizCommandTask method to make the generated task depends on the jar target instead of the build target.
OFBIZ-10866_Use-the-application-and-distribution-plugin.patch seems not related to this ticket
Thanks Jacques for detecting that issue, I am upgrading my patch with the solution I have proposed above.
Thanks Mathieu,
Each time we build from a clean state it takes 20 sec to create both archives on my machine. Since we mostly build from a previous build state, I think it's OK. It also puts 1/2 GB+ of data on the disk which are most of the time not needed. It's not an issue with me, but maybe we could create the archives only when we want, ie using distZip or/and distTar?
Yes wrong C/P with my patch, removed Anyway was only the 2 lines I added just below distributions.main.contents.from(rootDir).
> but maybe we could create the archives only when we want, ie using distZip or/and distTar?
That's the intent and this is why I modified the default task to not be :build which explicity builds everything. If things are working properly rm -rf build; ./gradlew cleanAll loadAll ofbiz does not build the archives.
Hi Mathieu,
Yes but currently gradlew clean build generates both archives in ~20 sec. As I said not a big deal with me, just saying.
Hi Mathieu,
Quick question, does this affect the way the rule-tasks operate (ofbiz, ofbizDebug, etc ...) or does it operate as intended?
Hello Taher,
The behaviour of rule-tasks has been relaxed to depend on the :jar task instead of the :build task to not trigger the compilation of the distribution archives. The side effect of this change is that unit tests are not triggered by those rule-tasks anymore which is matching the behavior of the :run task.
Hello,
I have found a way to make the :build task not depend on the :distTar and :distZip tasks without having to disable those tasks which require packagers to comment a line in the build.gradle file:
assemble.setDependsOn([jar])
I have updated OFBIZ-10866_Use-the-application-and-distribution-plugin.patch accordingly.
I suggest providing documentation patch (README.md) that shows exactly how this impacts everything and to make it easier for us to test.
I have updated OFBIZ-10866_Use-the-application-and-distribution-plugin.patch to add a section in the README.adoc file about the packaging and distribution of OFBiz. Additionnally I have adapted to the server tasks documentation to use the :run task instead of the rule based tasks when possible.
Hi Mathieu,
Sincerely syntactically I prefer the "ofbiz" way above the "run" way. It's much more intuitive. What the "run" way adds apart
make the :build task not depend on the :distTar and :distZip tasks without having to disable those tasks
?
Hello Jacques,
One important feature of the run task is that it is a standard task shared by most applications using Gradle. This means that once you learn it, you can reuse it across multiple projects and reduce the specific knowledge required to work on OFBiz.
So to me the question is more why use something specific when a generic syntax is available?
Mathieu,
Since it's about syntax and sugar, I got a quite interesting proposition from the quiet pfm.smits (thanks Pierre): why not renaming the 2 gradlew and gradlew.bat scripts to ofbiz and ofbiz.bat. It does not solve the "complication" introduced by the run task but it makes the most used commands clearer:
ofbiz build ofbiz run
etc.
Of course the other way around would be better:
ofbiz build ofbiz run
But it would still misses an "s" at the ends of builds and runs. Sorry I could not resist to this private joke .
Now Iet those who did not read the patch make their own opinion by comparing the pre and post commands (w/o the gradle to ofbiz scripts names change, anyway it does not change the other part of the run syntax)
-MS Windows: `gradlew ofbiz` +MS Windows: `gradlew run` -Unix-like OS: `./gradlew ofbiz` +Unix-like OS: `./gradlew run` -`gradlew "ofbiz --help"` +`gradlew run --args="--help"` -`gradlew "ofbizDebug --test"` +`gradlew run --debug-jvm --args="--test"` -`gradlew "ofbiz --shutdown --portoffset 10000"` +`gradlew run --args="--shutdown --portoffset 10000"` -`gradlew ofbiz` (default is --start) +`gradlew run` -`gradlew cleanAll loadAll "ofbiz --start --portoffset 10000"` +`gradlew cleanAll loadAll run --args="--start --portoffset 10000"` -`gradlew "ofbiz --help"` +`gradlew run --args="--help"` -`gradlew "ofbiz --start"` +`gradlew run` -`gradlew "ofbiz --shutdown"` +`gradlew run --args="--shutdown"` -`gradlew "ofbiz --status"` +`gradlew run --args="--status"` -`gradlew "ofbizDebug --start"` +`gradlew run --debug-jvm` -`gradlew "ofbiz --start --portoffset 10000"` +`gradlew run --args="--start --portoffset 10000"` -`gradlew ofbiz -PjvmArgs="-Xms1024M -Xmx2048M" -Dsome.parameter=hello` +`gradlew run -PjvmArgs="-Xms1024M -Xmx2048M" -Dsome.parameter=hello` -`gradlew "ofbiz --load-data readers=<readers-here-comma-separated>"` +`gradlew run --args="--load-data readers=<readers-here-comma-separated>"` -`gradlew "ofbiz --load-data readers=seed,seed-initial,ext,ext-demo"` +`gradlew run --args="--load-data readers=seed,seed-initial,ext,ext-demo"` -`gradlew "ofbiz --load-data"` +`gradlew run --args="--load-data"` -`gradlew "ofbiz --load-data readers=seed"` +`gradlew run --args="--load-data readers=seed"` -`gradlew "ofbiz --load-data readers=seed,seed-initial,ext"` +`gradlew run --args="--load-data readers=seed,seed-initial,ext"` -`gradlew "ofbiz --load-data readers=seed,seed-initial,ext,ext-test"` +`gradlew run --args="--load-data readers=seed,seed-initial,ext,ext-test"` -`gradlew "ofbiz --load-data file=foo/bar/FileNameHere.xml"` +`gradlew run --args="--load-data file=foo/bar/FileNameHere.xml"` -`gradlew 'ofbiz --test'` +`gradlew run --args='--test'`
With the gradle to ofbiz scripts names change it's
-MS Windows: `gradlew ofbiz` +MS Windows: `ofbiz run` -Unix-like OS: `./gradlew ofbiz` +Unix-like OS: `./ofbiz run` -`gradlew "ofbiz --help"` +`ofbiz run --args="--help"` -`gradlew "ofbizDebug --test"` +`ofbiz run --debug-jvm --args="--test"` -`gradlew "ofbiz --shutdown --portoffset 10000"` +`ofbiz run --args="--shutdown --portoffset 10000"` -`gradlew ofbiz` (default is --start) +`ofbiz run` -`gradlew cleanAll loadAll "ofbiz --start --portoffset 10000"` +`ofbiz cleanAll loadAll run --args="--start --portoffset 10000"` -`gradlew "ofbiz --help"` +`ofbiz run --args="--help"` -`gradlew "ofbiz --start"` +`ofbiz run` -`gradlew "ofbiz --shutdown"` +`ofbiz run --args="--shutdown"` -`gradlew "ofbiz --status"` +`ofbiz run --args="--status"` -`gradlew "ofbizDebug --start"` +`ofbiz run --debug-jvm` -`gradlew "ofbiz --start --portoffset 10000"` +`ofbiz run --args="--start --portoffset 10000"` -`gradlew ofbiz -PjvmArgs="-Xms1024M -Xmx2048M" -Dsome.parameter=hello` +`ofbiz run -PjvmArgs="-Xms1024M -Xmx2048M" -Dsome.parameter=hello` -`gradlew "ofbiz --load-data readers=<readers-here-comma-separated>"` +`ofbiz run --args="--load-data readers=<readers-here-comma-separated>"` -`gradlew "ofbiz --load-data readers=seed,seed-initial,ext,ext-demo"` +`ofbiz run --args="--load-data readers=seed,seed-initial,ext,ext-demo"` -`gradlew "ofbiz --load-data"` +`ofbiz run --args="--load-data"` -`gradlew "ofbiz --load-data readers=seed"` +`ofbiz run --args="--load-data readers=seed"` -`gradlew "ofbiz --load-data readers=seed,seed-initial,ext"` +`ofbiz run --args="--load-data readers=seed,seed-initial,ext"` -`gradlew "ofbiz --load-data readers=seed,seed-initial,ext,ext-test"` +`ofbiz run --args="--load-data readers=seed,seed-initial,ext,ext-test"` -`gradlew "ofbiz --load-data file=foo/bar/FileNameHere.xml"` +`ofbiz run --args="--load-data file=foo/bar/FileNameHere.xml"` -`gradlew 'ofbiz --test'` +`ofbiz run --args='--test'`
I let everyone make their own opinion...
Of course, we must note that this forces all users to change their scripts as well (both proposition your and Pierre's)...
Hello Jacques,
Renaming the gradlew wrapper ofbiz would be really confusing since they are not the same program.
> Of course, we must note that this forces all users to change their scripts as well (both proposition your and Pierre's)...
This is not the case at all, the patch I am proposing is only adding the run task and suggesting in the README.adoc to use it, I am not removing the ./gradlew "ofbiz ..." rule tasks, so scripts will not break.
To avoid confusing people anymore I have removed the documentation change regarding the suggestion to use the run task, so OFBIZ-10866_Use-the-application-and-distribution-plugin.patch is now really just about providing the distTar and distZip tasks, nothing more.
Hi Mathieu,
Renaming the gradlew wrapper ofbiz would be really confusing since they are not the same program.
I'm not opiniated about that, but we can be creative and have our own conventions. We could just put a comment in the scripts to explain why. Anyway it's really a minor thing and I'll not push more about that.
This is not the case at all, the patch I am proposing is only adding the run task and suggesting in the README.adoc to use it, I am not removing the ./gradlew "ofbiz ..." rule tasks, so scripts will not break.
In your last patch it's not the case indeed. Do you plan to propose the "run changes" in another Jira or patch or did you gave up?
Anyway +1 for your last patch! I did not test it all but it's simple and clear.
Thanks Jacques,
I will apply the reduced version of OFBIZ-10866_Use-the-application-and-distribution-plugin.patch and close this ticket next monday since it seems that there is a consensus on that part.
I give up on proposing to change the documentation to recommend using the run task over the ofbiz rule-based tasks. Regarding renaming the gradle wrapper ofbiz, feel free to open a discussion on the ML if you want to propose it to the community.
Hi Mathieu,
Don't give up too quickly Part of work of being in the community is convincing and discussing things.
Anyway, it seems what you are trying to achieve in this Jira is directly affecting the user experience and the way people are used to controlling the system. So perhaps a community discussion must precede any changes that happen here because it seems to be a big change to me.
With that being said, I have a comment regarding what you said about using the "generic" vs "specific" way like the rule-based tasks, Please remember that OFBiz is not standard in that sense. OFBiz does not deploy like a normal java web app (unfortunately) and so many things about the framework do not fall within standards.
Furthermore, Debugging is super important with all the possible values, so ofbizDebug needs to be satisfied, the running task does not accommodate for that if I'm not mistaken. So this needs to be something to look into.
Finally, I agree with you completely, a very confusing suggestion by Jacques to rename gradlew. That would be in effect hiding the fact that you are using a very known tool and it confuses the hell out of everyone.
Hello Taher,
The distribution feature is far more important to me than recommending the run task since it empowers people deploying OFBiz in production. The main reason I am giving up is that I don't want a discussion on syntax to block the patch which is not about syntax.
Anyway, it seems what you are trying to achieve in this Jira is directly affecting the user experience and the way people are used to controlling the system. So perhaps a community discussion must precede any changes that happen here because it seems to be a big change to me.
I agree that a change in the command line UI would need a community discussion, however I have other priorities.
Furthermore, Debugging is super important with all the possible values, so ofbizDebug needs to be satisfied, the running task does not accommodate for that if I'm not mistaken. So this needs to be something to look into.
There is the --debug-jvm gradle option which already achieves the same thing as ofbizDebug on trunk just try ./gradlew ofbiz --debug-jvm. The only thing that is not supported by Gradle OOTB is running OFBiz in the background like ofbizBackground.
Thanks for your feedback.
Hi Mathieu,
It seems you created the patch before committing last changes in the build file, so it does not apply. Apart that the distribution seems a great stuff, thanks for that!