Over the last few years, for our Parent POM project in Eclipse, I've had to employ slightly different tweaks to Eclipse's configuration, to avoid having Eclipse give errors like:
...target/classes/META-INF/MANIFEST.MF (No such file or directory) pom.xml
I know I can manually rid these errors, by right-clicking the parent project and doing
Maven > Update Project
but that only works until the next build when I do another "clean install".
In the past, I got Eclipse to stop complaining by making these 2 Eclipse tweaks:
Preferences > Maven > check "Automatically update Maven projects configuration (experimental)"
Preferences > Maven > Java EE Integration > uncheck "Maven Archiver generates files under the build directory".
But, this no longer work, with the latest versions of Eclipse (e.g., Version: 2021-03).
Why does Eclipse do this and how can I rid myself of this annoyance, once and for all?
I found a solution.
The problem is caused by the standard maven-compiler-plugin. When it generates a JAR file, it deletes target/classes/META-INF/MANIFEST.MF. Eventually (but not right away), Eclipse notices this and complains that the manifest file is missing.
Cleaning the project (as often recommended in related Stack Overflow questions) is not a solution. Although it makes the errors go away temporarily, the errors will soon return, the next time maven-compiler-plugin generates another JAR file.
A permanent solution is to include this additional plugin to my POM, which not just generates a manifest file, but KEEPS it at target/classes/META-INF/MANIFEST.MF:
...
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>compile</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<index>true</index>
<manifest>
<addDefaultSpecificationEntries>false</addDefaultSpecificationEntries>
<addDefaultImplementationEntries>false</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
...
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
...
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
...
</plugin>
</plugins>
...
</build>
...