Conflicting versions of datanucleus enhancer in a maven google app engine project

后端 未结 6 549
南方客
南方客 2020-12-09 09:54

I\'m having a problem setting up datanucleus enhancer to use with a google app engine project. If I use the datanucleus eclipse plugin everything goes well, but in my maven

相关标签:
6条回答
  • 2020-12-09 10:14

    Maven-datanucleus-plugin has stopped pulling in the latest versions of the available datanucleus-core since version 3.1.1.

    Check the differences between the POM files for Maven-datanucleus-plugin 3.1.1 (http://repo1.maven.org/maven2/org/datanucleus/maven-datanucleus-plugin/3.1.1/maven-datanucleus-plugin-3.1.1.pom) and 3.1.0-release (http://mvnrepository.com/artifact/org.datanucleus/maven-datanucleus-plugin/3.1.0-release).

    For maven-datanucleus-plugin 3.1.1 the version range of datanucleus-core dependency is (3.0.99, 3.1.99), and for maven-datanucleus-plugin 3.1.0-release it is (3.0.99, ). No wonder for the older versions of maven-datanucleus-plugin, it automatically pulls in the latest versions of datanucleus-core.

    0 讨论(0)
  • 2020-12-09 10:20

    I ran into the same issue while testing a maven gae plugin archetype.

    I fixed it by adding exclusions in my gae runtime transitive dependencies

    <!-- Google App Engine meta-package -->
            <dependency>
                <groupId>net.kindleit</groupId>
                <artifactId>gae-runtime</artifactId>
                <version>${gae.version}</version>
                <type>pom</type>
                <exclusions>
                    <exclusion>
                        <groupId>com.google.appengine.orm</groupId>
                        <artifactId>datanucleus-core</artifactId>
                    </exclusion>
    
                </exclusions>
            </dependency>
    

    and then adding the nucleus core as a runtime dependency

    <dependency>
                <groupId>org.datanucleus</groupId>
                <artifactId>datanucleus-core</artifactId>
                <version>${datanucleus-core.version}</version>
                <scope>runtime</scope>
                <exclusions>
                    <exclusion>
                        <groupId>javax.transaction</groupId>
                        <artifactId>transaction-api</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
    

    as keeping the gae plugin section simple:

    <plugin>
                    <groupId>org.datanucleus</groupId>
                    <artifactId>maven-datanucleus-plugin</artifactId>
                    <version>${maven-datanucleus-plugin.version}</version>
                    <configuration>
                        <!--
                            Make sure this path contains your persistent classes!
                        -->
                        <mappingIncludes>**/model/*.class</mappingIncludes>
                        <verbose>true</verbose>
                        <enhancerName>ASM</enhancerName>
                        <api>JDO</api>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>compile</phase>
                            <goals>
                                <goal>enhance</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
    
    0 讨论(0)
  • 2020-12-09 10:24

    The DN M2 plugin pulls in the latest versions of the available DN jars that it needs to do its job (there is no other sensible way to do it other than use the latest). You want to restrict "core" to a different version, either by specifying the plugin dependency of core, or by specifying that in your application to

    <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-core</artifactId>
        <version>1.1.0</version>
        <scope>runtime</scope> 
    </dependency>
    
    0 讨论(0)
  • 2020-12-09 10:32

    Unfortunately the answer is "hidden" in the comments:

    <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-core</artifactId>
        <version>1.1.0</version>
        <scope>runtime</scope>
    </dependency>
    

    That worked for me!

    0 讨论(0)
  • 2020-12-09 10:34

    After reading "How to override a plugin's dependency in Maven", I found another way to fix this. Here is my POM:

    <plugin>
      <groupId>org.datanucleus</groupId>
      <artifactId>maven-datanucleus-plugin</artifactId>
      <version>3.1.0-m3</version>
      <configuration>
        <verbose>true</verbose>
      </configuration>
    
      <executions>
        <execution>
          <phase>process-classes</phase>
          <goals>
            <goal>enhance</goal>
          </goals>
        </execution>
      </executions>
    
      <dependencies>
        <dependency>
          <groupId>org.datanucleus</groupId>
          <artifactId>datanucleus-core</artifactId>
          <version>3.0.4</version>
        </dependency>
      </dependencies>
    </plugin>
    
    0 讨论(0)
  • 2020-12-09 10:39

    clearing your old version of datanucleus from your local maven repository also solving the problem.

    0 讨论(0)
提交回复
热议问题