[FELIX-6548] Prevent NPE in "manifest" goal with parent outside reactor
diff --git a/tools/maven-bundle-plugin/pom.xml b/tools/maven-bundle-plugin/pom.xml
index e44c6d4..793ecac 100644
--- a/tools/maven-bundle-plugin/pom.xml
+++ b/tools/maven-bundle-plugin/pom.xml
@@ -127,7 +127,9 @@
<configuration>
<excludes>
<exclude>**/*.mf</exclude>
+ <exclude>**/*.MF</exclude>
<exclude>src/repo/**/*.pom</exclude>
+ <exclude>**/org.apache.felix_maven-bundle-plugin_manifest_xx</exclude>
</excludes>
</configuration>
</plugin>
diff --git a/tools/maven-bundle-plugin/src/it/existing-metadata-no-update/.gitignore b/tools/maven-bundle-plugin/src/it/existing-metadata-no-update/.gitignore
new file mode 100644
index 0000000..e3d979a
--- /dev/null
+++ b/tools/maven-bundle-plugin/src/it/existing-metadata-no-update/.gitignore
@@ -0,0 +1 @@
+!/target/
\ No newline at end of file
diff --git a/tools/maven-bundle-plugin/src/it/existing-metadata-no-update/pom.xml b/tools/maven-bundle-plugin/src/it/existing-metadata-no-update/pom.xml
new file mode 100644
index 0000000..74f107e
--- /dev/null
+++ b/tools/maven-bundle-plugin/src/it/existing-metadata-no-update/pom.xml
@@ -0,0 +1,55 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.felix.bundleits</groupId>
+ <artifactId>existing-metadata-no-update</artifactId>
+ <version>1-SNAPSHOT</version>
+ <packaging>jar</packaging><!-- only manifest goal is relevant here -->
+ <description>This project has been built before (i.e. a cache file is there), the current pom.xml has not been touched, nor any of the built files</description>
+ <!-- use a parent which is not available on the filesystem -->
+ <parent>
+ <groupId>io.wcm.maven</groupId>
+ <artifactId>io.wcm.maven.global-parent</artifactId>
+ <version>45</version>
+ </parent>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>@project.version@</version>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <goals>
+ <goal>manifest</goal>
+ </goals>
+ <configuration>
+ <supportIncrementalBuild>true</supportIncrementalBuild>
+ <showStaleFiles>true</showStaleFiles>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tools/maven-bundle-plugin/src/it/existing-metadata-no-update/prebuild.groovy b/tools/maven-bundle-plugin/src/it/existing-metadata-no-update/prebuild.groovy
new file mode 100644
index 0000000..fa69974
--- /dev/null
+++ b/tools/maven-bundle-plugin/src/it/existing-metadata-no-update/prebuild.groovy
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+File cacheFile = new File( basedir, "target/maven-bundle-plugin/org.apache.felix_maven-bundle-plugin_manifest_xx" )
+// pom.xml must be older than cache file
+cacheFile.setLastModified( new Date().getTime() )
+
+return true
diff --git a/tools/maven-bundle-plugin/src/it/existing-metadata-no-update/target/classes/META-INF/MANIFEST.MF b/tools/maven-bundle-plugin/src/it/existing-metadata-no-update/target/classes/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/maven-bundle-plugin/src/it/existing-metadata-no-update/target/classes/META-INF/MANIFEST.MF
diff --git a/tools/maven-bundle-plugin/src/it/existing-metadata-no-update/target/maven-bundle-plugin/org.apache.felix_maven-bundle-plugin_manifest_xx b/tools/maven-bundle-plugin/src/it/existing-metadata-no-update/target/maven-bundle-plugin/org.apache.felix_maven-bundle-plugin_manifest_xx
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/tools/maven-bundle-plugin/src/it/existing-metadata-no-update/target/maven-bundle-plugin/org.apache.felix_maven-bundle-plugin_manifest_xx
@@ -0,0 +1 @@
+
diff --git a/tools/maven-bundle-plugin/src/it/existing-metadata-no-update/verify.groovy b/tools/maven-bundle-plugin/src/it/existing-metadata-no-update/verify.groovy
new file mode 100644
index 0000000..b45f8e6
--- /dev/null
+++ b/tools/maven-bundle-plugin/src/it/existing-metadata-no-update/verify.groovy
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+String manifest = new File( basedir, "target/classes/META-INF/MANIFEST.MF" ).text
+
+assert manifest.isEmpty()
diff --git a/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java b/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
index a5a30fa..729d976 100644
--- a/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
+++ b/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
@@ -428,15 +428,26 @@
// generated last?
Path cacheData = getIncrementalDataPath(project);
if(!Files.isRegularFile(cacheData)) {
+ getLog().debug("No cache data file found at '" + cacheData + "', generating manifest.");
return false;
}
long manifestLastModified = lastModified(cacheData);
while (project != null)
{
- Path pom = project.getFile().toPath();
- if (manifestLastModified < lastModified(pom))
- {
- return false;
+ if (project.getFile() != null) {
+ Path pom = project.getFile().toPath();
+ if (manifestLastModified < lastModified(pom))
+ {
+ getLog().debug("POM file at '" + pom + "' newer than cache data file, generating manifest.");
+ return false;
+ }
+ } else {
+ if (project.getVersion().endsWith("-SNAPSHOT")) { // is it mutable?
+ getLog().debug("POM file not accessible for SNAPSHOT project '" + project + "', assume modification.");
+ return false;
+ } else {
+ getLog().debug("POM file not accessible for non-SNAPSHOT project '" + project + "', assume no modification.");
+ }
}
project = project.getParent();
}