Error compiling a modular maven project with modular java 10

2

I am adapting the exercise of the book "Java 9 - Interactive, reactive and modularized - author Rodrigo Turini" for a modular maven project with modular java 10. But this is giving error when compiling the second module (http)

msartor@msartor-Latitude-E6440 ~/AmbienteDeDesenvolvimento/Projetos/Cursos/Java9/bookstore $ mvn install -Dmaven.test.skip=true
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] bookstore                                                          [pom]
[INFO] domain                                                             [jar]
[INFO] http                                                               [jar]
[INFO] nf                                                                 [jar]
[INFO] app                                                                [jar]
[INFO] 
[INFO] -------------------< br.com.casadocodigo:bookstore >--------------------
[INFO] Building bookstore 1.0.0                                           [1/5]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.0.2.RELEASE:repackage (default) @ bookstore ---
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ bookstore ---
[INFO] Installing /home/msartor/AmbienteDeDesenvolvimento/Projetos/Cursos/Java9/bookstore/pom.xml to /home/msartor/.m2/repository/br/com/casadocodigo/bookstore/1.0.0/bookstore-1.0.0.pom
[INFO] 
[INFO] ---------------------< br.com.casadocodigo:domain >---------------------
[INFO] Building domain 1.0.0                                              [2/5]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ domain ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ domain ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 3 source files to /home/msartor/AmbienteDeDesenvolvimento/Projetos/Cursos/Java9/bookstore/domain/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ domain ---
[INFO] Not copying test resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ domain ---
[INFO] Not compiling test sources
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ domain ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ domain ---
[INFO] Building jar: /home/msartor/AmbienteDeDesenvolvimento/Projetos/Cursos/Java9/bookstore/domain/target/domain-1.0.0.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.0.2.RELEASE:repackage (default) @ domain ---
[INFO] Attaching archive: /home/msartor/AmbienteDeDesenvolvimento/Projetos/Cursos/Java9/bookstore/domain/target/domain-1.0.0-exec.jar, with classifier: exec
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ domain ---
[INFO] Installing /home/msartor/AmbienteDeDesenvolvimento/Projetos/Cursos/Java9/bookstore/domain/target/domain-1.0.0.jar to /home/msartor/.m2/repository/br/com/casadocodigo/domain/1.0.0/domain-1.0.0.jar
[INFO] Installing /home/msartor/AmbienteDeDesenvolvimento/Projetos/Cursos/Java9/bookstore/domain/pom.xml to /home/msartor/.m2/repository/br/com/casadocodigo/domain/1.0.0/domain-1.0.0.pom
[INFO] Installing /home/msartor/AmbienteDeDesenvolvimento/Projetos/Cursos/Java9/bookstore/domain/target/domain-1.0.0-exec.jar to /home/msartor/.m2/repository/br/com/casadocodigo/domain/1.0.0/domain-1.0.0-exec.jar
[INFO] 
[INFO] ----------------------< br.com.casadocodigo:http >----------------------
[INFO] Building http 1.0.0                                                [3/5]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ http ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ http ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] bookstore 1.0.0 .................................... SUCCESS [  1.013 s]
[INFO] domain ............................................. SUCCESS [  1.226 s]
[INFO] http ............................................... FAILURE [  0.046 s]
[INFO] nf ................................................. SKIPPED
[INFO] app 1.0.0 .......................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.426 s
[INFO] Finished at: 2018-05-20T16:27:36-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project http: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile failed.: IllegalArgumentException -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :http

parent project pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <groupId>br.com.casadocodigo</groupId>
  <artifactId>bookstore</artifactId>
  <version>1.0.0</version>
  <packaging>pom</packaging>



  <modules>

    <module>domain</module>
    <module>http</module>
    <module>nf</module>
    <module>app</module>

  </modules>

  <properties>
    <java.version>10</java.version>
    <start-class>br.com.casadocodigo.MainModulo</start-class>
    <maven-compiler-pluging.version>3.7.0</maven-compiler-pluging.version>
    <spring-boot.version>2.0.2.RELEASE</spring-boot.version>
  </properties>


  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-pluging.version}</version>
                <configuration>
                    <source>10</source>
                    <target>10</target>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>

        </plugins>
    </build>

</project>

project pom domain

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>br.com.casadocodigo</groupId>
    <version>1.0.0</version>
    <artifactId>bookstore</artifactId>
  </parent>

  <artifactId>domain</artifactId>
  <packaging>jar</packaging>

</project>

http project pom

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>br.com.casadocodigo</groupId>
    <version>1.0.0</version>
    <artifactId>bookstore</artifactId>
  </parent>

  <artifactId>http</artifactId>
  <packaging>jar</packaging>

  <dependencies>
    <dependency>
        <groupId>br.com.casadocodigo</groupId>
        <artifactId>domain</artifactId>
        <version>1.0.0</version>
    </dependency>

  </dependencies>   

</project>

nf project pom

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>br.com.casadocodigo</groupId>
    <version>1.0.0</version>
    <artifactId>bookstore</artifactId>
  </parent>

  <artifactId>nf</artifactId>
  <packaging>jar</packaging>

  <dependencies>
    <dependency>
        <groupId>br.com.casadocodigo</groupId>
        <artifactId>domain</artifactId>
        <version>1.0.0</version>
    </dependency>
  </dependencies>

</project>

app project pom

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>br.com.casadocodigo</groupId>
    <version>1.0.0</version>
    <artifactId>bookstore</artifactId>
  </parent>

  <artifactId>app</artifactId>
  <packaging>jar</packaging>

  <dependencies>
    <dependency>
        <groupId>br.com.casadocodigo</groupId>
        <artifactId>domain</artifactId>
        <version>1.0.0</version>
    </dependency>
    <dependency>
        <groupId>br.com.casadocodigo</groupId>
        <artifactId>http</artifactId>
        <version>1.0.0</version>
    </dependency>

    <dependency>
        <groupId>br.com.casadocodigo</groupId>
        <artifactId>nf</artifactId>
        <version>1.0.0</version>
    </dependency>

  </dependencies>

</project>

Each project has its module-info.java See below.

module-info domain

module domain {
    exports br.com.casadocodigo.domain;
}

module-info http

module http {
    exports br.com.casadocodigo.http;

    requires domain;
    requires jdk.incubator.httpclient;
}

module-info nf

module nf {
    exports br.com.casadocodigo.service;
    exports br.com.casadocodigo.model;

    requires domain;
}

module-info app

module app {
    exports br.com.casadocodigo;

    requires domain;
    requires http;
    requires nf;
}

continues

For those who want to see the code in its entirety, the same is in my github link

    
asked by anonymous 20.05.2018 / 21:37

1 answer

2

The maven-compiler-plugin plugin uses the ASM library, but only the most current versions are able to interpret bytecode from version 10.

The central POM should be changed with the following configuration:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-pluging.version}</version>
                <configuration>
                    <source>10</source>
                    <target>10</target>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.ow2.asm</groupId>
                        <artifactId>asm</artifactId>
                        <version>6.1.1</version> 
                    </dependency>
                </dependencies>
            </plugin>
    
31.05.2018 / 04:19