Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ghillert/pof-gradle-demo-multi-project

Using the Coherence Gradle POF Plugin with multi-project Gradle builds
https://github.com/ghillert/pof-gradle-demo-multi-project

Last synced: about 7 hours ago
JSON representation

Using the Coherence Gradle POF Plugin with multi-project Gradle builds

Awesome Lists containing this project

README

        

= POF Gradle Demo Multi-Project

Using the
https://coherence.community/24.03-SNAPSHOT/docs/#/docs/core/04_gradle[Coherence Gradle POF Plugin] with multi-project
Gradle builds.

As a starting point we use the Gradle `init` task to create a multi-project build. This is the same example provided at
https://docs.gradle.org/current/samples/sample_building_java_applications_multi_project.html[Building Java Applications with libraries Sample]
in the Gradle documentation.

== Create Gradle Project Structure

[source,bash,indent=0]
----
gradle init
----

[source,bash,indent=0]
----
Select type of project to generate:
1: basic
2: application
3: library
4: Gradle plugin
Enter selection (default: basic) [1..4] 2
----

[source,bash,indent=0]
----
Select implementation language:
1: C++
2: Groovy
3: Java
4: Kotlin
5: Scala
6: Swift
Enter selection (default: Java) [1..6] 3
----

[source,bash,indent=0]
----
Generate multiple subprojects for application? (default: no) [yes, no] yes
----

[source,bash,indent=0]
----
Select build script DSL:
1: Kotlin
2: Groovy
Enter selection (default: Kotlin) [1..2] 2
----

[source,bash,indent=0]
----
Project name (default: pof-gradle-demo-multi-project): pof-gradle-demo-multi-project
----

[source,bash,indent=0]
----
Source package (default: pof.gradle.demo.multi.project): com.hillert.coherence.pof
----

[source,bash,indent=0]
----
Enter target version of Java (min. 7) (default: 21): 21
----

[source,bash,indent=0]
----
Generate build using new APIs and behavior (some features may change in the next minor release)? (default: no) [yes, no] no
----

== Add Coherence POF Plugin

=== To App module

We will use a snapshot version of the Coherence POF plugin. To do this we need to add the Sonatype snapshot repository to
`settings.gradle` in the root of the project.

.settings.gradle (root)
[source,groovy,indent=0]
----
pluginManagement {
repositories {
mavenLocal()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
gradlePluginPortal()
}
}
----

Now we can add the Coherence POF plugin to the `app` module. In `./app/build.gradle` add the following:

.build.gradle (app module)
[source,groovy,indent=0]
----
plugins {
id 'com.hillert.coherence.pof.java-application-conventions'
id 'com.oracle.coherence.ce' version '24.03-SNAPSHOT'
}

...

compileTestJava {
dependsOn('coherencePof')
}
----

NOTE: `24.03-SNAPSHOT` contains a regression. By default `compileTestJava` should depend on `coherencePof` but this is not
the case right now. Therefore, we need to add the `dependsOn` line explicitly.

=== To Utilities module

Let's decide to add the Coherence POF plugin to the `utilities` module instead, as we decide to keep our POF annotated
classes in the `utilities` module. Therefore, move the Coherence POF plugin declaration to `./utilities/build.gradle`:

.build.gradle (app module)
[source,groovy,indent=0]
----
plugins {
id 'com.hillert.coherence.pof.java-application-conventions'
id 'com.oracle.coherence.ce' version '24.03-SNAPSHOT'
}

dependencies {
api project(':list')
implementation('com.oracle.coherence.ce:coherence:23.09');
}

compileTestJava {
dependsOn('coherencePof')
}
----

We will also add a dependency on the Coherence library to the `utilities` module. Next we will add a basic POF annotated
class to the `utilities` module:

.PofClass.java (utilities module)
[source,java,indent=0]
----
package com.hillert.coherence.pof.utilities;

import com.tangosol.io.pof.schema.annotation.PortableType;

@PortableType(id=1000)
public class PofClass {
private String name;

public PofClass(String name) {
this.name = name;
}

public String getName() {
return name;
}
}
----

One thing that is missing is a dependency on the `utilities` module's `coherencePof` from the `app` module. Add the following to
`./app/build.gradle`:

.build.gradle (app module)
[source,groovy,indent=0]
----
compileJava {
dependsOn(':utilities:coherencePof')
}
----

NOTE: `24.03-SNAPSHOT` contains a regression in this regard. By default, a child module with a `compileJava` should
automatically depend on `coherencePof` but this is not the case right now. Therefore, we need to add the `dependsOn` line
explicitly.