0

I am about to setup a new Gradle project in Intellij Idea. But I am alrady failing at loading dependencies. This is my gradle file:

plugins {
    id 'java'
}

group 'ch.demo'
version '7.4.5.0'

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'com.google.gwt', name: 'gwt', version: '2.9.0'
}

If I execute this gradle script, I get the error 'Could not resolve com.google.gwt:gwt:2.9.0.'

The maven module should be correct, it's available here: https://repo.maven.apache.org/maven2/com/google/gwt/gwt/2.9.0/

It seems I am doing something wrong. Does anyone know how to solve this?

Also tried compile 'com.google.gwt:gwt:2.9.0' but that didn't work either.

Edit:

I used the command "Reimport all Gradle Projects" so far. If I press "Execute Gradle Task" -> "gradle build", I get the following error:

Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not resolve com.google.gwt:gwt:2.9.0.
     Required by:
         project :
      > Could not resolve com.google.gwt:gwt:2.9.0.
         > Could not get resource 'https://repo.maven.apache.org/maven2/com/google/gwt/gwt/2.9.0/gwt-2.9.0.pom'.
            > Could not GET 'https://repo.maven.apache.org/maven2/com/google/gwt/gwt/2.9.0/gwt-2.9.0.pom'.
               > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Roman
  • 470
  • 2
  • 5
  • 17
  • Are you behind a proxy? I've seen some corporate proxies that basically hijack the connections, like a "man-in-the-middle" attacker would, and then serve you its own local certificate so they can snoop on all traffic. You can see if this is the case if you open the [URL](https://repo.maven.apache.org/maven2/com/google/gwt/gwt/2.9.0/gwt-2.9.0.pom) in a browser and click the padlock icon (or similar, depending on what browser you use). If the certificate looks OK, maybe your local JDK certificate store is broken or outdated. You can find it in `$JAVA_HOME/jre/lib/security/cacerts`. – Bjørn Vester Jun 02 '20 at 13:09
  • Other than a proxy, it could be possible that your Java build is too old to handle the certificate. This isn't likely for the apache.org url above, but we have seen it repeatedly for Let's Encrypt-created certificates. – Colin Alworth Jun 02 '20 at 13:38
  • @BjørnVester: I've load a new AdoptOpenJDK 11 version in Intellij Idea itself and used that one. I still get the same error. Also tried disabling the Windows Firewall. I'll load the gwt lib on my pc and load it locally, so I don't have this problem anymore. – Roman Jun 02 '20 at 14:26
  • com.google.gwt:gwt:2.9.0 is a parent pom. You most likely need something like com.google.gwt:gwt-user:2.9.0 and/or com.google.gwt:gwt-dev:2.9.0 – Alexander Leshkin Jun 02 '20 at 15:37

2 Answers2

1

There is most likely a setup problem on your machine. Looks like your Java installation does not have the usual trusted root certificates.

You should use a small program, like this one, to figure out what the issue is.

Solving this particular issue might need a question on its own or finding answers here. See questions like this one and that one.

Once you manage to open a connection that way, make sure that Gradle uses the same JDK and things should work.

Louis Jacomet
  • 13,661
  • 2
  • 34
  • 43
0

Try like this:

dependencies {    
       implementation 'com.google.gwt:gwt:2.9.0'
}

It is recommended to use implementation instead of compile. Further on that can be found here:

What's the difference between implementation and compile in Gradle?

update: I just tried in my machine and this works fine:

  1. Create a new gradle project via IntelliJ
  2. Modify your gradle.build to look like this:
  plugins {
            id 'java'
        }

    group 'org.example'
    version '1.0-SNAPSHOT'

    repositories {
        mavenCentral()
    }

    dependencies {
        implementation 'com.google.gwt:gwt:2.9.0'
    }

Demostration how I created the project and message on terminal saying that build passed:

enter image description here

javing
  • 12,307
  • 35
  • 138
  • 211
  • @Roman Try the update I just gave you. Pay attention to group and version. Use your IntelliJ Editor to create the project, it will create everything you see above all you need to do is add the dependency. It works perfectly fine I just tried it. – javing Jun 02 '20 at 09:48
  • I already created the project like this and made the same, but it still doesn't work. It seems like it's blocked from somewhere or so – Roman Jun 02 '20 at 10:04
  • @Roman You need to provide more information in your question. Please update your question with the command you are running to build and also a full stacktrace to see fully the error in context. If you are building with gradle you can use `--stacktrace` for more detailed error information – javing Jun 02 '20 at 10:06
  • It seems to be some kind of certification problem – Roman Jun 02 '20 at 11:09