Richard Fearn
Richard Fearn

Reputation: 25491

How to configure Tycho to also use a nearby p2 mirror for content.jar and artifacts.jar?

I have an Eclipse product that is being built with Maven and Tycho. The top-level POM specifies some Eclipse p2 sites:

<repository>
    <id>eclipse</id>
    <url>http://download.eclipse.org/releases/luna</url>
    <layout>p2</layout>
</repository>
<repository>
    <id>eclipse-updates</id>
    <url>http://download.eclipse.org/eclipse/updates/4.4</url>
    <layout>p2</layout>
</repository>

It seems that Tycho always downloads the p2 repository metadata (content.jar, artifacts.jar, etc.) directly from download.eclipse.org, which is very slow.

Once Tycho starts downloading bundles, it does then use the mirrors.

I also want to use a mirror of the Eclipse repositories for downloading metadata. Is there an alternative URL I can use, or a property I can set, to make Tycho use the nearest mirror?

I know that I could just replace:

http://download.eclipse.org/releases/luna

with, say:

http://ftp.acc.umu.se/mirror/eclipse.org/releases/luna/

but I wonder if there's a way to get Tycho to use the geographically closest mirror automatically, without me having to hard-code one.

Upvotes: 1

Views: 836

Answers (2)

oberlies
oberlies

Reputation: 11723

p2's built in mirror selection mechanism only applies to the artifacts but not to the index files content.jar and artifacts.jar. As far as I know, this option was at least considered at some point in development of this feature, but then the decision was taken against it. The reason is that stale mirrors would have caused erratic behaviour, whereas without mirrored index files, p2 is reasonably robust against stale or broken mirrors: When downloading an artifact from one mirror fails, p2 will just try another one (and unlike in Eclipse, you actually can see when this happens in Tycho's log output).

So if you also want to get the metadata from a mirror, the only good option is to configure mirrors in your settings.xml. In this way, you won't get the closest mirror selected automatically, but you'll at least not have to change your pom.xml.

So in your example, you'd need to add the following settings.xml configuration:

<mirrors>
   <mirror>
      <id>eclipse-luna-umu.se</id>
      <mirrorOf>eclipse</mirrorOf>
      <url>http://ftp.acc.umu.se/mirror/eclipse.org/releases/luna</url>
      <layout>p2</layout>
      <mirrorOfLayouts>p2</mirrorOfLayouts>
   </mirror>
</mirrors>

I would recommend however that you use a more specific repository ID than just eclipse, e.g. eclipse-luna.

Upvotes: 1

jsievers
jsievers

Reputation: 1853

By default, p2 downloads from eclipse.org will use automatic mirror selection (based on location I assume). This applies to all files except index files (content.jar, artifacts.jar) which are kept centrally at eclipse.org.

Tycho has a booelan switch tycho.disableP2Mirrors (defaults to false) make sure it it false (use maven debug mode -X)

Upvotes: 0

Related Questions