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

eclipse.mavencentral with underspecified releases #121

Closed
acisternino opened this issue Mar 31, 2020 · 8 comments
Closed

eclipse.mavencentral with underspecified releases #121

acisternino opened this issue Mar 31, 2020 · 8 comments
Labels

Comments

@acisternino
Copy link

com.diffplug.eclipse.mavencentral fails immediately when gradle is invoked.

The error happens when the plugin tries to download the https://download.eclipse.org/eclipse/updates/xx.xx/artifacts.jar archive from eclipse.org:

11:01 $ ./gradlew clean

FAILURE: Build failed with an exception.

* Where:
Build file '/home/andrea/Development/skunkworks/java-swt-gradle/build.gradle' line: 23

* What went wrong:
A problem occurred evaluating root project 'java-swt-gradle'.
> https://download.eclipse.org/eclipse/updates/4.14/artifacts.jar
  received http code 404
  <!DOCTYPE html>
  ... Rest of the HTML follows ...

Steps to reproduce

  1. Clone minimal sample project: https://github.com/acisternino/java-swt-gradle
  2. Execute any Gradle task using the wrapper. E.g. ./gradlew clean

Environment

  • Java 11
  • Gradle 6.3 (using the wrapper)
  • Several Eclipse versions (tested with 4.7, 4.11, 4.14, 4.15)
  • Plugin version 3.22.0
@acisternino acisternino changed the title Error 404 from eclipse.org with com.diffplug.eclipse.mavencentral Error 404 from eclipse.org in com.diffplug.eclipse.mavencentral Mar 31, 2020
@nedtwigg
Copy link
Member

nedtwigg commented Apr 1, 2020

Any chance you're behind a proxy?

@nedtwigg
Copy link
Member

nedtwigg commented Apr 1, 2020

Just FYI, I tried this example project on my machine, and it worked fine (I don't have Java 11, so the compile failed, but the SWT jars downloaded fine). I bet this is a firewall/proxy issue. This is where we download the "artifacts.jar" from the official eclipse p2 repository, which is what we use to determine version numbers for SWT, JFace, etc.

FileMisc.download(release.updateSite() + "artifacts.jar", artifactsJar);

And this is how the download happens:

/** Downloads the url to the destination file (with support for redirects). */
public static void download(String url, File dst) throws IOException {
mkdirs(dst.getParentFile());
OkHttpClient client = new OkHttpClient.Builder().build();
Request req = new Request.Builder().url(url).build();
try (Response response = client.newCall(req).execute()) {
if (!response.isSuccessful()) {
ResponseBody body = response.body();
throw new IllegalArgumentException(url + "\nreceived http code " + response.code() + (body == null ? "" : "\n" + body.string()));
}
try (ResponseBody body = response.body();
BufferedSink sink = Okio.buffer(Okio.sink(dst))) {
if (body == null) {
throw new IllegalArgumentException("Body was expected to be non-null");
}
sink.writeAll(body.source());
}
}
}

Happy to take a PR which fixes your issue, but it's very hard to debug proxy issues from outside the proxy.

@nedtwigg nedtwigg changed the title Error 404 from eclipse.org in com.diffplug.eclipse.mavencentral Add proxy support for com.diffplug.eclipse.mavencentral Apr 1, 2020
@acisternino
Copy link
Author

acisternino commented Apr 1, 2020

Unfortunately I am not behind any proxy.
I have just tested again from my home PC directly connected to the internet through a regular ADSL modem/router.

What is perplexing is that the URL printed in the error report (https://download.eclipse.org/eclipse/updates/4.14/artifacts.jar) doesn't exist. If I try it in the browser I get a Not Found page that matches Gradle's output.

Going to https://download.eclipse.org/eclipse/updates/4.14/ shows a page saying that I have hit an Eclipse software repository whose content is:

  • R-4.14-201912100610/
  • categories/
  • compositeArtifacts.jar
  • compositeContent.jar
  • p2.index

error.html.gz

@acisternino
Copy link
Author

I have just noticed that the URL of the artifacts.jar file actually is:

http://download.eclipse.org/eclipse/updates/4.14/R-4.14-201912100610/artifacts.jar

i.e. one level below 4.14.

This happens also in more recent versions. The actual file is in the directory with the release number and the timestamp.

@nedtwigg
Copy link
Member

nedtwigg commented Apr 1, 2020

Aha! In that case, in your build, try changing 4.14 to 4.14.0. Let me know if that fixes it, in which case this will become a bug that we fix in the next version.

@acisternino
Copy link
Author

Thanks @nedtwigg !

It worked after adding the third number to the version. Sorry for not testing this before.

Maybe a note in the documentation could be helpful to avoid the same mistake in the future.

@nedtwigg nedtwigg added bug and removed enhancement labels Apr 3, 2020
@nedtwigg
Copy link
Member

nedtwigg commented Apr 3, 2020

Maybe a note in the documentation

I think it's a bug that we allow you to try at all. Next version will give a warning "You have to be specific, instead of 4.14 use 4.14.0"

@nedtwigg nedtwigg changed the title Add proxy support for com.diffplug.eclipse.mavencentral eclipse.mavencentral with non-specific releases Apr 3, 2020
@nedtwigg nedtwigg changed the title eclipse.mavencentral with non-specific releases eclipse.mavencentral with underspecified releases Apr 3, 2020
@nedtwigg
Copy link
Member

Fixed in 3.23.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants