2
I am adapting the exercise of the book "Java 9 - Interactive, reactive and modularized - author Rodrigo Turini" to a modular Maven project with java 10 modular. However this gives 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
pom from the parent project
<?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>
pom from the Domain project
<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>
pom of the http project
<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>
pom from the nf project
<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 design 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 Goes 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 full, the same is in my github https://github.com/marcelosartor/Estudo-Java10_Modular-Com-Maven_Modular
This dependency solves my build problem. See if you can still help me. When running I have the following error. Exception in thread "main" java.lang.Noclassdeffounderror: br/com/casadocodigo/http/Books at br.com.casadocodigo.MainMavenModulo.main(Mainmavenmodulo.java:16) Caused by: java.lang.Classnotfoundexception: br.com.casadocodigo.http.Books at
– Marcelo
Ask another question with this new problem, I can take a look. ;)
– Marcos Zolnowski
https://answall.com/questions/303939/projecto-maven-modular-com-java10-modular-n%C3%A3o-encontra-os-modulo-java
– Marcelo