What is the difference between installDist task in gradle distribution plugin and build task in gradle java plugin? and how can we run the application generated by these two plugin? The scene i meet is that: i am learning hyperledger fabric, and found some java contract application in the tutorial using gradle distributon plugin and thus using installDist task, but there also some java contract using gradle java plugin instead of distribution plugin and the tutorial do not tell me how to deploy this kind of java contract.
Asked
Active
Viewed 5,750 times
4
-
1Could you please provide a link to the sample application you've mentioned? I might be able to add specific clarifications to my answer seeing project configuration. – r4zzz4k Aug 07 '20 at 09:28
-
@r4zzz4k https://github.com/shudal/my-fabric-samples/tree/master/chaincode/fabcar/java this app use application plugin. – user14063487 Aug 12 '20 at 08:36
-
@r4zzz4k https://github.com/shudal/my-fabric-samples/tree/master/commercial-paper/organization/magnetocorp/contract-java this app only use java plugin – user14063487 Aug 12 '20 at 08:37
-
Second one uses shadow plugin, so it has [`shadowJar`](https://imperceptiblethoughts.com/shadow/getting-started/#default-java-groovy-tasks) task which is probably what you need. It should output it's jar into `build/libs/chaincode.jar` if I'm not missing anything ([docs](https://imperceptiblethoughts.com/shadow/configuration/#configuring-output-name) and [usage](https://github.com/shudal/my-fabric-samples/blob/1c500ba30e791ed302fd740da59338ae592d263a/commercial-paper/organization/magnetocorp/contract-java/build.gradle#L37-L45)) – r4zzz4k Aug 12 '20 at 09:41
1 Answers
7
installDist
is a task from bundled Distrubution Plugin. Its output can be found at build/install/[project-name]
. To detect what should be packaged, it relies on other plugins, for example Application Plugin. If that's present, after invoking ./gradlew installDist
you'll find bulild/install/[project-name]/bin/[project-name].bat
, which should run the application.
build
is a common task to assemble and test the project. It often does not provide distribution which can be pulled into a separate directory or executed easily. Aforementioned Application Plugin adds run
task which assembles and then runs the app directly from the project tree. Depending on the configuration of your project, there may be some custom tasks to deploy the contract.

r4zzz4k
- 656
- 5
- 10
-
-
your answer is correct, but i have issue with the installDist command, the directory and packaging is done as per your answer only. issue is while executing main class is not found Error: Could not find or load main class C:\Users\Sandeep Prajapati\Downloads\Ex_Files_Gradle_Java\Exercise Files\chapter_1\01_01\build\install\01_01\bin\01_01.bat1_01_OPTSCLASSPATH* The system cannot find the path specified ├───install │ └───01_01 │ ├───bin -> 01_01 01_01.bat │ └───lib -> calculator-1.0.0.jar the command i ran is /install/01_01/bin ~ ./01_01 add 1 2 – Sandeep Prajapati Mar 26 '23 at 09:35