3

I try to build a project, which is using the Maven Wrapper. The build works fine on command line. There is also a plug-in for IntelliJ Idea. However, I haven't found any article, how to build such project with Eclipse.

Do you have an experience with project build by ./mvnw command instead of mvn in Eclipse, please?

Theodor Keinstein
  • 1,653
  • 2
  • 26
  • 47
  • 1
    AFAIK, building in Eclipse is right click on pom, Runs As -> Maven build ... – LMC Aug 02 '21 at 03:39
  • The problem is, that it fails always with an error: Non-resolvable parent POM for ...: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact ... has not been downloaded from it before. and 'parent.relativePath' points at wrong local POM ... However there is no relativePath tag in any POM and it works even off-line at command line using mvnw. The missing artifact is indeed in the local repo. – Theodor Keinstein Aug 09 '21 at 07:38
  • building in Eclipse is right click on pom, Runs As -> Maven build: Eclipse has permanent problems with dependencies. The same command works on command line. No idea, what is so different within Eclipse. – Theodor Keinstein Aug 09 '21 at 09:30

1 Answers1

0

As implied by the comment from LMC, the Java edition of Eclipse will come with the "m2e" plugin, which will automatically recognize a project with a pom.xml file as a Maven project, and it will automatically note the dependencies, download them, and compile your source code with those artifacts as dependencies.

That deals with dependencies and compilation. If your build is running unit tests with Surefire, or generating code with particular plugins, unless there is a specialized m2e connector for that plugin, Eclipse will not know to do that.

Inside Eclipse, if you need to run a Maven build, you don't need to care about "mvn" vs. "mvnw". Eclipse will have an embedded Maven installation.

David M. Karr
  • 14,317
  • 20
  • 94
  • 199
  • 2
    Yes, might be. However there are some corporate settings in the mvmw script, that take no effect in Eclipse and the build fails. On other hand, Maven should build in the off-line mode, if all has been already downloaded. Maven Wrapper installs a Maven internally. But the Eclipse Embedded Maven is another Maven, what breaks meaning of Maven wrapper - to ensure the same Maven version across environments. – Theodor Keinstein Aug 09 '21 at 06:53