Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make P2 repo URL configurable #1629

Closed
jhonnen opened this issue Mar 16, 2023 · 4 comments · Fixed by #1635
Closed

Make P2 repo URL configurable #1629

jhonnen opened this issue Mar 16, 2023 · 4 comments · Fixed by #1635

Comments

@jhonnen
Copy link
Contributor

jhonnen commented Mar 16, 2023

spotless-plugin-gradle:6.17.0 broke our build because it now tries to download artifacts directly from https://download.eclipse.org/eclipse/updates whereas before they were resolved via the configured repositories in Gradle (i.e. an internal maven-central mirror).

Please make the P2 repo URL which is currently hardcoded in EquoBasedStepBuilder#addPlatformRepo configurable so we can swap it out with an internal mirror.

Stacktrace:

Caused by: java.lang.RuntimeException: java.net.SocketTimeoutException: connect timed out
	at dev.equo.solstice.p2.Unchecked.wrap(Unchecked.java:25)
	at dev.equo.solstice.p2.P2Model.query(P2Model.java:133)
	at com.diffplug.spotless.extra.EquoBasedStepBuilder.get(EquoBasedStepBuilder.java:88)
	at com.diffplug.spotless.FormatterStepImpl.calculateState(FormatterStepImpl.java:58)
	at com.diffplug.spotless.LazyForwardingEquality.state(LazyForwardingEquality.java:56)
	at com.diffplug.spotless.LazyForwardingEquality.unlazy(LazyForwardingEquality.java:118)
	at com.diffplug.spotless.LazyForwardingEquality.unlazy(LazyForwardingEquality.java:124)
	at com.diffplug.gradle.spotless.SpotlessExtensionPredeclare.lambda$new$0(SpotlessExtensionPredeclare.java:39)
	at com.diffplug.gradle.spotless.SpotlessExtensionPredeclare.lambda$new$1(SpotlessExtensionPredeclare.java:33)
[...]
Caused by: java.net.SocketTimeoutException: connect timed out
	at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128)
	at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295)
	at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:207)
	at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
	at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
	at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
	at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
	at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
	at dev.equo.solstice.p2.P2Client.getBytes(P2Client.java:145)
	at dev.equo.solstice.p2.P2Client.getString(P2Client.java:116)
	at dev.equo.solstice.p2.P2Client$Folder.<init>(P2Client.java:209)
	at dev.equo.solstice.p2.P2Client.addUnits(P2Client.java:94)
	at dev.equo.solstice.p2.P2Session.populateFrom(P2Session.java:34)
	at dev.equo.solstice.p2.P2Model.queryRaw(P2Model.java:96)
	at dev.equo.solstice.p2.P2Model.query(P2Model.java:125)
	... 191 more
@nedtwigg
Copy link
Member

Happy to merge a PR for this! I'm open to other ideas, but my instinct is to do it like this:

Add a method replaceAllP2ReposWith(String...) to EquoBasedStepBuilder

Then right here

EquoBasedStepBuilder.State get() throws Exception {
var query = model(formatterVersion).query(P2ClientCache.PREFER_OFFLINE, P2QueryCache.ALLOW);

you can do

var model = model(formatterVersion)
if (replaceAllP2Repos != null) {
  model.getP2repo().removeAll()
  model.getP2repo().addAll(replaceAllP2Repos)
}

It'll also have to get wired into the Gradle and Maven DSL. Happy to merge a PR which only addresses one step and one DSL, you don't have to solve the entire problem if you don't want to, just your own.

@jhonnen
Copy link
Contributor Author

jhonnen commented Mar 20, 2023

Add a method replaceAllP2ReposWith(String...) to EquoBasedStepBuilder

But this would quietly override the configured version, right? Just overriding the "https://download.eclipse.org/eclipse/updates/" part would cause less surprises IMHO.
But that only takes care of JDT, the other two are adding additional repositories...

How about something like this:

Map<String, String> p2Mirrors;

/** Creates the state of the configuration. */
EquoBasedStepBuilder.State get() throws Exception {
	P2Model model = model(formatterVersion);
	ArrayList<String> p2Repos = new ArrayList<>(model.getP2repo());
	p2Repos.replaceAll(url -> {
		for (Map.Entry<String, String> mirror : p2Mirrors.entrySet()) {
			if (url.startsWith(mirror.getKey())) {
				return mirror.getValue() + url.substring(mirror.getKey().length());
			}
		}
		return url;
	});
	model.getP2repo().addAll(p2Repos);

	var query = model.query(P2ClientCache.PREFER_OFFLINE, P2QueryCache.ALLOW);
	// ...

And then you would configure mirrors somewhere (not sure where exactly...):

spotless {
    p2Mirrors = [
        'https://download.eclipse.org/eclipse/updates': 'https://some-internal-mirror/eclipse-updates',
        'https://groovy.jfrog.io/artifactory/plugins-release': '...',
    ]
}

@nedtwigg
Copy link
Member

That's a great idea! I have two notes:

  1. if any repos are being replaced, all of them should be. User should get an error message "you need to specify a replacement repo for blah"
  2. I would do the replacement like this jdt().replaceAllP2ReposByPrefix(['https://download.eclipse.org/eclipse/updates' : 'https://internal'])

@nedtwigg
Copy link
Member

nedtwigg commented Apr 6, 2023

Published in plugin-gradle 6.18.0. Thanks to @jhonnen!

benkard pushed a commit to benkard/mulkcms2 that referenced this issue Aug 7, 2023
This MR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [flow-bin](https://github.com/flowtype/flow-bin) ([changelog](https://github.com/facebook/flow/blob/master/Changelog.md)) | devDependencies | minor | [`^0.206.0` -> `^0.214.0`](https://renovatebot.com/diffs/npm/flow-bin/0.206.0/0.214.0) |
| [org.liquibase.ext:liquibase-hibernate5](https://github.com/liquibase/liquibase-hibernate/wiki) ([source](https://github.com/liquibase/liquibase-hibernate)) | build | minor | `4.21.1` -> `4.22.0` |
| [org.liquibase:liquibase-maven-plugin](http://www.liquibase.org/liquibase-maven-plugin) ([source](https://github.com/liquibase/liquibase)) | build | minor | `4.21.1` -> `4.23.0` |
| [com.vladsch.flexmark:flexmark-all](https://github.com/vsch/flexmark-java) | compile | patch | `0.64.4` -> `0.64.8` |
| [com.diffplug.spotless:spotless-maven-plugin](https://github.com/diffplug/spotless) | build | minor | `2.36.0` -> `2.38.0` |

---

### Release Notes

<details>
<summary>flowtype/flow-bin</summary>

### [`v0.214.0`](flow/flow-bin@a8d35e6...ca11e28)

[Compare Source](flow/flow-bin@a8d35e6...ca11e28)

### [`v0.213.1`](flow/flow-bin@656b64a...a8d35e6)

[Compare Source](flow/flow-bin@656b64a...a8d35e6)

### [`v0.213.0`](flow/flow-bin@733e908...656b64a)

[Compare Source](flow/flow-bin@733e908...656b64a)

### [`v0.212.0`](flow/flow-bin@d057186...733e908)

[Compare Source](flow/flow-bin@d057186...733e908)

### [`v0.211.1`](flow/flow-bin@669f2d7...d057186)

[Compare Source](flow/flow-bin@669f2d7...d057186)

### [`v0.211.0`](flow/flow-bin@c0f5f12...669f2d7)

[Compare Source](flow/flow-bin@c0f5f12...669f2d7)

### [`v0.210.2`](flow/flow-bin@6dbf435...c0f5f12)

[Compare Source](flow/flow-bin@6dbf435...c0f5f12)

### [`v0.210.1`](flow/flow-bin@572b4ff...6dbf435)

[Compare Source](flow/flow-bin@572b4ff...6dbf435)

### [`v0.210.0`](flow/flow-bin@026a117...572b4ff)

[Compare Source](flow/flow-bin@026a117...572b4ff)

### [`v0.209.0`](flow/flow-bin@b1689a0...026a117)

[Compare Source](flow/flow-bin@b1689a0...026a117)

### [`v0.208.1`](flow/flow-bin@1e8564c...b1689a0)

[Compare Source](flow/flow-bin@1e8564c...b1689a0)

### [`v0.208.0`](flow/flow-bin@97db57b...1e8564c)

[Compare Source](flow/flow-bin@97db57b...1e8564c)

### [`v0.207.0`](flow/flow-bin@7bf1c0e...97db57b)

[Compare Source](flow/flow-bin@7bf1c0e...97db57b)

</details>

<details>
<summary>liquibase/liquibase-hibernate</summary>

### [`v4.22.0`](https://github.com/liquibase/liquibase-hibernate/releases/tag/v4.22.0)

[Compare Source](liquibase/liquibase-hibernate@v4.21.1...v4.22.0)

Support for Liquibase 4.22.0.

#### What's Changed

-   Fix diff changelog is removing unique constraint since 4.21.0 (hibernate6 + postgresql) by [@&#8203;filipelautert](https://github.com/filipelautert) in liquibase/liquibase-hibernate#480
-   add Support for Hibernate EnversSettings revision_field_name and revision_type_field_name by [@&#8203;lorenzbaier](https://github.com/lorenzbaier) in liquibase/liquibase-hibernate#488
-   Bump spring.version from 6.0.8 to 6.0.9 by [@&#8203;dependabot](https://github.com/dependabot) in liquibase/liquibase-hibernate#490

#### New Contributors

-   [@&#8203;lorenzbaier](https://github.com/lorenzbaier) made their first contribution in liquibase/liquibase-hibernate#488

**Full Changelog**: liquibase/liquibase-hibernate@v4.21.0...v4.22.0

</details>

<details>
<summary>liquibase/liquibase</summary>

### [`v4.23.0`](https://github.com/liquibase/liquibase/blob/HEAD/changelog.txt#Liquibase-4230-is-a-major-release)

[Compare Source](liquibase/liquibase@v4.22.0...v4.23.0)

### [`v4.22.0`](https://github.com/liquibase/liquibase/blob/HEAD/changelog.txt#Liquibase-v4220-is-a-major-release)

[Compare Source](liquibase/liquibase@v4.21.1...v4.22.0)

</details>

<details>
<summary>vsch/flexmark-java</summary>

### [`v0.64.6`](vsch/flexmark-java@0.64.4...0.64.6)

[Compare Source](vsch/flexmark-java@0.64.4...0.64.6)

</details>

<details>
<summary>diffplug/spotless</summary>

### [`v2.38.0`](https://github.com/diffplug/spotless/blob/HEAD/CHANGES.md#&#8203;2380---2023-04-06)

##### Added

-   Support configuration of mirrors for P2 repositories in `EquoBasedStepBuilder` ([#&#8203;1629](diffplug/spotless#1629)).
-   The `style` option in Palantir Java Format ([#&#8203;1654](diffplug/spotless#1654)).
-   Added formatter for Gherkin feature files ([#&#8203;1649](diffplug/spotless#1649)).

##### Changes

-   **POTENTIALLY BREAKING** Converted `googleJavaFormat` to a compile-only dependency and drop support for versions < `1.8`. ([#&#8203;1630](diffplug/spotless#1630))
-   Bump default `cleanthat` version to latest `2.6` -> `2.13`. ([#&#8203;1589](diffplug/spotless#1589) and [#&#8203;1661](diffplug/spotless#1661))
-   Bump default `diktat` version `1.2.4.2` -> `1.2.5`. ([#&#8203;1631](diffplug/spotless#1631))
-   Bump default `flexmark` version `0.62.2` -> `0.64.0`. ([#&#8203;1302](diffplug/spotless#1302))
-   Bump default `googleJavaFormat` version `1.15.0` -> `1.16.0`. ([#&#8203;1630](diffplug/spotless#1630))
-   Bump default `scalafmt` version `3.7.1` -> `3.7.3`. ([#&#8203;1584](diffplug/spotless#1584))
-   Bump default Eclipse formatters for the 2023-03 release. ([#&#8203;1662](diffplug/spotless#1662))
    -   JDT and GrEclipse `4.26` -> `4.27`
        -   Improve GrEclipse error reporting. ([#&#8203;1660](diffplug/spotless#1660))
    -   CDT `11.0` -> `11.1`

### [`v2.37.0`](https://github.com/diffplug/spotless/blob/HEAD/CHANGES.md#&#8203;2370---2023-03-13)

##### Added

-   You can now put the filename into a license header template with `$FILE`. ([#&#8203;1605](diffplug/spotless#1605) fixes [#&#8203;1147](diffplug/spotless#1147))

##### Changes

-   We are now opting in to Gradle's new stable configuration cache. ([#&#8203;1591](diffplug/spotless#1591))
-   Adopt [Equo Solstice OSGi and p2 shim](https://github.com/equodev/equo-ide/tree/main/solstice) to update all Eclipse-based plugins. ([#&#8203;1524](diffplug/spotless#1524))
    -   Eclipse JDT now supports `4.9` through `4.26`. Also we now recommend dropping the last `.0`, e.g. `4.26` instead of `4.26.0`, you'll get warnings to help you switch.
    -   Eclipse Groovy now supports `4.18` through `4.26`. Also we now recommend dropping the last `.0`, e.g. `4.26` instead of `4.26.0`, you'll get warnings to help you switch.
    -   Eclipse CDT now supports `10.6` through `11.0`.
    -   Eclipse WTP is still WIP at [#&#8203;1622](diffplug/spotless#1622).

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

👻 **Immortal**: This MR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4yNC4wIiwidXBkYXRlZEluVmVyIjoiMzQuMjQuMCJ9-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants