Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/sebersole/jakarta-transformer-plugin

JakartaTransformer Gradle plugin
https://github.com/sebersole/jakarta-transformer-plugin

Last synced: 26 days ago
JSON representation

JakartaTransformer Gradle plugin

Awesome Lists containing this project

README

        

= JakartaTransformer Gradle plugin

image:https://github.com/hibernate/jakarta-transformer-plugin/actions/workflows/gradle.yml/badge.svg[Build Status,link=https://github.com/hibernate/jakarta-transformer-plugin/actions/workflows/gradle.yml]

Plugin for integrating the https://github.com/eclipse/transformer[JakartaTransformer] tool into Gradle builds.

The main implemented case at the moment is that of "shadowing" (to play on the phrase "shade").
Basically this allows a project to apply this plugin, point to a dependency, have the plugin
transform that dependency's artifacts and present those transformed artifacts as the projects
published artifacts.

E.g.

[source]
----
plugins {
id 'base'
id 'hibernate.jakarta-transformer'
}

ext {
jpa = 'javax.persistence:javax.persistence-api:2.2'
jta = 'org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec'

jakartaJpa = 'jakarta.persistence:jakarta.persistence-api:3.0.0'
jakartaJta = 'jakarta.transaction:jakarta.transaction-api:2.0.0'
}

dependencies {
// Specifying the transformer's dependencies is optional. 0.2.0 is used by default
jakartaTransformerTool(
'org.eclipse.transformer:org.eclipse.transformer:0.2.0',
'org.eclipse.transformer:org.eclipse.transformer.cli:0.2.0'
)
}

jakartaTransformation {
renameRules rootProject.file( 'rules/jakarta-renames.properties' )
versionRules rootProject.file( 'rules/jakarta-versions.properties' )
directRules rootProject.file( 'rules/jakarta-direct.properties' )

dependencyResolutions {
dependencySubstitution {
substitute module( project.jpa ) with module( project.jakartaJpa )
substitute module( project.jta ) with module( project.jakartaJta )
}
}

shadow( 'org.hibernate:hibernate-core:5.5.0.Alpha1' ) {
runTests {
useJUnitPlatform()
...
}
withSources()
withJavadoc()
}
}
----

This configuration will:

1. Apply this plugin to a project :D
2. Define the dependencies for the transformer tool (this is exposed to allow easier updating)
3. Substitute dependencies as specified
4. Apply shadowing to the `hibernate-core` JPA provider. The produced artifacts are named based on
the shadow project's dependency details (group, name, version).
5. Present the transformed artifact(s) as this project's published artifacts

[NOTE]
----
I did try to https://github.com/eclipse/transformer/issues/146[contribute] this back to the upstream Jakarta project but
never got a reply, so I simply implement the requirements for the Hibernate projects.

For a more complete implementation, e.g., we would support "selections", "bundles" and other Transformer / JakartaTransformer
options. However, this plugin simply supports the options needed for Hibernate builds.
----