summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorEckart Langhuth2011-09-14 07:07:38 (EDT)
committer Tobias Oberlies2011-10-07 09:25:56 (EDT)
commit4633bd52d0757a28b43605fefd5d75370a23762b (patch)
tree751a137adae8e977702eed1bae6bef9638888890
parentcd1e4c62c445e7593ea2a5965705a6c6fd76a643 (diff)
downloadorg.eclipse.tycho-4633bd52d0757a28b43605fefd5d75370a23762b.zip
org.eclipse.tycho-4633bd52d0757a28b43605fefd5d75370a23762b.tar.gz
org.eclipse.tycho-4633bd52d0757a28b43605fefd5d75370a23762b.tar.bz2
356716 Improve error handling in product builds
missing .product file - Avoid NPE, only log in case of no product file. missing uid attribute in product file - Fail with explaining error message
-rw-r--r--tycho-p2/tycho-p2-director-plugin/src/main/java/org/eclipse/tycho/plugins/p2/director/DirectorMojo.java6
-rw-r--r--tycho-p2/tycho-p2-director-plugin/src/main/java/org/eclipse/tycho/plugins/p2/director/ProductConfig.java15
-rw-r--r--tycho-p2/tycho-p2-director-plugin/src/test/java/org/eclipse/tycho/plugins/p2/director/ProductConfigTest.java7
-rw-r--r--tycho-p2/tycho-p2-publisher-plugin/src/main/java/org/eclipse/tycho/plugins/p2/publisher/PublishProductMojo.java8
4 files changed, 30 insertions, 6 deletions
diff --git a/tycho-p2/tycho-p2-director-plugin/src/main/java/org/eclipse/tycho/plugins/p2/director/DirectorMojo.java b/tycho-p2/tycho-p2-director-plugin/src/main/java/org/eclipse/tycho/plugins/p2/director/DirectorMojo.java
index 10edf94..63afaee 100644
--- a/tycho-p2/tycho-p2-director-plugin/src/main/java/org/eclipse/tycho/plugins/p2/director/DirectorMojo.java
+++ b/tycho-p2/tycho-p2-director-plugin/src/main/java/org/eclipse/tycho/plugins/p2/director/DirectorMojo.java
@@ -42,7 +42,11 @@ public final class DirectorMojo extends AbstractProductMojo {
private RepositoryReferenceTool repositoryReferenceTool;
public void execute() throws MojoExecutionException, MojoFailureException {
- for (Product product : getProductConfig().getProducts()) {
+ List<Product> products = getProductConfig().getProducts();
+ if (products.isEmpty()) {
+ getLog().info("No product definitions found. Nothing to do.");
+ }
+ for (Product product : products) {
for (TargetEnvironment env : getEnvironments()) {
final DirectorApplicationWrapper director = p2.getService(DirectorApplicationWrapper.class);
int flags = RepositoryReferenceTool.REPOSITORIES_INCLUDE_CURRENT_MODULE;
diff --git a/tycho-p2/tycho-p2-director-plugin/src/main/java/org/eclipse/tycho/plugins/p2/director/ProductConfig.java b/tycho-p2/tycho-p2-director-plugin/src/main/java/org/eclipse/tycho/plugins/p2/director/ProductConfig.java
index 1a1da22..e1ff84c 100644
--- a/tycho-p2/tycho-p2-director-plugin/src/main/java/org/eclipse/tycho/plugins/p2/director/ProductConfig.java
+++ b/tycho-p2/tycho-p2-director-plugin/src/main/java/org/eclipse/tycho/plugins/p2/director/ProductConfig.java
@@ -12,6 +12,7 @@ package org.eclipse.tycho.plugins.p2.director;
import java.io.File;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -48,10 +49,16 @@ class ProductConfig {
* is currently a limitation of this Maven plug-in - it can only be added to an
* eclipse-repository module (which calls the tycho-p2-publisher-plugin).
*/
- File[] productIDs = baseDir.listFiles();
- products = new ArrayList<Product>(productIDs.length);
- for (File file : productIDs) {
- products.add(new Product(file.getName()));
+ if (baseDir.exists()) {
+ File[] productIDs = baseDir.listFiles();
+ products = new ArrayList<Product>(productIDs.length);
+ for (File file : productIDs) {
+ products.add(new Product(file.getName()));
+ }
+ } else {
+ // the product publisher did not create the basedir. So there was no project definition file. Nothing to do.
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=356716
+ products = Collections.emptyList();
}
}
}
diff --git a/tycho-p2/tycho-p2-director-plugin/src/test/java/org/eclipse/tycho/plugins/p2/director/ProductConfigTest.java b/tycho-p2/tycho-p2-director-plugin/src/test/java/org/eclipse/tycho/plugins/p2/director/ProductConfigTest.java
index 6416b05..0e998cd 100644
--- a/tycho-p2/tycho-p2-director-plugin/src/test/java/org/eclipse/tycho/plugins/p2/director/ProductConfigTest.java
+++ b/tycho-p2/tycho-p2-director-plugin/src/test/java/org/eclipse/tycho/plugins/p2/director/ProductConfigTest.java
@@ -118,6 +118,13 @@ public class ProductConfigTest {
assertEquals(false, subject.uniqueAttachIds());
}
+ @Test
+ public void testNotExistingProductsDir() throws Exception {
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=356716
+ subject = new ProductConfig(null, new File(tempDir, "aNotExstistingFolder"));
+ assertTrue(subject.getProducts().isEmpty());
+ }
+
private File createTempDir(String prefix) throws IOException {
File directory = File.createTempFile(prefix, "");
if (directory.delete()) {
diff --git a/tycho-p2/tycho-p2-publisher-plugin/src/main/java/org/eclipse/tycho/plugins/p2/publisher/PublishProductMojo.java b/tycho-p2/tycho-p2-publisher-plugin/src/main/java/org/eclipse/tycho/plugins/p2/publisher/PublishProductMojo.java
index 368f5a2..148db80 100644
--- a/tycho-p2/tycho-p2-publisher-plugin/src/main/java/org/eclipse/tycho/plugins/p2/publisher/PublishProductMojo.java
+++ b/tycho-p2/tycho-p2-publisher-plugin/src/main/java/org/eclipse/tycho/plugins/p2/publisher/PublishProductMojo.java
@@ -86,7 +86,13 @@ public final class PublishProductMojo extends AbstractPublishMojo {
qualifyVersions(productConfiguration, qualifier);
- File buildProductDir = new File(targetDir, "products/" + productConfiguration.getId());
+ final String productId = productConfiguration.getId();
+ if (productId == null) {
+ throw new MojoExecutionException("The product file " + product.productFile.getName()
+ + " does not contain the mandatory attribute 'uid'");
+ }
+
+ File buildProductDir = new File(targetDir, "products/" + productId);
buildProductDir.mkdirs();
final Product buildProduct = new Product(new File(buildProductDir, product.getProductFile().getName()),
new File(buildProductDir, "p2.inf"));