jigsaw

Where should I put unit tests when migrating a Java 8 project to Jigsaw

微笑、不失礼 提交于 2019-11-27 14:22:15
I am currently testing to migrate a Java 8 application to Java 9 / Jigsaw, using jdk-9+149. The project has been laid out in standard Maven directory layout, i.e. having src/main/java , src/test/java , etc. As soon as I add the module-info.java to src/main/java , maven-compiler-plugin fails throwing a NullPointerException. This is because it expects to find a module-info for the test directory, too. So, as far as I can see, the options are: keep test classes in a separate module, which means they can only access exported packages of the main module. move test classes into the main module,

Does the Java 9 Module system support optional dependencies?

≡放荡痞女 提交于 2019-11-27 12:12:34
问题 Background In maven, an artifact can declare a dependency with <optional>true</optional> which means that the dependency is not required, but can be used if present. The State of the Module System seems to specify that a module can only read modules it has required. Questions Does the Java 9 module system indeed not support optional dependencies? Why not? What alternatives to optional dependencies does the Java 9 module system provide? Use Case I have a framework that integrates various

Eclipse - module not found when adding module-info.java

只谈情不闲聊 提交于 2019-11-27 09:19:42
I have a simple hello world project in eclipse that I want to run with java 9. The program runs when I don't have a module-info.java file but when I add that file I get the following error: Error occurred during initialization of boot layer java.lang.module.FindException: Module modulefinder not found Steps to reproduce 1. Create a new maven project 2. Change compiler and build path jre to 9 3. Auto generate module-info.java 4. Update junit dependency in junit to 4.12 if eclipse complains 5. Run the project Is this an eclipse related issue or am I missing something when running the project?

How to use 3rd party library in Java9 module?

不羁的心 提交于 2019-11-27 08:26:05
I have some java9 module that uses 3rd party library that is not Java9 module, just a simple utility jar. However, the compiler complains that it can't find a package from my utility. What should I do in module-info.java to enable usage of my 3rd party library? You can use your library as an automatic module . An automatic module is a module that doesn't have a module descriptor (i.e. module-info.class ). But what name should you use to refer to this module? The name of the automatic module is derived from the JAR name (unless this JAR contains an Automatic-Module-Name attribute). The full

How to add org.eclipse.swt (and other plugin dependencies) as an automatic Java9 module?

社会主义新天地 提交于 2019-11-27 06:33:50
问题 In order to be able to use my Eclipse plugin "treezCore" also as a Java9 module I created a module-info.java in my src folder. Furthermore, I moved the Plug-in Dependencies from the Classpath to the Modulepath. I can see a module "org.eclipse.swt.3.106.1.v20170926" in the plugin dependencies: However, I am not able to reference that module in my module-info.java. I tried require org.eclipse.swt.3.106.1.v20170926; require org.eclipse.swt; require swt; None of those options worked. The jar file

What is an automatic module?

醉酒当歌 提交于 2019-11-27 04:37:48
Automatic modules are mentioned many times on stackoverflow but I couldn't find a complete, succinct and self-sufficient definition of an automatic module. So, what is an automatic module? Does it export all packages? Does it open all packages? Does it read all other modules? I first answer your actual question ("What is an automatic module?"), but I also explain what they are there for . It is hard to understand why automatic modules behave the way they do without that information. What is an automatic module? The module system creates a module from every JAR it finds on the module path. For

Eclipse - module not found when adding module-info.java

混江龙づ霸主 提交于 2019-11-27 04:01:03
问题 I have a simple hello world project in eclipse that I want to run with java 9. The program runs when I don't have a module-info.java file but when I add that file I get the following error: Error occurred during initialization of boot layer java.lang.module.FindException: Module modulefinder not found Steps to reproduce 1. Create a new maven project 2. Change compiler and build path jre to 9 3. Auto generate module-info.java 4. Update junit dependency in junit to 4.12 if eclipse complains 5.

How do you organize tests in a modular Java project?

依然范特西╮ 提交于 2019-11-27 02:51:11
问题 I am creating a modular build (using module-info.java) on GitHub, but when adding a module-info.java to the modules that I want modular, no tests can be executed... How can I achieve this? I am using the following versions: junit.jupiter version 5.3.0 (first take was also unsuccessful with version 5.2.0) maven-compiler-plugin version 3.8.0 (first take was also unsuccessful with version 3.7.0) maven-surefire-plugin version 2.22.0 (first take was also unsuccessful with version 2.21.0) A typical

Accessing resource files from external modules

自古美人都是妖i 提交于 2019-11-27 01:58:27
So far until non-modularized java, you would simply put a file in src/main/java/resources make sure it is in classpath and then load it with file = getClass().getClassLoader().getResourceAsStream("myfilename"); from pretty much anywhere in the classpath. Now with modules, the plot thickens. My project setup is the following: module playground.api { requires java.base; requires java.logging; requires framework.core; } Config file is placed inside src/main/resources/config.yml . Project is run with java -p target/classes:target/dependency -m framework.core/com.framework.Main Since the main class

Scanning classpath/modulepath in runtime in Java 9

一曲冷凌霜 提交于 2019-11-26 18:54:01
I can't seem to find any info on whether scanning all available classes (for interfaces, annotations etc) is still possible in runtime, the way Spring, Reflections and many other frameworks and libraries currently do, in the face of Jigsaw related changes to the way classes are loaded. EDIT : This question is about scanning the real physical file paths looking for classes. The other question is about dynamically loading classes and resources. It's related but very much not a duplicate . UPDATE : Jetty project has made a JEP proposal for a standardized API for this. If you have a way to help