How does Eclipse apply an Expose Package configuration to a Maven build? - eclipse

How does Eclipse propagate Java 11 "Expose Package..." to the Maven target?
I am exposing a Java 11 module to ALL-UNNAMED using Eclipse: Properties -> Java Build Path -> Module Dependencies -> Expose Package...
Nothing is added to pom.xml with this configuration yet the project builds successfully.
Using Eclipse 2020-06, m2e's maven 3.6.3, maven-compiler-plugin 3.8.1 (this is the only explicit override in pom.xml). The rest is the "EMBEDDED" maven.
When I look at the Maven console and effective pom I do not see any compilerArgs (--add-exports...) added. When I run mvn from the command line I do get compiler failure as expected.
How does m2e propagate --add-exports to javac without it being visible to help:effective-pom target or Maven console?
In Eclipse when I click "Show JPMS Options..." it does display "--add-exports ...", but nowhere in the m2e debug output does this appear.

Related

Eclipse maven not adding dependencies

I am new to maven and am experiencing difficulties while trying to mavenise a Java project.
Setting:
IDE: Eclipse Oxygen.2 Release (4.7.2)
Java: 8
m2e: 1.8.2
What I did:
- copy-pasted the entire original java project and renamed it
- right-click in eclipse: Configure > Convert to Maven project
- in java build path, deletion of libraries import from original local lib repo. The build path shows the Maven Dependencies folder, with the only junit library.
- maven install => downloaded things in the user/.m2/repository/, but not all.
What does not work:
When I try to add a dependency right from a file:
,
nothing pops up in the artifact selection windows, even though there is a commons-logging/ folder in m2/repository
When I try to add the dependency manually in the pom.xml:
<dependency>
<groupId>org.kie.modules</groupId>
<artifactId>org-apache-commons-configuration-main</artifactId>
<version>6.5.0.Final</version>
<type>pom</type>
</dependency>
but the package resolution error still appears in the java file, and I get this warning after Maven install
`[WARNING] The POM for org.kie.modules:org-apache-commons-configuration-main:pom:6.5.0.Final is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details`
I did Maven Update project, eclipse project clean, nothing changes.
My goal for now is just that eclipse understands (at least for one library), that it has to take it from maven repository. I still have many other dependencies to solve (intra-project), but that will be the next step.
Thanks for your help.
The cause of the issue is stated in the warning message :
[WARNING] The POM for
org.kie.modules:org-apache-commons-configuration-main:pom:6.5.0.Final
is invalid, transitive dependencies (if any) will not be available,
enable debug logging for more details
It means that the pom.xml downloaded in your local maven repository exists but is not valid.
Delete the folder of the dependency downloaded in your local maven repository and try again.
If you still have the same problem, check that your central repository that provides the dependency provides also correctly the pom.xml for that.
You can do it by browsing the directory of the dependency from a web browser.
For example we can see that the maven central repository provides a valid pom :
http://central.maven.org/maven2/org/kie/modules/org-apache-commons-collections-main/6.5.0.Final/org-apache-commons-collections-main-6.5.0.Final.pom

Error Updating Maven Project under eclipse

I got this error when update Maven Project under eclipse Eclipse Java EE IDE for Web Developers. (Version: Kepler Service Release 2)
An internal error occurred during: "Updating Maven Project".
Path must include project and resource name: /myProjectName
Thanks
rightclick project, remove maven nature (or in newer eclipse, "Maven->Disable Maven Nature")
mvn eclipse:clean (with project open in eclipse/STS)
delete the project in eclipse (but do not delete the sources)
Import existing Maven project
SOLVED THE PROBLEM

How can I generate-sources on project import/update with m2e

I used to add "generate-resources" to Maven's "Goals to run on project import" setting in older m2e.
Now I have new version of eclispe and m2e, and the setting is gone.
How can I add the generated-sources o the eclipse project automatically?
see this older question:
Problems by import of a multiple modules maven 2 project into eclipse workspace
I am using m2e 1.0.200.20111228-1245,
Eclipse version is as follows
Version: Indigo Service Release 2
Build id: 20120216-1857
Maven is: 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Pls. note that this is a centrally managed system, I have no root access etc.

Eclipse Indigo + me2 project import: Unknown packaging / could not find artifact

Note: I'm just getting started with Jenkins plugin development and have never used maven before.
I have successfully set up a sample plugin with maven and the command
line. (HelloWorldBuilder is building and running correctly via mvn
hpi:run.)
I have then installed eclipse (indigo) and the m2e plugin and tried to
import the maven project into eclipse. (Via Import > Existing Maven
Projects)
The project is imported, but it displays two errors:
#pom.xml, line 1 :
<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/maven-v4_0_0.xsd">
Project build error: Unresolveable build extension: Plugin
org.jenkins- ci.tools:maven-hpi-plugin:1.72 or one of its dependencies
could not be resolved: Could not find artifact com.sun:tools:jar:1.5
at specified path C:\Programme\Java\jre6/../lib/tools.jar
#pom.xml, line 12 :
<packaging>hpi</packaging>
Project build error: Unknown packaging: hpi
Any ideas?
I have already changed the m2e setting (Window > Preferences > Maven > Installations) for the maven installation to use my maven 2.1.1 that I use on the command line.
I have also tried Right-Click-Project > Maven > Update-Dependencies... / Update-Project-Configuration / and Enable-Workspace-Resolution (whatever these settings mean)
This question seems to describe a similar problem, but I have no clue whether it's a duplicate.
I think your Eclipse installation runs under a Java JRE instead of a Java JDK, this is why the tools jar could not be found.
M2Eclipse normally warns the user about that fact at first startup.
The solution is to specify the jdk executable in the eclipse.ini file like shown below.
add:
-vm
C:/Program Files (x86)/Java/jdk1.6.0_26/bin/javaw.exe
before the line starting with -vmargs
1) As Torsten said you need to use JDK, not JRE.
In Eclipse Window->Preferences
Java / Installed JREs
2) See also Jenkins plug-in developing - Maven issue: Unknown packaging: hpi

how to load the dependencies from the pom into classpath of eclipse project?

Am using eclipse helios with m2eclipse plugin. For a maven project checked out from CVS, how do i tell eclipse to automatically fetch all the jars needed for that project from the dependencies mentioned in the pom.
Thanks for your time
m2eclipse should do this for you (dependencies will be copied to your local repository) and build a valid classpath.
I you have any doubts that the resolved dependencies are outdated try
<select project> -> Context Menu -> Maven -> Update Dependencies
If you want to guarantee that all dependencies (and plugins) are in your local repository you can run the go-offline goal from the Maven Dependency Plugin:
mvn dependency:go-offline
If you want to copy all needed dependencies to one place, use the copy-dependencies goal
mvn dependency:copy-dependencies
The Maven Dependency Plugin will copy all dependencies (including transitive) to the target/dependency folder in this case.
You can run all these commands also from eclipse using:
<select project> -> Context Menu -> Run As -> Maven build... -> <type goals> -> Run