Skip to content

Commit

Permalink
[#542] Make use of Java 9 features by using the MR JAR feature to all…
Browse files Browse the repository at this point in the history
…ow running on Java 11. Fixes #542. Fix mixed nested collection update
  • Loading branch information
beikov committed May 3, 2018
1 parent f2906cb commit de62017
Show file tree
Hide file tree
Showing 85 changed files with 2,382 additions and 315 deletions.
187 changes: 77 additions & 110 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ cache:
before_install:
- sh -c "if [ '$RDBMS' = 'firebird' ]; then sh travis/before_install_firebird.sh; fi"
install:
- sh -c "if [ '$LATEST_MAVEN' = 'true' ]; then sh travis/install_latest_maven.sh; fi"
# Skip the first maven execution for downloading dependencies by using this command
- /bin/true
before_script:
- sh -c "if [ '$RDBMS' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS test DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_bin;'; fi"
- sh -c "if [ '$RDBMS' = 'postgresql' ]; then psql -c 'create database test;' -U postgres; fi"
Expand Down Expand Up @@ -402,128 +403,94 @@ matrix:
################################################
# JDK 9+
################################################
- env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=10 LATEST_MAVEN=true
- env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=10
before_install:
- wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
- . ./install-jdk.sh -F 10 -L GPL
- env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=11 LATEST_MAVEN=true
- env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=11
before_install:
- wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
- . ./install-jdk.sh -F 11 -L BCL
- env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=10 BUILD_JDK=10 LATEST_MAVEN=true
- env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=10 BUILD_JDK=10
before_install:
- wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
- . ./install-jdk.sh -F 10 -L GPL
- env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=11 BUILD_JDK=11 LATEST_MAVEN=true
- env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=11 BUILD_JDK=11
before_install:
- wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
- . ./install-jdk.sh -F 11 -L BCL
- env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=9 LATEST_MAVEN=true
addons:
apt:
packages:
- oracle-java9-installer
jdk: oraclejdk9
- env: JPAPROVIDER=datanucleus-5 RDBMS=h2 JDK=9 LATEST_MAVEN=true
addons:
apt:
packages:
- oracle-java9-installer
jdk: oraclejdk9
- env: JPAPROVIDER=eclipselink RDBMS=h2 JDK=9 LATEST_MAVEN=true
addons:
apt:
packages:
- oracle-java9-installer
jdk: oraclejdk9
# - env: JPAPROVIDER=hibernate-5.3 RDBMS=h2 JDK=9 LATEST_MAVEN=true
# addons:
# apt:
# packages:
# - oracle-java9-installer
# jdk: oraclejdk9
# - env: JPAPROVIDER=datanucleus-5.1 RDBMS=h2 JDK=9 LATEST_MAVEN=true
# addons:
# apt:
# packages:
# - oracle-java9-installer
# jdk: oraclejdk9
- env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=9
before_install:
- wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
- . ./install-jdk.sh -F 9 -L GPL
- env: JPAPROVIDER=datanucleus-5 RDBMS=h2 JDK=9
before_install:
- wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
- . ./install-jdk.sh -F 9 -L GPL
- env: JPAPROVIDER=eclipselink RDBMS=h2 JDK=9
before_install:
- wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
- . ./install-jdk.sh -F 9 -L GPL
# - env: JPAPROVIDER=hibernate-5.3 RDBMS=h2 JDK=9
# before_install:
# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
# - . ./install-jdk.sh -F 9 -L GPL
# - env: JPAPROVIDER=datanucleus-5.1 RDBMS=h2 JDK=9
# before_install:
# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
# - . ./install-jdk.sh -F 9 -L GPL
################################################
# Skip JDK 9 profile combinations for older JPA provider versions
################################################
# - env: JPAPROVIDER=hibernate-5.1 RDBMS=h2 JDK=9 LATEST_MAVEN=true
# addons:
# apt:
# packages:
# - oracle-java9-installer
# jdk: oraclejdk9
# - env: JPAPROVIDER=hibernate-5.0 RDBMS=h2 JDK=9 LATEST_MAVEN=true
# addons:
# apt:
# packages:
# - oracle-java9-installer
# jdk: oraclejdk9
# - env: JPAPROVIDER=hibernate-4.3 RDBMS=h2 JDK=9 LATEST_MAVEN=true
# addons:
# apt:
# packages:
# - oracle-java9-installer
# jdk: oraclejdk9
# - env: JPAPROVIDER=hibernate-4.2 RDBMS=h2 JDK=9 LATEST_MAVEN=true
# addons:
# apt:
# packages:
# - oracle-java9-installer
# jdk: oraclejdk9
# - env: JPAPROVIDER=datanucleus-4 RDBMS=h2 JDK=9 LATEST_MAVEN=true
# addons:
# apt:
# packages:
# - oracle-java9-installer
# jdk: oraclejdk9
# - env: JPAPROVIDER=hibernate-5.1 RDBMS=h2 JDK=9
# before_install:
# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
# - . ./install-jdk.sh -F 9 -L GPL
# - env: JPAPROVIDER=hibernate-5.0 RDBMS=h2 JDK=9
# before_install:
# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
# - . ./install-jdk.sh -F 9 -L GPL
# - env: JPAPROVIDER=hibernate-4.3 RDBMS=h2 JDK=9
# before_install:
# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
# - . ./install-jdk.sh -F 9 -L GPL
# - env: JPAPROVIDER=hibernate-4.2 RDBMS=h2 JDK=9
# before_install:
# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
# - . ./install-jdk.sh -F 9 -L GPL
# - env: JPAPROVIDER=datanucleus-4 RDBMS=h2 JDK=9
# before_install:
# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
# - . ./install-jdk.sh -F 9 -L GPL
allow_failures:
- env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=10 BUILD_JDK=10 LATEST_MAVEN=true
- env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=11 BUILD_JDK=11 LATEST_MAVEN=true
- env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=11 LATEST_MAVEN=true
# - env: JPAPROVIDER=hibernate-5.3 RDBMS=h2 JDK=9 LATEST_MAVEN=true
# addons:
# apt:
# packages:
# - oracle-java9-installer
# jdk: oraclejdk9
# - env: JPAPROVIDER=datanucleus-5.1 RDBMS=h2 JDK=9 LATEST_MAVEN=true
# addons:
# apt:
# packages:
# - oracle-java9-installer
# jdk: oraclejdk9
# - env: JPAPROVIDER=hibernate-5.1 RDBMS=h2 JDK=9 LATEST_MAVEN=true
# addons:
# apt:
# packages:
# - oracle-java9-installer
# jdk: oraclejdk9
# - env: JPAPROVIDER=hibernate-5.0 RDBMS=h2 JDK=9 LATEST_MAVEN=true
# addons:
# apt:
# packages:
# - oracle-java9-installer
# jdk: oraclejdk9
# - env: JPAPROVIDER=hibernate-4.3 RDBMS=h2 JDK=9 LATEST_MAVEN=true
# addons:
# apt:
# packages:
# - oracle-java9-installer
# jdk: oraclejdk9
# - env: JPAPROVIDER=hibernate-4.2 RDBMS=h2 JDK=9 LATEST_MAVEN=true
# addons:
# apt:
# packages:
# - oracle-java9-installer
# jdk: oraclejdk9
# - env: JPAPROVIDER=datanucleus-4 RDBMS=h2 JDK=9 LATEST_MAVEN=true
# addons:
# apt:
# packages:
# - oracle-java9-installer
# jdk: oraclejdk9
- env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=10 BUILD_JDK=10
- env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=11 BUILD_JDK=11
- env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=11
# - env: JPAPROVIDER=hibernate-5.3 RDBMS=h2 JDK=9
# before_install:
# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
# - . ./install-jdk.sh -F 9 -L GPL
# - env: JPAPROVIDER=datanucleus-5.1 RDBMS=h2 JDK=9
# before_install:
# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
# - . ./install-jdk.sh -F 9 -L GPL
# - env: JPAPROVIDER=hibernate-5.1 RDBMS=h2 JDK=9
# before_install:
# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
# - . ./install-jdk.sh -F 9 -L GPL
# - env: JPAPROVIDER=hibernate-5.0 RDBMS=h2 JDK=9
# before_install:
# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
# - . ./install-jdk.sh -F 9 -L GPL
# - env: JPAPROVIDER=hibernate-4.3 RDBMS=h2 JDK=9
# before_install:
# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
# - . ./install-jdk.sh -F 9 -L GPL
# - env: JPAPROVIDER=hibernate-4.2 RDBMS=h2 JDK=9
# before_install:
# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
# - . ./install-jdk.sh -F 9 -L GPL
# - env: JPAPROVIDER=datanucleus-4 RDBMS=h2 JDK=9
# before_install:
# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
# - . ./install-jdk.sh -F 9 -L GPL
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,15 @@ Setup local development

Here some notes about setting up a local environment for testing.

## Setup general build environment

Although Blaze-Persistence still supports running on Java 7, the build must be run with at least JDK 8.
When doing a release at least a JDK 9 is required as we need to build some Multi-Release or MR JARs.
Since we try to support the latest JDK versions as well, we require developers that want to build the project with JDK 11+ to define a system property.

The system property `jdk8.home` should be set to the path to a Java 7 or 8 installation that contains either `jre/lib/rt.jar` or `jre/lib/classes.jar`.
This property is necessary when using JDK 11+ because `sun.misc.Unsafe.defineClass` was removed.

## Building the website and documentation

You have to install [GraphViz](http://www.graphviz.org/Download.php) and make it available in your PATH.
Expand Down
26 changes: 17 additions & 9 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
#!/bin/bash
set -e
set -x

SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"

if [ "$JDK" != "" ]; then
MVN_BIN=/tmp/apache-maven/bin/mvn
export MAVEN_OPTS="-Xmx1024m -XX:MaxMetaspaceSize=512m" # --add-modules=java.se.ee"
elif [ "$LATEST_MAVEN" = "true" ]; then
MVN_BIN=/tmp/apache-maven/bin/mvn
export MAVEN_OPTS="-Xmx1024m -XX:MaxMetaspaceSize=512m" # --add-modules=java.se.ee"
else
MVN_BIN=mvn
export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=512m"
fi

if [ "$JDK" = "9" ]; then
export JAVA_HOME="/usr/lib/jvm/java-9-oracle/"
fi

${MVN_BIN} -version
mvn -version

PROPERTIES="$PROPERTIES -Duser.country=US -Duser.language=en"

if [ "$BUILD_JDK" != "" ]; then
PROPERTIES="$PROPERTIES -Dmaven.compiler.target=$BUILD_JDK -Dmaven.compiler.source=$BUILD_JDK"
PROPERTIES="$PROPERTIES -Djava.version=$BUILD_JDK"
fi

if [ "$JDK" != "" ]; then
PROPERTIES="$PROPERTIES -Djdk8.home=/usr/lib/jvm/java-8-oracle"
fi

if [ "$TRAVIS_REPO_SLUG" == "Blazebit/blaze-persistence" ] &&
[ "$TRAVIS_BRANCH" == "master" ] &&
[ "$JPAPROVIDER" == "hibernate-5.2" ] &&
[ "$RDBMS" == "h2" ]; then
exec ${MVN_BIN} -P ${JPAPROVIDER},${RDBMS},${SPRING_DATA:-spring-data-1.11.x},${DELTASPIKE:-deltaspike-1.7} install
exec mvn -P ${JPAPROVIDER},${RDBMS},${SPRING_DATA:-spring-data-1.11.x},${DELTASPIKE:-deltaspike-1.7} clean install -V $PROPERTIES
else
if [ "$TRAVIS_REPO_SLUG" == "Blazebit/blaze-persistence" ] &&
[ "$TRAVIS_BRANCH" == "master" ] &&
Expand All @@ -42,5 +50,5 @@ else
: # do nothing right now
fi

eval exec ${MVN_BIN} -P ${JPAPROVIDER},${RDBMS},${SPRING_DATA:-spring-data-1.11.x},${DELTASPIKE:-deltaspike-1.7} install --projects "core/testsuite,entity-view/testsuite,jpa-criteria/testsuite,integration/deltaspike-data/testsuite,integration/spring-data/testsuite,examples/spring-data-rest,examples/showcase/runner/spring,examples/showcase/runner/cdi" -am $PROPERTIES
eval exec mvn -P ${JPAPROVIDER},${RDBMS},${SPRING_DATA:-spring-data-1.11.x},${DELTASPIKE:-deltaspike-1.7} clean install --projects "core/testsuite,entity-view/testsuite,jpa-criteria/testsuite,integration/deltaspike-data/testsuite,integration/spring-data/testsuite,examples/spring-data-rest,examples/showcase/runner/spring,examples/showcase/runner/cdi" -am -V $PROPERTIES
fi
98 changes: 98 additions & 0 deletions core/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,102 @@
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<executions>
<execution>
<id>add-module-infos</id>
<phase>post-package</phase>
<goals>
<goal>add-module-info</goal>
</goals>
<configuration>
<version>${project.version}-module</version>
<module>
<moduleInfoSource>
module ${module.name} {
requires transitive java.sql;
requires transitive java.persistence;
exports com.blazebit.persistence;
exports com.blazebit.persistence.spi;
exports com.blazebit.persistence.internal;
uses com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider;
}
</moduleInfoSource>
</module>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>java9</id>
<activation>
<jdk>[1.9,)</jdk>
</activation>
<properties>
<jdkSpecificSourceDirectory>src/main/java9</jdkSpecificSourceDirectory>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>compile-java9</id>
<phase>compile</phase>
<configuration>
<tasks>
<mkdir dir="${project.build.outputDirectory}/META-INF/versions/9" />
<javac srcdir="${project.basedir}/src/main/java9" destdir="${project.build.outputDirectory}/META-INF/versions/9"
classpath="${project.build.outputDirectory}" includeantruntime="false" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<archive>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
<execution>
<id>modular-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>module</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Loading

0 comments on commit de62017

Please sign in to comment.