Bug 424805 - "publish-product" fails to update icons for launcher
Summary: "publish-product" fails to update icons for launcher
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Tycho (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks: 527561
  Show dependency tree
 
Reported: 2014-01-02 09:17 EST by Uwe Stieber CLA
Modified: 2021-04-28 16:51 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Uwe Stieber CLA 2014-01-02 09:17:30 EST
If using the Eclipse Product Configuration Editor to browse for and fill in the launcher icons, "publish-product" fails to resolve the relative path and therefore fails to copy the launcher icons in PublishProductMojo.prepareBuildProduct.

Assumptions:
- The "eclipse-repository" project is located in C:\MyProjects\x.y.z.repo
- x.y.z.repo contains the product definition file, x.y.z.repo.product
- x.y.z.repo contain a directory "images", containing the Linux launcher icon launcher.xpm and the Windows launcher icon launcher.ico

Steps to reproduce:
- Using Tycho 0.19.0
- Edit the product configuration using the Eclipse Product Configuration Editor. Use the "Browse..." button to select the launcher icon
    - The relative path to the launcher icons are generated including the project directory
      - Windows: /x.y.z.repo/images/launcher.ico
      - Linux: /x.y.z.repo/images/launcher.xpm
- The checkbox "The product includes native launcher artifacts" is checked
- Build the project

Symptom details:
The update of the launcher icons is not performed. Messages to the console are

java.io.FileNotFoundException: C:\MyProjects\x.y.z.repo\target\products\x.y.z.bundle\x.y.z.repo\images\launcher.xpm (The system cannot find the path specified)

and

Error - 7 icon(s) not replaced in C:\Temp\p2.brandingIron25910701
76925043785\launcher.exe using C:\MyProjects\x.y.z.repo\target\products\x.y.z.bundle\x.y.z.repo\images\launcher.ico

Failure analysis:
The issue appears to be caused by the different interpretation of the relative path for the launcher icons of the Eclipse Product Configuration Editor and the Tycho PublishProductMojo. While the Eclipse Product Configuration Editor assumes that the relative icons path is "<project>.getParentFile()", the Tycho PublishProductMojo assumes the root to be "<productFile>.getParentFile()" (== <project>).

Therefore, PublishProductMojo fails to copy the launcher icons to the expected location in PublishProductMojo.copyFiles.

For the example, the Windows launcher icon path source, calculated by PublishProductMojo.copyFiles, line 173 is "C:\MyProjects\x.y.z.repo\x.y.z.repo\images\launcher.ico". Note the duplication of the project directory in the calculated path. The correct path would be "C:\MyProjects\x.y.z.repo\images\launcher.ico".

Fix proposal:
There are probably better solutions to the problem, but adding the following lines to PublishProductMojo after line 173, might be one solution.

174:  if (relativePath.startsWith("/" + sourceDir.getName())) {
175:    sourceFile = new File(sourceDir.getParentFile(), relativePath);
176:  }

Workarounds:
- Edit the product configuration file manually and remove the project directory from the relative launcher icon paths
- Use "maven-resources-plugin" to copy the images before the "publish-product" goal is executed
Comment 1 Jan Sievers CLA 2014-02-10 09:43:21 EST
FWIW, here is a working example

https://github.com/jsievers/tycho-demo/tree/master/tychodemo.product

From my point of view the current behaviour is correct.

The problem is that when you use the PDE .product editor to browse for .ico files, it will prompt you with an eclipse workspace file selection.
If you choose a file, the path inserted by the editor will be "/<project_name>/path/to/icon.ico"

Note that the first element is the project name, not a directory name.
You would need an eclipse workspace to resolve eclipse project locations in the filesystem.

This kind of path workspace relative path will never work for a headless build as there is no such thing as an eclipse workspace during headless build. 

The .product editor introduces non-portable (workspace-dependent) paths so I don't think this is an issue we could solve on the tycho side.
Comment 2 Tobias Oberlies CLA 2014-02-12 05:52:44 EST
(In reply to comment #1)
> From my point of view the current behaviour is correct.
I'm not sure. I think that Tycho's behaviour is AFAIK the same as p2's, but p2 just may be wrong as well. The product file is a PDE format, so the PDE's definition of the file format should win.

> The problem is that when you use the PDE .product editor to browse for .ico
> files, it will prompt you with an eclipse workspace file selection.
> If you choose a file, the path inserted by the editor will be
> "/<project_name>/path/to/icon.ico"
> 
> Note that the first element is the project name, not a directory name.
> You would need an eclipse workspace to resolve eclipse project locations in the
> filesystem.
> 
> This kind of path workspace relative path will never work for a headless build
> as there is no such thing as an eclipse workspace during headless build.
This is indeed a flaw in the product file format. But Tycho could try to mitigate it as good as possible:
- If the path starts with <project_folder_name>, strip it (as proposed in comment #0). This works if <project_name> is the same as <project_folder_name>, which is probably not too uncommon.
- Otherwise, interpret the path as relative to the project root *and fail if there is not such file*, explaining the limitations of the way how PDE specifies these paths.

> The .product editor introduces non-portable (workspace-dependent) paths so I
> don't think this is an issue we could solve on the tycho side.
Good point. We should file an enhancement request for the PDE to have the target editor produce paths within the same project without the leading /<project_name> (possibly marked with a "relative:" prefix to distinguish them from the current semantic).
Comment 3 David Williams CLA 2014-02-24 09:12:22 EST
Apologies if too far off topic, but ... 

I've recently tried to move (change) to this capability in our Eclipse project builds. 

I was just going to "hard code" the ico's path, such as to "/icons/eclipse.ico" even though the "product editor" flags that with a a warning and simply check in the eclipse.ico into the repository for each product. 

(Seems to be common knowledge, such as from reading 
http://andrius.velykis.lt/2012/10/creating-icons-for-eclipse-rcp-launcher/

So, my problem, it actually seems to work, but for only exactly one product, in our multi-product build. I assume you'd expect this to work for multi-product builds? 

I ask here because I'm a bit confused about the "working example" in comment 1 ... on the surface it appears to (still) be copying the ico files (somewhere) ... so not sure if that's a required step I'm missing ... or if that's just a handy trick to have th icons in one place and "copy everywhere", instead of checking in multiple copies into Git?
Comment 4 Tobias Oberlies CLA 2014-02-24 09:54:03 EST
(In reply to comment #3)
> So, my problem, it actually seems to work, but for only exactly one product, in
> our multi-product build. I assume you'd expect this to work for multi-product
> builds?
It should work regardless of whether you have one or multiple products within one module. If it doesn't, please set up a new project (starting from an empty project) and add only as much as is needed to reproduce the problem, and then report a new bug.
Comment 5 Tobias Oberlies CLA 2014-03-03 08:49:01 EST
Tutorial on how to configure the icons: http://andrius.velykis.lt/2012/10/creating-icons-for-eclipse-rcp-launcher/
Comment 6 David Williams CLA 2014-03-03 09:19:23 EST
(In reply to Tobias Oberlies from comment #5)
> Tutorial on how to configure the icons:
> http://andrius.velykis.lt/2012/10/creating-icons-for-eclipse-rcp-launcher/

I too found this tutorial very helpful. 

And have a theory about why it wasn't working in our "Eclipse Platform" build (but now is).  
Partially, because we had several "sources" of icons, and hard to know which was the "last one applied" -- solved by making sure all "old ones" were deleted from Git repo. 
Plus, might have been some issue that the windows ico icon must be "the same shape" as the one that was originally "built in" to the windows executable. So, while one was replaced correctly, others were not. Again I think this was fundamentally caused by having multiple sources of ico files, and has "cleared up" once we rebuilt windows executable with the new one. Have yet to test that this new one is in fact "replaceable" in all "products" (bug 429082) but assume it will be. [And our current "shape" is slightly different that what's in that tutorial ... we no longer have the 24×24 size.]
Comment 7 Veselin Markov CLA 2018-07-27 03:44:26 EDT
Could you please at least print the path of the file that wasn't found? I spent a lot of time looking for the problem as everything seemed ok.

How could I know that I had to put a relative path in my .product file when there was no warning at all?
Comment 8 Mickael Istria CLA 2021-04-08 18:07:19 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.