May be a bit out of date ⚠️⚠️⚠️

Stub used to generate the template implement code, and 3rd party dependencies integrated.

Setup

Please refer to apihug-full-demo demo-user/build.gradle:

plugins {
    id "java"
    alias(libs.plugins.springBoot)
    alias(libs.plugins.springDependency)
    alias(libs.plugins.hopeStub)
    alias(libs.plugins.liquibase)

}

hopeStub {
    debug = false
}

Meta information apihug-full-demo demo-user/hope-stub.json:

{
  "packageName": "com.apihug.demo.user",
  "name": "demo-user",
  "domain": "user",
  "proto": {
    "artifact": {
      "groupId": "com.apihug",
      "artifactId": "demo-user-proto",
      "version": "0.1.1-SNAPSHOT"
    },
    "module": "demo-user-proto",
    "domain": "user",
    "applied": true
  },
  "dependencies": [
  ]
}

Configuration

hopeStub Configuration:

NameDescriptionType(Default)Remarks
debugPlugin DebuggingbooleanfalseExit after configuration check, without completing any code generation
verboseEnable Execution LogbooleanfalseOpen full log for debugging when issues arise
generatedVersionInclude Plugin VersionbooleanfalseWhether the @Generated annotation in the generated code includes the plugin version
generatedTimeInclude Generation TimestampbooleanfalseWhether the @Generated annotation in the generated code includes the generation timestamp
pluginMainVersionPlugin Auxiliary VersionStringThe version dependency of the wire plugin at runtime, do not set unless necessary. Apihug’s overall package is released with BOM, and this version should not be manually set
pluginMainClassPlugin Auxiliary Main EntryStringDo not set unless the plugin is extended
enableFrontVueGenerate Front Vue ScaffoldingbooleanfalseExperimental stage
adminStubGenerate Admin Management CodebooleanfalseNot enabled

Meta configuration resources\hope-stub.json:

  1. Self-service Protocol Definition Dependencies: In the proto configuration, define dependencies for a single self-service protocol.
  2. Third-party Service Protocol Definition Dependencies: In the dependencies, understand as dependencies on other microservices, which can be multiple.
  3. Artifact Section: If dependencies have already been introduced in various ways through dependencies in your own build.gradle, this section is not necessary. Incorrect configurations can lead to compilation errors and may cause runtime errors! ⚠️⚠️⚠️
    1. The dependencies of the service protocol proto package can be controlled through standard Gradle dependencies.
    2. Dependencies can also be managed by configuring in the resources\hope-stub.json file, and the plugin will handle it for you.
    3. Maintain a unified approach and avoid mixing usage, as this can make problem location troublesome.
NameDescriptionType(Default)Remarks
packageNamePackage NameStringRequiredProject package name, must conform to Java package naming conventions, cannot contain reserved keywords: wire, stub
nameProject NameStringRequiredProject identifier, must conform to artifact ID, lowercase, Chinese characters, e.g., user-info, corresponds to the application of the proto project
domainDomainStringRequiredThe domain it belongs to
proto.artifact.groupIdSelf-service Proto Group IDStringOptionalSelf-service, dependency package group ID
proto.artifact.artifactIdSelf-service Proto Artifact IDStringOptionalSelf-service, dependency package artifact ID
proto.artifact.versionSelf-service Proto VersionStringOptionalSelf-service, dependency package version
proto.moduleSelf-service Proto ModuleStringRequiredUsed for service locator at runtime to locate, if not set, proto.artifact.artifactId is used instead
proto.domainSelf-service Proto DomainStringOptionalIf not set, it is the same as the main project domain
proto.appliedSelf-service Proto IncludedbooleanRequiredWhether it has been included, if already included in gradle > dependencies, the plugin will not include the lib again
dependencies.artifact.groupIdThird-party Service Proto Group IDStringOptionalThird-party service, dependency package group ID
dependencies.artifact.artifactIdThird-party Service Proto Artifact IDStringOptionalThird-party service, dependency package artifact ID
dependencies.artifact.versionThird-party Service Proto VersionStringOptionalThird-party service, dependency package version
dependencies.moduleThird-party Service Proto ModuleStringRequiredThird-party service, module name, if not set, it should be consistent with artifact.artifactId
dependencies.domainThird-party Service Proto DomainStringRequiredThird-party service, domain
dependencies.appliedThird-party Service Proto IncludedbooleanfalseWhether it has been included, if already included in gradle > dependencies, the plugin will not include the lib again

Run

Every Auto generated project include a detail README example: README, include detail instruction how to use it.

NOT like Wire which integrate with gradle’s default compile task, stub must run manually as you manually trigger it:

sh gradlew {YOUR_MODULE}:clean stub build -x test -x stubTest