vivo-project / VIVO

VIVO is an extensible semantic web application for research discovery and showcasing scholarly work
http://vivoweb.org
BSD 3-Clause "New" or "Revised" License
205 stars 127 forks source link

Infrastructure improvements - Migration to Java 11 from Java 8 #3836

Open michel-heon opened 1 year ago

michel-heon commented 1 year ago

VIVO GitHub issue 3834: (please link to issue) see also for vitro https://github.com/vivo-project/Vitro/pull/368

What does this pull request do?

This PR modifies the pom files so that VIVO and Vitro are compiled and run with Java 11

What's new?

Replacing
            <configuration>
                <source>JAVA_RELEASE</source>
                <target>JAVA_RELEASE</target>
            </configuration>
by
        <maven.compiler.release>JAVA_RELEASE</maven.compiler.release> 
in top pom file

Addition in Vitro a code segment that aborts the compilation if the configuration is in Java-8 
(Vitro/api/src/test/java/compilation/IsNotCompatibleWithJava8.java)

Adding an echo mechanism for maven properties

Change project.version to 1.14.1-SNAPSHOT

How should this be tested?

  1. Purge the maven downloaded library directory rm -fr ~/.m2/repository

  2. Install Java 11

  3. Install SOLR and Tomcat according to https://wiki.lyrasis.org/display/VIVODOC113x/Installing+VIVO

  4. Configure runtime.properties and applicationSetup.n3

  5. Extracted VIVO and Vitro concerned by this PR

  6. copy this settings.xml in ./VIVO/installer directory

    <settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
    <profiles>
        <profile>
            <id>defaults</id>
            <properties>
                <app-name>${env.APP_NAME}</app-name>
                <vivo-dir>${env.VIVO_HOME}/home</vivo-dir>
                <tomcat-dir>${env.TOMCAT_HOME}</tomcat-dir>
                <default-theme>${env.VIVO_THEME}</default-theme>
                <maven.compiler.release>${env.JAVA_RELEASE}</maven.compiler.release>
            </properties>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>defaults</activeProfile>
    </activeProfiles>
    </settings>
  7. set environment variables indicated in settings.xml

    # Example
    export APP_NAME=vivo
    export VIVO_HOME=/opt/vivo/home
    export TOMCAT_HOME=/opt/tomcat
  8. Check incompatibility with Java-8

    # Run the following commands
    export JAVA_RELEASE=8
    cd $VIVO
    mvn clean install -DskipTests=false -s installer/settings.xml

    Overview of the output During the execution, it is possible to follow the following trace in the maven logs

    [INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ vivo-home ---
    [INFO] Deleting /home/ubuntu/VIVO_LYRSAIS_TEST/00-GIT/VIVO/home/target
    [INFO] Skipping artifact installation
    [INFO] 
    [INFO] --- maven-antrun-plugin:3.1.0:run (echo-properties) @ vivo-home ---
    [INFO] Executing tasks
    [WARNING]      [echo] ###################################################################
    [WARNING]      [echo] Displaying value of 'vivo-home' properties
    [WARNING]      [echo] ###################################################################
    [WARNING]      [echo] [app-name]                   vivo
    [WARNING]      [echo] [vivo-dir]                   /opt/vivo/home
    [WARNING]      [echo] [tomcat-dir]                 /opt/tomcat
    [WARNING]      [echo] [default-theme]              wilma
    [WARNING]      [echo] [vitro-version]              1.14.1-SNAPSHOT
    [WARNING]      [echo] [vivo-version]               1.14.1-SNAPSHOT
    [WARNING]      [echo] [java.vendor.version]        Corretto-11.0.18.10.1
    [WARNING]      [echo] [java.version]               11.0.18
    [WARNING]      [echo] [java.specification.version] 11
    [WARNING]      [echo] [maven.compiler.release]     8
    [WARNING]      [echo] ###################################################################
    [WARNING]      [echo] ###################################################################
    [INFO] Executed tasks
    #
    # ... and later you will see
    #
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  27.057 s (Wall Clock)
    [INFO] Finished at: 2023-02-22T19:53:24Z
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:testCompile (default-testCompile) on project vitro-api: Compilation failure
    [ERROR] GIT/Vitro/api/src/test/java/compilation/IsNotCompatibleWithJava8.java:[14,32] error: cannot find symbol
    [ERROR]   symbol:   method isBlank()
    [ERROR]   location: variable value of type String

    The compilation aborts because the class code is not compatible with Java version 8

  9. Validate the VIVO/Vitro compilation with Java 11

    # Run the following commands
    export JAVA_RELEASE=11
    cd $VIVO
    mvn clean install -DskipTests=false -s installer/settings.xml

    Overview of the output During the execution, it is possible to follow the following trace in the maven logs

    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Summary for VIVO 1.14.1-SNAPSHOT:
    [INFO] 
    [INFO] Vitro .............................................. SUCCESS [ 27.836 s]
    [INFO] Vitro Dependencies ................................. SUCCESS [  0.296 s]
    [INFO] Vitro API .......................................... SUCCESS [01:08 min]
    [INFO] VIVO ............................................... SUCCESS [ 27.836 s]
    [INFO] VIVO API ........................................... SUCCESS [ 24.329 s]
    [INFO] Vitro Web App ...................................... SUCCESS [  2.606 s]
    [INFO] VIVO Web App ....................................... SUCCESS [  0.877 s]
    [INFO] Vitro Home ......................................... SUCCESS [  7.982 s]
    [INFO] VIVO Home .......................................... SUCCESS [  1.587 s]
    [INFO] Vitro Installer .................................... SUCCESS [  8.613 s]
    [INFO] Vitro Install Home ................................. SUCCESS [  0.006 s]
    [INFO] Vitro Install Web App .............................. SUCCESS [  2.523 s]
    [INFO] VIVO Installer ..................................... SUCCESS [  8.613 s]
    [INFO] VIVO Install Home .................................. SUCCESS [  2.053 s]
    [INFO] VIVO Install Web App ............................... SUCCESS [  2.519 s]
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  02:10 min (Wall Clock)
    [INFO] Finished at: 2023-02-22T20:09:02Z
    [INFO] ------------------------------------------------------------------------
  10. Testing execution in tomcat Before starting Tomcat, you can copy the samples data contained in https://github.com/vivo-project/sample-data/tree/main/i18n and copy it to $VIVO_HOME/rdf/abox/filegraph then

    start solr
    start tomcat

    You can navigate VIVO in your browser http://localhost:8080/vivo

You can validate that VIVO runs in TOMCAT in a Java-11 context with the following command

>head -20 $TOMCAT_HOME/logs/catalina.out
# Response
NOTE: Picked up JDK_JAVA_OPTIONS:  --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
Picked up _JAVA_OPTIONS: -Xms1024m -Xmx4048m
OpenJDK 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0
Listening for transport dt_socket at address: 8000
22-Feb-2023 19:09:29.590 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name:   Apache Tomcat/8.5.85
22-Feb-2023 19:09:29.594 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jan 11 2023 00:09:15 UTC
22-Feb-2023 19:09:29.594 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 8.5.85.0
22-Feb-2023 19:09:29.594 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux
22-Feb-2023 19:09:29.594 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            5.15.0-1030-aws
22-Feb-2023 19:09:29.594 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
22-Feb-2023 19:09:29.594 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /home/ubuntu/VIVO_LYRSAIS_TEST/00-GIT/vivo-studio/deploy/JDK
22-Feb-2023 19:09:29.594 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           11.0.18+10-LTS
22-Feb-2023 19:09:29.594 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Amazon.com Inc.
22-Feb-2023 19:09:29.595 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /home/ubuntu/VIVO_LYRSAIS_TEST/00-GIT/vivo-studio/deploy/tomcat
22-Feb-2023 19:09:29.595 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /home/ubuntu/VIVO_LYRSAIS_TEST/00-GIT/vivo-studio/deploy/tomcat
22-Feb-2023 19:09:29.596 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED

etc ...

Interested parties

@chenejac

chenejac commented 1 year ago

@michel-heon why did you change version to 1.14.1-SNAPSHOT? Change of the version is usually done by a script when a new release is published.

michel-heon commented 1 year ago

@chenejac Because version 1.13.1-SNAPSHOT does not reflect where we are in development and it is often confusing to work on branches that do not correspond to the working version

michel-heon commented 1 year ago

@litvinovg The return to 1.13.1 is done.... but this version corresponds to the previous sprint and is not representative of the evolution of development. This version misalignment may lead to misunderstandings about the evolution of the development.

michel-heon commented 1 year ago

@litvinovg , Why do a test on an OS installation based on Java 8 when the basic specification of this issue is to use Java 11 ?

litvinovg commented 1 year ago

@michel-heon To model what user trying to update VIVO or Vitro to next version would experience.

michel-heon commented 1 year ago

@litvinovg @chenejac The files have been changed as discussed

litvinovg commented 1 year ago

I don't remember discussion about maven enforcer. I think increasing version of maven enforcer and enforcing maven version is unnecessary.