Bug 438853 - Automatically skip tycho-p2-director-plugin:materialize-products on projects with "pom" packaging
Summary: Automatically skip tycho-p2-director-plugin:materialize-products on projects ...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Tycho (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2014-07-03 11:26 EDT by Andreas Sewe CLA
Modified: 2021-04-28 16:51 EDT (History)
1 user (show)

See Also:


Attachments
Upon "mvn clean install" the build fails with Product with id 'org.example.products.product' does not exist in the project (1.54 KB, application/xml)
2014-07-04 09:27 EDT, Andreas Sewe CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Sewe CLA 2014-07-03 11:26:57 EDT
My understanding of Maven is that projects of packaging "pom" are special insofar as they are the only ones usable as parent POMs. Such parent POMs are a great place for shared <configuration>. Unfortunately, in the case of the tycho-p2-director-plugin this means that this configuration must happen below project/build/pluginManagement rather than below project/build/plugins, as it would otherwise be active for the parent "pom" project already and fail as it cannot find a .product file.

Now, in most case it's desirable to do <configuration> in project/build/pluginManagement rather than project/build/plugins, as it at the very least safes a bogus plugin execution for the "pom" project. Alas, AFAIK the order of plugins below project/build/plugins is the only way one can influence the order of plugin executions in the chronically crowded "package" phase. (In my case, I have to execute the org.vafer:jdeb plugin after tycho-p2-director-plugin:materialize-products, as the materialized product needs to go into the Debian package.)

It would hence be great if the tycho-p2-director-plugin could skip its execution for projects with "pom" packaging.
Comment 1 Tobias Oberlies CLA 2014-07-03 11:47:15 EDT
I don't exactly understand how this change would help you - do you have a small sample for your use case? - but the proposed change absolutely makes sense.

I even would go one step further and only require a product file if the packaging type is "eclipse-repository", and skip the check (and hence do nothing) in all other cases.

This change should be really simple. If you want it to be in 0.21.0 which is due in a few days, you should propose [1] it now ;-)

[1] http://wiki.eclipse.org/Tycho/Contributor_Guide
Comment 2 Andreas Sewe CLA 2014-07-03 11:56:23 EDT
(In reply to Tobias Oberlies from comment #1)
> I don't exactly understand how this change would help you - do you have a
> small sample for your use case? - but the proposed change absolutely makes
> sense.
> 
> I even would go one step further and only require a product file if the
> packaging type is "eclipse-repository", and skip the check (and hence do
> nothing) in all other cases.

I'm not a big fan of testing for specific packaging types as that often prevents creative solutions (see my comment on Bug 416543, for example, where it would have been harmful if supportedProjectTypes were hard-coded).

That being said, maybe a supportedProjectTypes parameter would be best. Alternatively, I would make the "pom" vs. "everything else" distinction, as "pom" is really the one special case that IMHO always warrants a different treatment. Which solution do you prefer?

> This change should be really simple. If you want it to be in 0.21.0 which is
> due in a few days, you should propose [1] it now ;-)

I'll give it a try over the weekend. (Also, the helpwanted keyword on Bug 371884 gave me another idea how to spend my weekend ;-)

> [1] http://wiki.eclipse.org/Tycho/Contributor_Guide
Comment 3 Tobias Oberlies CLA 2014-07-04 06:28:04 EDT
I checked the code, and it already does what I thought that we'd need to change: The mojo does nothing if there are no products. So for a pom packaging type, the mojo does nothing.

So, I don't understand why we need to change anything.

(In reply to comment #0)
> it would otherwise be active for the parent "pom" project already and fail as it
> cannot find a .product file.

Do you have a small/minimal project that demonstrates this?
Comment 4 Andreas Sewe CLA 2014-07-04 09:27:56 EDT
Created attachment 244828 [details]
Upon "mvn clean install" the build fails with Product with id 'org.example.products.product' does not exist in the project

(In reply to Tobias Oberlies from comment #3)
> I checked the code, and it already does what I thought that we'd need to
> change: The mojo does nothing if there are no products. So for a pom
> packaging type, the mojo does nothing.
> 
> So, I don't understand why we need to change anything.
> 
> (In reply to comment #0)
> > it would otherwise be active for the parent "pom" project already and fail as it
> > cannot find a .product file.
> 
> Do you have a small/minimal project that demonstrates this?

Sure. I've attached a pom.xml with packaging type "pom" (it does not declare any <modules> to keep the example minimal but that's the intention of this parent POM). Upon "mvn clean install" I get the following error message:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Products 1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ products ---
[INFO] 
[INFO] --- tycho-p2-director-plugin:0.20.0:materialize-products (materialize-products) @ products ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.929s
[INFO] Finished at: Fri Jul 04 15:24:40 CEST 2014
[INFO] Final Memory: 8M/19M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-p2-director-plugin:0.20.0:materialize-products (materialize-products) on project products: Product with id 'org.example.products.product' does not exist in the project -> [Help 1]
Comment 5 Tobias Oberlies CLA 2014-07-04 09:33:27 EDT
Okay, I see now which error you mean.

But for the given example, you could simply move the configuration to the pluginManagement section and it would work. Could you extend the sample and demonstrate why this doesn't work for you?
Comment 6 Andreas Sewe CLA 2014-07-04 09:43:35 EDT
(In reply to Tobias Oberlies from comment #5)
> Okay, I see now which error you mean.
> 
> But for the given example, you could simply move the configuration to the
> pluginManagement section and it would work. Could you extend the sample and
> demonstrate why this doesn't work for you?

Not without quite a bit of work. The synopsis: The products (there are quite many) I build in a module of the attached project should be, after they have been materialized and archived by Tycho, be packaged as a Debian package. Thus, I would like to configure both Tycho and the org.vafer:jdeb plugins in the parent POM and have the configuration take effect in all children.

The problem is that I haven't found a way to configure the tycho-p2-director-plugin in projects/build/pluginManagement and the org.vafer:jdeb plugin in projects/build/*plugins* of the parent POM such that the tycho-p2-director-plugin executes before the jdeb plugin in the package phase.

This can be achieved quite easily by specifying both in the desired order in projects/build/plugins, but then I have to do that in every module, as putting the tycho-p2-director-plugin in projects/build/plugins fails the build as described.
Comment 7 Tobias Oberlies CLA 2014-07-11 07:19:37 EDT
Okay, now this makes sense.

In this case, I'd still wouldn't skip the goal completely in POM packaging types, but just demote the error to a warning. In this way, your use case works, and the director-plugin may still be used without restrictions (and in ways that we don't know today) without having to introduce a new configuration switch.
Comment 8 Andreas Sewe CLA 2014-07-11 07:42:34 EDT
(In reply to Tobias Oberlies from comment #7)
> Okay, now this makes sense.
> 
> In this case, I'd still wouldn't skip the goal completely in POM packaging
> types, but just demote the error to a warning. In this way, your use case
> works, and the director-plugin may still be used without restrictions (and
> in ways that we don't know today) without having to introduce a new
> configuration switch.

Fair enough.
Comment 9 Mickael Istria CLA 2021-04-08 18:09:50 EDT
Eclipse Tycho is moving away from this bugs.eclipse.org issue tracker to https://github.com/eclipse/tycho/issues/ instead. If this issue is relevant to you, your action is required.
0. Verify this issue is still happening with latest Tycho 2.4.0-SNAPSHOT
  if issue has disappeared, please change status of this issue to "CLOSED WORKFORME" with some details about your testing environment and how you did verify the issue; and you're done
  if issue is still present when latest release:
* Create a new issue at https://github.com/eclipse/tycho/issues/
  ** Use as title in GitHub the title of this Bugzilla ticket (may include the bug number or not, at your own convenience)
  ** In the GitHub description, start with a link to this bugzilla ticket
  ** Optionally add new content to the description if it can helps towards resolution
  ** Submit GitHub issue
* Update bugzilla ticket
  ** Add to "See also" property (up right column) the link to the newly created GitHub issue
  ** Add a comment "Migrated to <link-to-newly-created-GitHub-issue>"
  ** Set status as CLOSED MOVED
  ** Submit

All issues that remain open will be automatically closed next week or so. Then the Bugzilla component for Tycho will be archived and made read-only.