You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: plexus-java/src/site/markdown/locationmanager.md
+9-7
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
The plexus-java library is created to have a solution for common activities, so this business logic doesn't have to be maintained at multiple places. The first provided feature was the `LocationManager` to analyze module desciptors and to decide which jars should end up on the modulepath and which on the classpath. The name was based on the [javax.tools.JavaFileManager.Location]. (https://docs.oracle.com/javase/10/docs/api/javax/tools/JavaFileManager.Location.html)
2
2
3
-
The library requires Java 8 to run, but contains optimized code for Java 9. By requiring Java 8 it was much easier to embed this library in several other projects.
3
+
The library requires Java 8 to run, but contains optimized code for Java 9. By requiring Java 8 it was much easier to embed this library in several other projects.
4
4
5
5
This jar is a multi release jar (aka MRJAR), because it contains 2 implementations for the `BinaryModuleInfoParser`. If the Java runtime is 9 or above, the `java.lang.module.ModuleDescriptor` is used to read the `module-info.class`. If the runtime is Java 8, then ASM is used to read the module descriptor.
6
6
@@ -18,13 +18,13 @@ There are 3 ways to create a `ResolvePathsRequest`:
As argument you pass all the archives and/or outputDirectories specified to build the project.
21
+
As argument you pass all the archives and/or outputDirectories specified to build the project.
22
22
23
23
Additional methods are:
24
24
25
25
-`setAdditionalModules`, in case the consumer wants to use `--add-modules`
26
26
27
-
-`setIncludeAllProviders`, in general would only be used at runtime, not during compile or test. In case `uses` is used, all modules with matching `provides` are added as well.
27
+
-`setIncludeAllProviders`, in general would only be used at runtime, not during compile or test. In case `uses` is used, all modules with matching `provides` are added as well.
28
28
29
29
-`setJdkHome`, should point to Java 9 or above in case the runtime of this library is Java 8
30
30
@@ -37,9 +37,9 @@ If there's a `mainModuleDescriptor`, extract a `JavaModuleDescriptor` of it. Thi
37
37
All pathElements of `ResolvePathsRequest.ofT` are transformed to Path instances. For every element the name will be resolved in the following order:
38
38
39
39
1. Module descriptor: verify if the jar or the directory contains `module-info.class`. If so, the its descriptor is transformed to a `JavaModuleDescriptor`, where its ModuleNameSource is marked as `ModuleNameSource.MODULEDESCRIPTOR`
40
-
41
-
2. Manifest: verify if the jar or directory has a `META-INF/MANIFEST.MF` and if it contains the `Automatic-Module-Name` attribute. If so, an automatic `JavaModuleDescriptor` is created, where its ModuleNameSource is marked as `ModuleNameSource.MANIFEST`.
42
-
40
+
41
+
2. Manifest: verify if the jar or directory has a `META-INF/MANIFEST.MF` and if it contains the `Automatic-Module-Name` attribute. If so, an automatic `JavaModuleDescriptor` is created, where its ModuleNameSource is marked as `ModuleNameSource.MANIFEST`.
42
+
43
43
3. Filename: try to extract the module name based on the filename. If the filename could be transformed to a module name (which is not always the case), an automatic `JavaModuleDescriptor` is created, where its ModuleNameSource is marked as `ModuleNameSource.FILENAME`.
44
44
45
45
When there's an `IOException` with one of the pathElements, the exception is stored in the `ResolvePathsResult.pathExceptions` so the consumer can handle them separately.
@@ -48,7 +48,7 @@ The result are a couple of Maps:
48
48
49
49
* module name to `ModuleNameSource`
50
50
51
-
* module name to `JavaModuleDescriptor`
51
+
* module name to `JavaModuleDescriptor`
52
52
53
53
# Phase 2: Resolve
54
54
@@ -57,6 +57,7 @@ This contains recursive code and ensures that required modules are only evaluate
57
57
All these pathElements must be placed on the modulepath, all other pathElements will be marked for the classPath.
58
58
59
59
# Result
60
+
60
61
All results will be stored in a `ResolvePathsResult`.
61
62
62
63
-`getClasspathElements()`, ordered collection of all pathElements that don't belong to the modulepath
@@ -68,3 +69,4 @@ All results will be stored in a `ResolvePathsResult`.
68
69
-`getPathElements()`, ordered map of the pathElements with their module descriptor
69
70
70
71
-`getPathExceptions()`, map of pathElements containing only the elements that faced an exception.
In order to use this class you must setup a `ResolvePathsRequest`, which requires a list of all the jars and output directories and the main module descriptor.
@@ -7,33 +6,34 @@ You start by using `ResolvePathsRequest.ofXXX`, where XXX is either Files, Paths
7
6
8
7
The `ResolvePathRequest` also contains:
9
8
10
-
* mainModuleDescriptor: the path or file of the main module descriptor, can either be `module-info.java` or `module-info.class`
11
-
12
-
* additionalModules: the modules that will be addedusing `-add-modules`
13
-
14
-
* jdkHome: in case you need to use a different JDK to extract the name from the modules. Can be interesting if the runtime is still Java 7.
9
+
* mainModuleDescriptor: the path or file of the main module descriptor, can either be `module-info.java` or `module-info.class`
10
+
11
+
* additionalModules: the modules that will be addedusing `-add-modules`
12
+
13
+
* jdkHome: in case you need to use a different JDK to extract the name from the modules. Can be interesting if the runtime is still Java 7.
15
14
16
15
The `ResolvePathsResult` contains:
17
16
18
-
* mainModuleDescriptor: the module descriptor of the passed descriptor file.
19
-
20
-
* pathElements: as a map in the same order as provided by the request. Every entry has a matching moduledescriptor when available.
21
-
22
-
* classpathElements: all the pathElements which should end up on the classpath.
23
-
24
-
* modulepathElements: all the pathElements which should end up on the modulepath. Per entry you get the source of the modulename which is either the moduledescriptor, the manifestfile of the filename. This information can be used to warn users in case they use automatic modules, which module names are not reliable yet.
25
-
26
-
* pathExceptions: pathElements with their exception while trying to resolve it. Only pathElements with an exception are listed.
27
-
17
+
* mainModuleDescriptor: the module descriptor of the passed descriptor file.
18
+
19
+
* pathElements: as a map in the same order as provided by the request. Every entry has a matching moduledescriptor when available.
20
+
21
+
* classpathElements: all the pathElements which should end up on the classpath.
22
+
23
+
* modulepathElements: all the pathElements which should end up on the modulepath. Per entry you get the source of the modulename which is either the moduledescriptor, the manifestfile of the filename. This information can be used to warn users in case they use automatic modules, which module names are not reliable yet.
24
+
25
+
* pathExceptions: pathElements with their exception while trying to resolve it. Only pathElements with an exception are listed.
26
+
28
27
# JavaVersion
29
28
30
29
This is a String based, lazy-parsing implementation of a Java Version which can be used to compare versions. It's goal is to support to support the following patterns:
31
30
32
-
*[JEP 223: New Version-String Scheme](https://openjdk.java.net/jeps/223)
0 commit comments