Skip to content

hibernate/jakarta-transformer-plugin

Repository files navigation

JakartaTransformer Gradle plugin

Build Status

Plugin for integrating the 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.

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

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages