0

In Eclipse I can build my project with the following steps:

  1. clone project from github
  2. Maven -> Update project with the following settings enabled
  • "Update dependencies"
  • "Update project configuration from pom.xml"
  • "Refresh workspace resources from local filesystem"
  • "Clean projects"
  1. Run as -> Maven install The build succeeds.

Now I want to do the same from the CLI.

  1. I dont know which arguments I need to fully replicate the steps from eclipse, I tried the following
  • mvn clean
  • mvn dependency:resolve
  • mvn eclipse:eclipse
  1. mvn install -U

The installation fails with a lot of errors (see example below) about packages that doesn't exist. This is normally done in step 2 for the eclipse procedure. When I perform this step in eclipse and run mvn install, then it works.

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/projects/git/mypackage/src/mypackage/myfile.java:[13,10] package ij does not exist

I suppose I am using the wrong CLI commands. Someone knows which I should use?

-- edit --

The only file that contains a reference to ij.jar is the MANIFEST.MF:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Tasks
Bundle-SymbolicName: mypackage
Bundle-Version: 1.0.0.qualifier
Bundle-ClassPath: mypackage.jar,
 lib/ij.jar

The file ij.jar is located in the lib folder.

The error above indeed is the first error. The other errors are similar, therefore I didn't copy all of them.

The difference in output of mvn install -U from the CLI compared to the output of the console in eclipse after using Update project followed by Run as -> Maven install is

[INFO] Scanning for projects...
[INFO]
[INFO] ---------------< mypakcage >----------------
[INFO] Building mypackage 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ mypackage ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 12 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ mypackage ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 202 source files to C:\projects\eclipse\mypackage\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/projects/git/mypackage/src/mypackage/myfile.java:[13,10] package ij does not exist

vs

[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------< mypackage:mypackage >----------------
[INFO] Building mypackage 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ mypackage ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 12 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ mypackage ---
[INFO] Nothing to compile - all classes are up to date

The errors occur once the build tries to compile mypackage.

  • There's going to be a lot of info we can't see here that probably would help. I would first compare the entire console contents between your "mvn install -U" within Eclipse, and the shell contents. Is that compile error the very first error that you see in the output? Is the "ij" package from a dependency, or from the local source? – David M. Karr Apr 09 '21 at 23:35
  • Thanks for your response. I added the missing info in the original post after the --edit-- tag. – Ashgard Weterings Apr 10 '21 at 07:35
  • Never call `mvn eclipse:eclipse`. This might break your project. Just call `mvn clean install`, that is all. – J Fabian Meier Apr 10 '21 at 11:02
  • I tried several combinations. Unortunately mvn clean install gives the same errors. – Ashgard Weterings Apr 10 '21 at 12:48

1 Answers1

0

I'm actually surprised that the build from Eclipse works. The key here is the odd way the "ij" dependency is specified. A Maven project specifies its dependencies in the pom.xml, usually by typical declarative GAV specifications, but it is actually possible to specify dependencies to local jars, although that is not recommended. If there is no way to specify a conventional GAV dependency for "ij", then you'll need to specify the local jar dependency.

The key is using the "systemPath" element with "system" scope. There is a discussion about this in the following StackOverflow thread: build maven project with propriatery libraries included

You can also read about the "systemPath" element in the official Maven documentation: https://maven.apache.org/pom.html .

David M. Karr
  • 14,317
  • 20
  • 94
  • 199