Maven Enhancement Not Kicking In

177 views
Skip to first unread message

montanajava

unread,
Aug 5, 2017, 3:10:14 AM8/5/17
to Ebean ORM
I am quite sure I am doing something wrong as I only see very old entries about this topic and no one else seems to have this problem. The issue is that sometimes the maven enhancement plugin works, sometimes it does not. Worst type of problem, really, being non-deterministic.

Anyway, I have a mixed Java/Kotlin project. I took the https://github.com/ebean-orm-examples/example-minimal project from GitHub and used that as a starting point. I updated the versions of the dependencies based on the information on this page:

http://ebean-orm.github.io/releases  which referred me to
http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22io.ebean%22

Kotlin classes are in the same folder as Java classes, in case that could somehow be a problem.

javap Customer.class reveals sometimes enhanced, sometimes not. Enhancement is supposed to happen in the compile goal automatically, is it not?

Anyone see any glaring problem?

Thanks in advance.

The properties:

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <java.version>1.8</java.version>
        <!--<ebean-maven-plugin.args>debug=2</ebean-maven-plugin.args>-->
        <ebean.version>10.4.2</ebean.version>
        <kotlin.version>1.1.3-2</kotlin.version>

        <ebeanorm-enhancement.plugin.args>debug=0</ebeanorm-enhancement.plugin.args>
        <querybean-maven-plugin.version>2.1.1</querybean-maven-plugin.version>
        <avaje-ebeanorm-mavenenhancer.version>4.9.1</avaje-ebeanorm-mavenenhancer.version>
        <kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
    </properties>


The dependencies:

        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
            <version>${kotlin.version}</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.20</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.25</version>
            <scope>test</scope>
        </dependency>


        <!-- https://mvnrepository.com/artifact/io.ebean/ebean -->
        <!-- https://mvnrepository.com/artifact/io.ebean/ebean -->
        <dependency>
            <groupId>io.ebean</groupId>
            <artifactId>ebean</artifactId>
            <version>${ebean.version}</version>
        </dependency>

        <dependency>
            <groupId>io.ebean</groupId>
            <artifactId>ebean-maven-plugin</artifactId>
            <version>10.4.1</version>
        </dependency>

        <!-- optionally add query beans -->
        <dependency>
            <groupId>io.ebean</groupId>
            <artifactId>ebean-querybean</artifactId>
            <version>10.3.1</version>
        </dependency>

        <dependency>
            <groupId>io.ebean</groupId>
            <artifactId>kotlin-querybean-generator</artifactId>
            <version>10.1.2</version>
        </dependency>


        <dependency>
            <groupId>io.ebean</groupId>
            <artifactId>querybean-generator</artifactId>
            <version>10.2.1</version>
        </dependency>

        <dependency>
            <groupId>io.ebean</groupId>
            <artifactId>ebean-annotation</artifactId>
            <version>2.3</version>
        </dependency>

        <dependency>
            <groupId>io.ebean</groupId>
            <artifactId>persistence-api</artifactId>
            <version>2.2.1</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/junit/junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>




The plugins I have activated:

             <plugin>
                <artifactId>kotlin-maven-plugin</artifactId>
                <groupId>org.jetbrains.kotlin</groupId>
                <version>${kotlin.version}</version>

                <executions>
                    <execution>
                        <id>compile</id>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>

                    <execution>
                        <id>test-compile</id>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>


            <plugin>
                <groupId>org.avaje.ebean</groupId>
                <artifactId>ebean-maven-plugin</artifactId>
                <version>8.2.1</version>
                <executions>
                    <execution>
                        <id>main</id>
                        <phase>process-classes</phase>
                        <configuration>
                            <transformArgs>debug=1</transformArgs>
                        </configuration>
                        <goals>
                            <goal>enhance</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Rob Bygrave

unread,
Aug 5, 2017, 6:38:31 PM8/5/17
to ebean@googlegroups
So it could be that you need to install the intelliJ ebean enhancement plugin.

That is, during development it is most often the case that sometimes the IDE does the compile and sometimes maven.  In this case ... We need the intelliJ plugin to do the enhancement when the IDE does the compile.

There is an IDE enhancement plugin for IDEA and Eclipse.

Cheers, Rob.

--

---
You received this message because you are subscribed to the Google Groups "Ebean ORM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ebean+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rob Bygrave

unread,
Aug 5, 2017, 6:48:31 PM8/5/17
to ebean@googlegroups
Note that we should use io.ebean for everything.  I see the maven-enhance-plugin ... Is an old one (org.avaje) ... So that might actually be the problem you are seeing (as the old one looks for and uses the different package - org.avaje etc).

Also note there is a example-kotlin project that I think closely matches what you want (uses src/main/kotlin though).  It uses a maven tile ... And hooks up KAPT for the Kotlin query bean generation.

I believe I updated that example just the other night.

montanajava

unread,
Aug 7, 2017, 1:42:27 AM8/7/17
to Ebean ORM
Hi Rob,

Swapped out the package name as recommended and things are now working almost entirely as expected.

There is still one exception:

QueryBeans for kotlin entities are not being created when using the maven plugin (I have a maven-based build, not gradle. This does work when using the kotlin example.)  I have the added the kotlin-querybean-generator. Is this possible with maven?


Thanks for taking a look!

Steve

P.S. On the ebean website it still references the old package. That was where I may have went wrong.

http://ebean-orm.github.io/docs/setup/enhancement

 <groupId>org.avaje.ebean</groupId>
To unsubscribe from this group and stop receiving emails from it, send an email to ebean+un...@googlegroups.com.

Rob Bygrave

unread,
Aug 7, 2017, 3:44:18 AM8/7/17
to ebean@googlegroups

QueryBeans for kotlin entities are not being created when using the maven plugin (I have a maven-based build, not gradle. This does work when using the kotlin example.)  I have the added the kotlin-querybean-generator. Is this possible with maven?

This this works with Maven. (Gradle folks should note that KAPT with Kotlin query beans doesn't really work well with Gradle at the moment - its a pain).

Note that I have just done another push to 'example-kotlin' which uses entity beans written in Kotlin, uses Kapt to generate Kotlin specific query beans ... and as such is the "full monty" Kotlin + Ebean + query beans + maven example.

The thing to note is that it expects src/main/kotlin so people might want to adjust that via properties for a mixed java/kotlin code base.

This does use maven tiles which promotes a more DRY approach wrt project poms.  People can look at mvn help:effective-pom ... or view the tile source at:  https://github.com/ebean-orm-tools/ebean-kotlin-kapt/blob/master/tile.xml ... to see more specifically what it does - kapt configuration etc.

Of course people can also adjust / use a parent pom hierarchy to promote DRY build poms instead of using tiles.

In summary, yes we are all good with Kotlin + maven.


Cheers, Rob.





To unsubscribe from this group and stop receiving emails from it, send an email to ebean+unsubscribe@googlegroups.com.

montanajava

unread,
Aug 7, 2017, 11:01:39 AM8/7/17
to Ebean ORM
Checked it out and it worked! Thanks much.

I do wonder about this: nKotlin is being enhanced perfectly, but my Java entities not. I realize that is potentially uncommon -- most people probably do Kotlin or one do Java. Me, I mix them as I move gradually into the Kotlin world. :-)  I am thinking I am not unusual in that respect.

So, as per your recommendation, I put my Java classes in a Java directory -- that is, I am keeping the kotlin and Java code apart, but I do reference back and forth, inheritance and so on, if that makes sense.

Is this a simple configuration issue, do you think?

montanajava

unread,
Aug 7, 2017, 12:38:09 PM8/7/17
to Ebean ORM
I fear I was insufficiently precise:

Enhancement: That worked for Kotlin and for Java.

Generation: That worked only for Kotlin.

Rob Bygrave

unread,
Aug 9, 2017, 3:57:15 AM8/9/17
to ebean@googlegroups
So, as per your recommendation, I put my Java classes in a Java directory

Careful there in that ... I don't know what is best in the Java + Kotlin scenario. For me I think it is tempting to put both .java and .kt source in the same src/main/java say.  I say that because I personally find it slightly painful when source is split into the 2 separate top level source directories (with java and groovy).

So don't be afraid of doing it either way really.


Enhancement: That worked for Kotlin and for Java.

There should be no issue there assuming both compile into the same target/classes and target/test-classes directories.  That is, the maven enhancement processes the .class files it finds in the target/classes and target/test-classes directories.

It should be a matter of doing:  mvn clean process-test-classes and reviewing the log messages and seeing the right enhancement going on.


Generation: That worked only for Kotlin.

Generation of query beans right. I presume that works, I don't know why it would not.  The APT (Java) works automatically and the KAPT (Kotlin) needs the explicit configuration so it should be that KAPT only processes the Kotlin compiled entity beans.


You could look to put a simple example somewhere (github?) if it isn't working as expected.


Cheers, Rob.


  

To unsubscribe from this group and stop receiving emails from it, send an email to ebean+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages