Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle task to publish dependencies for bisq mobile using mavenLocal #2965

Conversation

rodvar
Copy link
Contributor

@rodvar rodvar commented Oct 29, 2024

  • Implementation for Publish Bisq 2 libraries for re-use in Bisq-mobile #2951
  • create custom plugin to apply to each specific module where we need to publish jar to maven local
  • applied to all the necesary modules we need for AndroidNode
  • created handy publishAll task in root
  • adaptations for recursive submodules like network

Screenshot from 2024-10-29 22-28-30
Screenshot from 2024-10-29 22-28-24
Screenshot from 2024-10-29 22-28-16

@HenrikJannsen
Copy link
Contributor

Those modules need to be added as well:
account
application
presentation

The tor project is another project inside network with sub-projects. That is not published yet.

When using in Android there is an error with missing dependency to bisq::platform, which is part of the pom.xml file

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>bisq</groupId>
        <artifactId>platform</artifactId>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

I think the protobuf and resources need to be added to sources for the jars.

@rodvar
Copy link
Contributor Author

rodvar commented Oct 29, 2024

Those modules need to be added as well: account application presentation

The tor project is another project inside network with sub-projects. That is not published yet.

When using in Android there is an error with missing dependency to bisq::platform, which is part of the pom.xml file

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>bisq</groupId>
        <artifactId>platform</artifactId>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

I think the protobuf and resources need to be added to sources for the jars.

cool I'll work on this next 💪

@rodvar rodvar marked this pull request as draft October 29, 2024 22:29
@rodvar rodvar force-pushed the feature/j17_modules_publishing_for_android branch 2 times, most recently from f870181 to fdbbc3a Compare October 30, 2024 06:33
@rodvar rodvar marked this pull request as ready for review October 30, 2024 06:40
@rodvar rodvar marked this pull request as draft October 31, 2024 04:14
@rodvar
Copy link
Contributor Author

rodvar commented Oct 31, 2024

this is proving to be quite complex, because of the complexities of gradle composite builds we use in the project the generated default pom files have significant issues (corrupted files with no version in dependencies, or wrong reference name). I'm dealing with each one by one.
For the platform issue, I needed to publish a fake BOM dependency to maven local and it solved the issue.

@rodvar
Copy link
Contributor Author

rodvar commented Oct 31, 2024

this feature forces us to define requirement of dependencies properly (always specifying a version) cause

  • pom dependency without versioning is a corrupted file (already fixed)
  • dependency references to be able to work in m2 therefore, always need to specify the version appart from the group and artifact

So we need to fix the following now:

Cause 1: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find tor:tor:.
Required by:
   project :app > bisq:network:2.1.2
Cause 2: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find network:network:.
Required by:
   project :app > bisq:identity:2.1.2
   project :app > bisq:account:2.1.2
   project :app > bisq:settings:2.1.2
   project :app > bisq:bonded-roles:2.1.2
   project :app > bisq:user:2.1.2
   project :app > bisq:contract:2.1.2
   project :app > bisq:offer:2.1.2
   project :app > bisq:trade:2.1.2
   project :app > bisq:support:2.1.2
   project :app > bisq:application:2.1.2
   project :app > bisq:chat:2.1.2
Cause 3: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find network:network-identity:.
Required by:
   project :app > bisq:identity:2.1.2
   project :app > bisq:bonded-roles:2.1.2
   project :app > bisq:user:2.1.2
   project :app > bisq:contract:2.1.2
   project :app > bisq:offer:2.1.2
   project :app > bisq:trade:2.1.2
   project :app > bisq:support:2.1.2
   project :app > bisq:chat:2.1.2

@rodvar
Copy link
Contributor Author

rodvar commented Oct 31, 2024

Android POC can compile with these changes but failes dexing with a protobuf duplicated class error Account$Builder

@rodvar
Copy link
Contributor Author

rodvar commented Nov 3, 2024

agreed with henrik we can ignore bisq-easy dependency as its not really needed and forces us to export wallet and bitcoind which we wold like to avoid.

@rodvar
Copy link
Contributor Author

rodvar commented Nov 5, 2024

removed bisq-easy, only issue pending for the POC to build is solving protobuf duplicated defs:

Type bisq.account.protobuf.Account$Builder-IA is defined multiple times: andorid_only_poc/app/build/intermediates/project_dex_archive/release/dexBuilderRelease/out/bisq/account/protobuf/Account$Builder.dex, 
andorid_only_poc/app/build/intermediates/external_libs_dex/release/mergeExtDexRelease/classes2.dex

@rodvar rodvar force-pushed the feature/j17_modules_publishing_for_android branch from e57b611 to 912c078 Compare November 5, 2024 05:00
@rodvar
Copy link
Contributor Author

rodvar commented Nov 5, 2024

Managed to get rid of those issues by using a different package for the proto generated in the mobile POC (some libs jave the jar generation including the proto sources and everything in bisq2 depends on that so cleaning it up is very complex)

now I'm into a different deal of problems, looks like code is still being compiled using Java22

import bisq.user.cathash.CatHashService;
                        ^
  bad class file: .m2/repository/bisq/user/2.1.2/user-2.1.2.jar(/bisq/user/cathash/CatHashService.class)
    class file has wrong version 66.0, should be 61.0

need to use this PR to make sure Java 17 is used for compilation

@rodvar
Copy link
Contributor Author

rodvar commented Nov 5, 2024

worth to mention that it builds now, the error above is in runtime :)

BUILD SUCCESSFUL in 1m 6s
117 actionable tasks: 117 executed

@rodvar
Copy link
Contributor Author

rodvar commented Nov 5, 2024

@HenrikJannsen I merged your latest work on the native POC + some small adaptations into bisq-mobile pocs folder, let's continue contributions there 💪

@rodvar rodvar force-pushed the feature/j17_modules_publishing_for_android branch from edc932b to 85835f8 Compare November 5, 2024 23:10
@rodvar rodvar marked this pull request as ready for review November 5, 2024 23:54
@rodvar
Copy link
Contributor Author

rodvar commented Nov 5, 2024

@HenrikJannsen this version works. You can test it by running ./gradlew clean build publishAll and then run the POC you can find here https://github.com/bisq-network/bisq-mobile/tree/main/pocs/android_only_m2_j17jars

Next lines of work after this is merged:

  • some protobuf errors of classes not recognised (see logs when running the POC)
  • optimizations on the generated jars: debug apk size is ~75MB, we could trim the generated jars removing all of the protobuf stuff for example, which we decided its gonna be client based
  • allow publishing on internet maven repository (this will be very useful for our CI setup)

Let me know your thoughts!

@rodvar
Copy link
Contributor Author

rodvar commented Nov 6, 2024

@HenrikJannsen happy to revert the changes on wallets/ module as we ended up not needing them, let me know

@HenrikJannsen
Copy link
Contributor

@HenrikJannsen happy to revert the changes on wallets/ module as we ended up not needing them, let me know

Yes that would be good.

@HenrikJannsen
Copy link
Contributor

@rodvar Regaring the setting of the Java version 17: We still would like to use Java 22 for Bisq 2, so it would be good to have the version configurable so that the publish tasks use Java 17 but normal build/deployment tasks use Java 22.
If that adds lot of effort we can delegate it to a dedicated PR as well.

@rodvar
Copy link
Contributor Author

rodvar commented Nov 6, 2024

@rodvar Regaring the setting of the Java version 17: We still would like to use Java 22 for Bisq 2, so it would be good to have the version configurable so that the publish tasks use Java 17 but normal build/deployment tasks use Java 22. If that adds lot of effort we can delegate it to a dedicated PR as well.

I'll give this a go today, if its not trivial I agree we can do it in a subsequent PR

@rodvar rodvar force-pushed the feature/j17_modules_publishing_for_android branch 3 times, most recently from cfa6d62 to a7426c7 Compare November 7, 2024 01:08
@rodvar rodvar force-pushed the feature/j17_modules_publishing_for_android branch 3 times, most recently from a1ffa05 to 12964e4 Compare November 7, 2024 05:24
@rodvar
Copy link
Contributor Author

rodvar commented Nov 7, 2024

it's all broken after rebase, even switching to main or downloading a fresh new copy of bisq I get

* What went wrong:
Error resolving plugin [id: 'bisq.gradle.toolchain_resolver.ToolchainResolverPlugin']
> Included build '/projects/bisq_new/wallets/bitcoind/build-logic' does not exist.


org.gradle.api.GradleException: Error resolving plugin [id: 'bisq.gradle.toolchain_resolver.ToolchainResolverPlugin']


Caused by: org.gradle.api.InvalidUserDataException: Included build '/home/rok/projects/bisq_new/wallets/bitcoind/build-logic' does not exist.

@HenrikJannsen
Copy link
Contributor

HenrikJannsen commented Nov 7, 2024

I will make a PR with additional build instructions for git submodule in a minute.

Setup bitcoind git submodule:
At project setup run first:

git submodule init
git submodule update

In case the submodule has changed after a project update, run:

git submodule update

@rodvar
Copy link
Contributor Author

rodvar commented Nov 8, 2024

Project won't build until this gets merged to wallets/bitcoind submodule

@rodvar rodvar force-pushed the feature/j17_modules_publishing_for_android branch from 9479975 to 9b88ed0 Compare November 8, 2024 09:56
   to publish jar to maven local
 - applied to all the necesary modules we need for AndroidNode
 - created handy publishAll task in root
 - adaptations for recursive submodules like network
 - include protobuf generated sources in the jars when available
 - include tor composite build
 - updated publishAll to consider all the needed jars for Android node
   dev
   build-logic dependent on version)
 - added fake BOM maven publish for gradle platform module 'platform'
 - flatten generate m2 repo structure leaving composite gradle modules
   on its own group
 - require a more careful definition of dependencies considering version
   (full group-artifact-version definition)
@rodvar rodvar force-pushed the feature/j17_modules_publishing_for_android branch from 9b88ed0 to fa28883 Compare November 8, 2024 10:13
Copy link
Contributor

@HenrikJannsen HenrikJannsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@HenrikJannsen
Copy link
Contributor

This PR need some follow-up but to not block the work on Bisq mobile we merge it as it is.
Open tasks for future PR:

  • We use Java 17 but we would like to use Java 22 for the Bisq 2 app build/deployment. For publishing for mobile though we need java 17. It should be made default Java 22 and the publish task change it for the time it is running to Java 17. We should also rename the publishAll task to specify the special purpose for Bisq mobile (requiring Java 17).
  • Jitpack not used yet. Need to be figured out if we want to use it. For now we use MavenLocal
  • The Bisq verison in libs.versions.toml should be dynamically set from the root version

@HenrikJannsen HenrikJannsen merged commit 9b1bbdd into bisq-network:main Nov 8, 2024
15 checks passed
@rodvar rodvar deleted the feature/j17_modules_publishing_for_android branch November 8, 2024 21:59
@rodvar
Copy link
Contributor Author

rodvar commented Nov 8, 2024

This PR need some follow-up but to not block the work on Bisq mobile we merge it as it is. Open tasks for future PR:

  • We use Java 17 but we would like to use Java 22 for the Bisq 2 app build/deployment. For publishing for mobile though we need java 17. It should be made default Java 22 and the publish task change it for the time it is running to Java 17. We should also rename the publishAll task to specify the special purpose for Bisq mobile (requiring Java 17).
  • Jitpack not used yet. Need to be figured out if we want to use it. For now we use MavenLocal
  • The Bisq verison in libs.versions.toml should be dynamically set from the root version

Thanks Henrik, I've created an issue for this please have a read and contribute with anything you think appropiate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants