Giter Site home page Giter Site logo

activejdbc-gradle-plugin's Introduction

ActiveJDBC Gradle plugin

Build Status

Gradle plugin for instrumenting your project's model classes for the ActiveJDBC ORM framework.

Version 2.0 of the plugin requires Gradle 7 or higher. Use version 1.5.2 for older Gradle versions.

The plugin has been tested with ActiveJDBC 2.0 to 2.6-j8.

Usage

Add the plugin in addition to Java plugin to the build.gradle file as follows:

plugins {
    id 'java'
    id 'de.schablinski.activejdbc-gradle-plugin' version '2.0.1'
}

This will create a task instrumentModels in the task group build which is added as doLast action to the compileJava task.

Configuration

The version of the ActiveJDBC instrumentation tool is determined by the plugin from the version of the activejdbc.jar used as compile or implementation dependency in the build script. For backward compatibility or as a last resort, the instrumentation tool version can be configured as follows:

activejdbc.toolVersion = '2.2'

If the ActiveJDBC model classes of the project have compile-time dependencies on 3rd-party libraries, they must be added to the activejdbc configuration (see example below).

dependencies {
    ...
    activejdbc 'org.scala-lang:scala-library:2.12.6'
    ...
}

Other JVM languages

Scala

To instrument ActiveJDBC model classes written in Scala, configure the plugin as shown in the build script below (Gradle >= 4.0):

plugins {
    id 'scala'
    id 'de.schablinski.activejdbc-gradle-plugin'
}   

dependencies {
    implementation 'org.scala-lang:scala-library:2.12.6'
    implementation 'org.javalite:activejdbc:2.3'
    
    activejdbc 'org.scala-lang:scala-library:2.12.6'
}

repositories {
    jcenter()
}

The Scala library must be added on the classpath of ActiveJDBC instrumentation tool (s. configuration activejdbc), because the model classes have a dependency on the Scala library.

Groovy

To instrument ActiveJDBC model classes written in Groovy, configure the plugin as shown in the build script below (Gradle >= 4.0):

plugins {
    id 'groovy'
    id 'de.schablinski.activejdbc-gradle-plugin'
}   

dependencies {
    implementation 'org.codehaus.groovy:groovy:2.4.15'
    implementation 'org.javalite:activejdbc:2.3'
    
    // The Groovy library is only required on the instrumentation classpath, if the model classes depend on the GDK
    // activejdbc 'org.codehaus.groovy:groovy:2.4.15'
}

repositories {
    jcenter()
}

JVM languages not yet supported supported by the plugin

The ActiveJDBC model instrumentation is executed by the task ActiveJDBCInstrumentation. An instance of this task is added as doLast-action to the task compileJava by the ActiveJDBC Gradle plugin, e.g.

This task can be used to instrument ActiveJDBC model classes written in JVM languages not yet supported by this plugin. First, a task of type ActiveJDBCInstrumentation must be created with its property classesDir set to the output directory of the language's compiler. Then, this task must be added as doLast-action to the language's compile-task.

The following build script snippet demonstrates these steps for Kotlin. A complete build script can be found in the Kotlin example project active-jdbc-gradle-kotlin-example at Github.

task instrumentKotlinModels(type: ActiveJDBCInstrumentation) {
    group = 'build'
    classesDir = "${project.buildDir}/classes/kotlin/main"
}

tasks['compileKotlin'].doLast {
    instrumentKotlinModels.instrument()
}

Attribution.

This project started as a hard fork of the gradle-plugin module of ActiveJDBC to make it available on Gradle's plugin portal.

activejdbc-gradle-plugin's People

Contributors

cschabl avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

jcabraham

activejdbc-gradle-plugin's Issues

Java 17 support?

Is Java 17 supported? Builds fine with 16 but with 17 I'm getting the following error on build:

groovy.lang.MissingPropertyException: Could not get unknown property 'out' for task ':sls:sls-server:instrumentModels' of type de.schablinski.gradle.activejdbc.ActiveJDBCInstrumentation.
at org.gradle.internal.metaobject.AbstractDynamicObject.getMissingProperty(AbstractDynamicObject.java:85)
at org.gradle.internal.metaobject.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:62)
at de.schablinski.gradle.activejdbc.ActiveJDBCInstrumentation_Decorated.getProperty(Unknown Source)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getGroovyObjectProperty(ScriptBytecodeAdapter.java:520)
at de.schablinski.gradle.activejdbc.ActiveJDBCInstrumentation.this$dist$get$3(ActiveJDBCInstrumentation.groovy)
at de.schablinski.gradle.activejdbc.ActiveJDBCInstrumentation$StdOutCaptor.propertyMissing(ActiveJDBCInstrumentation.groovy)
at [email protected]/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at [email protected]/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at [email protected]/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at [email protected]/java.lang.reflect.Method.invoke(Method.java:568)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaClassImpl.invokeMissingProperty(MetaClassImpl.java:879)
at groovy.lang.MetaClassImpl$10.getProperty(MetaClassImpl.java:2120)
at org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(GetEffectivePogoPropertySite.java:85)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:341)
at de.schablinski.gradle.activejdbc.ActiveJDBCInstrumentation$StdOutCaptor.close(ActiveJDBCInstrumentation.groovy:144)
at org.gradle.internal.concurrent.CompositeStoppable$2.stop(CompositeStoppable.java:90)
at org.gradle.internal.concurrent.CompositeStoppable.stop(CompositeStoppable.java:106)
at org.gradle.process.internal.streams.ExecOutputHandleRunner.forwardContent(ExecOutputHandleRunner.java:70)
at org.gradle.process.internal.streams.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:53)
at org.gradle.internal.operations.CurrentBuildOperationPreservingRunnable.run(CurrentBuildOperationPreservingRunnable.java:42)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at [email protected]/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at [email protected]/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at [email protected]/java.lang.Thread.run(Thread.java:833)

Check if the new update is needed for JavaLite 3.0

The new version of JavaLite 30 for Java 16 is being released. It has been already published to the Sonatype repos, and will appear there soon.

@cschabl see if the plugin needs an update - this is an FYI. The release is still in progress, with release notes to follow.

Plugin initialization fails if declared in plugins block

If the plugin is declared in the build script in the block plugins, plugin initialization fails although the java plugin is declared before. Example:

plugins {
    id "java"
    id "de.schablinski.activejdbc-gradle-plugin" version "1.0-beta-1"
}

The plugin must be declared the "legacy way":

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath group: 'de.schablinski.gradle.activejdbc', name: 'activejdbc-gradle-plugin', version: '1.0-beta-1'
    }
}

apply plugin: 'java'
apply plugin: 'de.schablinski.activejdbc-gradle-plugin'

UnsupportedClassVersionError with version 2.0.2

Hi,

we get the following issue when running our gradle builds:
java.lang.UnsupportedClassVersionError: de/schablinski/gradle/activejdbc/ActiveJDBCGradlePlugin has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0

We run our gradle builds with the settings (backwards compatibility for legacy platforms):
sourceCompatibility = 1.8
targetCompatibility = 1.8

and since version 2.0.2 our gradle builds do not run anymore. We switched back to version 2.0.1 for now, but is there something else we can do to use the latest version?

Kind regards,
Arjo Poldervaart

Add ability to instrument groovy class files

The instrumentor code looks for java and scala class files (classes/java/main and classes/scala/main) but not for classes in (classes/groovy/main). This is a shame because a) some people still use groovy for UI/DB development, and b) the plugin itself is written in groovy! Will try to create a PR myself for this, but might take a week.

Gradle 7 Support

Hello! I've made sure to check for other issues here before reporting this.

It appears that the compile configuration as present in the build.gradle of this project, and not implementation, is preventing compatibility with Gradle 7.1.

I believe it is a simple replacement, as Gradle's site documents here: https://docs.gradle.org/current/userguide/upgrading_version_6.html and here: https://i.imgur.com/Q0ucPVs.png however I am not very experienced in writing Gradle plugins at all. If you could take a look I would really appreciate it!

Fix missing slf4j implementation

When the instrumentation tool is executed by the plugin, the logging library SLF4J used by the instrumentation tool logs the following:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.