Skip to content

Gradle plugin for Spine-based projects.

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE
Unknown
license-report.md
Notifications You must be signed in to change notification settings

SpineEventEngine/bootstrap

bootstrap

Build Status

The Gradle plugin for bootstrapping projects built with Spine.

Applying to the project

In order to apply the plugin to a Gradle project, in build.gralde add the following config:

plugins {
    id("io.spine.tools.gradle.bootstrap").version("1.9.0")
}

See this Gradle doc on how to apply a plugin only to certain to subprojects.

Java Projects

In order to mark a (sub-)project as a Java project for Spine, apply the following config:

spine.enableJava()

This configuration:

  • applies java Gradle plugin;

  • applies com.google.protobuf Gradle plugin;

  • configures Java code generation from Protobuf;

  • adds a dependency onto the io.spine:spine-base module;

  • applies the Spine Model Compiler plugin and performs its minimal configuration.

More often than not, a user would also like to mark a Java project as a client or a server module. To do that, apply the following configuration:

  • for client modules:

    spine.enableJava().client()
  • for server modules:

    spine.enableJava().server()

This config will add required dependencies for developing a Spine-based Java client and server respectively.

Obtaining the version when adding other dependencies

In order to use the same version for other Spine libraries, please use spine.version(). For example, adding testing utilities would look like this:

dependencies {
   //...
   testImplementation("io.spine:spine-testutil-server:${spine.version()}")   
}   

gRPC code generation

Spine relies on gRPC.

All the required gRPC Java stubs and services are already included into the Spine artifacts. However, if users would like to declare gRPC services of their own, they may use the following configuration to set up the generation seamlessly:

spine.enableJava {
    codegen {
        grpc = true
    }
    client() // or server()
}

Note that it is required to mark the module as either client() or server(). Otherwise, the user would have to add all the gRPC-related dependencies on their own.

Also, gRPC may require additional dependencies at runtime. For example, the grpc-netty dependency is not added by default in order not to cause clashes in the user projects.

Disable code generation

Sometimes, the users might not want any Java code to be generated. For such cases, the plugin provides following configuration opportunity:

spine.enableJava {
    codegen {
        protobuf = false
        spine = false
    }
}

This way, no Java code will be generated at all, including Protobuf messages, gRPC services, validating builders, and rejections.

A user also may leave the Java Protobuf codegen enabled, but only turn off Spine-specific code generation:

spine.enableJava {
    codegen {
        spine = false
    }
}

JavaScript Projects

In order to mark a (sub-)project as a JS project for Spine, apply the following config:

spine.enableJavaScript()

This configuration:

  • applies com.google.protobuf and java Gradle plugin (as the former depends on the latter);
  • configures JS code generation from Protobuf.

If only JS generation is configured, the Java code will not be generated (and the other way around).

Dart Projects

In order to mark a (sub-)project as a Dart project for Spine, apply the following config:

spine.enableDart()

This configuration:

  • applies com.google.protobuf and java Gradle plugin (as the former depends on the latter);
  • configures Dart code generation from Protobuf.

If only Dart generation is configured, the Java code will not be generated (and the other way around).