Community
Participate
Working Groups
Configuring a project to build with tycho for the first time is made considerably more difficult by the fact that any errors in the configuration will likely result in a stacktracee from tycho which doesn't help explain what is wrong rather than going "died because you don't have a 'foo'" or similar. For example someone else also got: "Caused by: java.lang.NullPointerException at org.eclipse.tycho.plugins.p2.director.ProductConfig.<init>(ProductConfig.java:52) at org.eclipse.tycho.plugins.p2.director.AbstractProductMojo.getProductConfig(AbstractProductMojo.java:80) at org.eclipse.tycho.plugins.p2.director.DirectorMojo.execute(DirectorMojo.java:42) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107) ... 28 more" Which is what happens if there is no target/products directory because of an configuration error earlier in the build. (for example when building using the eclipse-repository packaging to build an RCP application the absence of a .product file in the same directory as the pom specifying eclipse-repository will cause this) "The installable unit null has not been found." If the uid attribute is not specified in the .product file then in org.eclipse.tycho.plugins.p2.publisher.PublishProductMojo.prepareBuildProduct(Product, File, String) at line 89 null is appended to "products/" resulting in it later being used as the name of the installable unit. Instead at this point tycho should bail and state that the uid attribute is missing.
Thanks for reporting this. I totally agree that error handling could be better in many cases. And because we can't just go through the entire code for these kind of problems, it is good to get your examples of bad log messages.
Created attachment 203332 [details] Patch proposal
(In reply to comment #2) > Created attachment 203332 [details] > Patch proposal I think that perhaps there should be some sort of warning given for "the product publisher did not create the basedir. So there was no project definition file. Nothing to do." noting that they should check that they have a .product file in the right place - silent failure (which appears as success) being slightly more tedious than bailing with an exception.
Fixed with 4633bd5. Thanks for the patch :-) I added an info log entry in case the the tycho-p2-director-plugin:materialize-products is configured, but there is no product file in the expected location. It is now supported to have materialize-products in the build, although there is no product file. This may be useful for templates/parent POMs.
For your information I encountered the same stack trace for a totally different reason. In my corporate parent pom there is this snippet of XML to generate and attach source bundle to every artifact: <plugins> <!-- Force generation of source bundle even for SNAPSHOTS --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <executions> <execution> <id>attach-sources</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> </plugins> But this configuration make the product generation fail because it seems the clean plugin is called during the forked execution so there is no more target folder when the materialize-products goal is called. Using jar-no-fork has fixed the issue but I spend lot of time to find the reason. May be good to display a better error message than NPE. For information I will attach the build output.
Created attachment 205118 [details] Tycho Maven output with NPE