aionnetwork / aion_api

aion network api repository
MIT License
20 stars 20 forks source link

Gradle: separate from aion repo and build scripts #60

Closed aion-kelvin closed 5 years ago

aion-kelvin commented 5 years ago

Details of how jar and pom were added:

Short version: From a cloned aion repo, run: ./gradlew :modAionBase:publish :modCrypto:publish :modLogger:publish :modRlp:publish :3rdParty.libnzmq:publish :aion_vm_api:publish :modUtil:publish -PpublishTarget=/home/you/path_to/aion_api/lib/maven_repo

That basically runs publish for a bunch of kernel modules we specifically name in the command. The modules we named are the ones we added in build.gradle (modAionBase, modCrypto, modLogger, modRlp, libnzmq), plus all transitive dependencies (modUtil, aion_vm_api).

Long version

After updating build.gradle in aion_api, if you build, it will tell you that it can't find the dependencies, since modAionBAse, modLogger, etc are not in a Maven Central repo. This command can be run for a nicer view of missing dependencies:

$ ./gradlew dependencies --configuration compile -q 

------------------------------------------------------------
Root project
------------------------------------------------------------

compile - Dependencies for source set 'main' (deprecated, use 'implementation ' instead).
+--- network.aion:modAionBase:0.3.2 FAILED
+--- network.aion:modCrypto:0.3.2 FAILED
+--- network.aion:modLogger:0.3.2 FAILED
+--- network.aion:modRlp:0.3.2 FAILED
+--- network.aion:libnzmq:1.0 FAILED
+--- com.madgag.spongycastle:prov:1.58.0.0
|    +--- com.madgag.spongycastle:core:1.58.0.0
|    \--- junit:junit:4.12
|         \--- org.hamcrest:hamcrest-core:1.3
+--- com.madgag.spongycastle:core:1.58.0.0
+--- org.apache.commons:commons-collections4:4.0
+--- org.slf4j:slf4j-api:1.7.25
+--- com.google.protobuf:protobuf-java:3.5.0
+--- com.google.code.gson:gson:2.7
+--- ch.qos.logback:logback-core:1.2.3
+--- ch.qos.logback:logback-classic:1.2.3
|    +--- ch.qos.logback:logback-core:1.2.3
|    \--- org.slf4j:slf4j-api:1.7.25
\--- com.google.code.findbugs:jsr305:3.0.2

So in kernel, we use the publish target of the missing dependencies and tell Gradle to write it to aion_api's maven repo dir:

./gradlew :modAionBase:publish :modCrypto:publish :modLogger:publish :modRlp:publish :3rdParty.libnzmq:publish -PpublishTarget=/home/sergiu/repos/aion_api/lib/maven_repo 

If we try to build aion_api again, there's new missing dependencies. That's because the kernel modules we just published have dependencies on other kernel modules.

$ ./gradlew build -q

FAILURE: Build failed with an exception.

* Where:
Build file '/home/sergiu/repos/aion_api/build.gradle' line: 168

* What went wrong:
Could not determine the dependencies of task ':fatJar'.
> Could not resolve all files for configuration ':compile'.
   > Could not find network.aion:aion_vm_api:0.3.2.
     Searched in the following locations:
       - file:/home/sergiu/.m2/repository/network/aion/aion_vm_api/0.3.2/aion_vm_api-0.3.2.pom
       - file:/home/sergiu/.m2/repository/network/aion/aion_vm_api/0.3.2/aion_vm_api-0.3.2.jar
       [...]
     Required by:
         project : > network.aion:modAionBase:0.3.2
   > Could not find network.aion:modUtil:0.3.2.
     Searched in the following locations:
       - file:/home/sergiu/.m2/repository/network/aion/modUtil/0.3.2/modUtil-0.3.2.pom
       - file:/home/sergiu/.m2/repository/network/aion/modUtil/0.3.2/modUtil-0.3.2.jar
      [...]
     Required by:
         project : > network.aion:modCrypto:0.3.2
         project : > network.aion:modRlp:0.3.2

So, we go back to the kernel and publish those ones as well (./gradlew :aion_vm_api:publish :modUtil:publish -PpublishTarget=/home/sergiu/repos/aion_api/lib/maven_repo ). After that, aion_api can build.

Testing

I've tested the output jar of pack build against Aion Wallet (replaced its aion_api jar with the one produced by this code) and it appears to function fine on Linux. Note: still need to add Mac and Windows support to libnzmq before we update Aion Wallet jars with these new ones.

aion-kelvin commented 5 years ago

I updated the README with the instructions. It seems pretty outdated, we should spend some time to update the rest of it soon.