Could not install Gradle distribution during creation of gradle project in windows - spring

I am creating a new gradle project in STS. It shows a error message
Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-6.4.1-bin.zip'.
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException
I tried deleting the gradle directory under c:....gradle\wrapper\dists\
Even after that it throws the same error message.
Am I missing anything here?

Related

Unable to skip ssl verification with gradle command but able to do so in maven

I am currently using gradle publish command but unable to do so, due to PKIX path building failed unable to find valid certification path to requested target
when I tried with mvn deploy command
mvn deploy -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true --debug
It worked fine.
I want to achieve same with gradle.
Create the gradle.properties file:
systemProp.http.ssl.insecure=true
systemProp.http.ssl.allowall=true
systemProp.http.ssl.ignore.validity.dates=true

Maven: All Plugins & Dependencies are underlined Red

ANY IDEAS?? I downloaded a Maven project for IntelliJ and cannot build it. I get errors for dependencies and plugins:
(SOLVED: THIS was because I was trying to run it on my work laptop in work, and the company firewall was blocking me from downloading from the public Maven repository. Thank you)
VIEW BUILD LOG HERE
VIEW IDEA LOG HERE
From reviewing the log files, its as people have mentioned IntelliJ is not able to actually download the dependencies.
The reason why is:
Caused by: java.lang.RuntimeException:
org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.springframework:spring-aop:pom:4.1.2.RELEASE from/to central (https://repo.maven.apache.org/maven2):
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
This typically can occur when all your external traffic is being routed by a corporate proxy that is performing a man-in-the-middle type of scan where the traffic is decrypted, scanned and then re-encrypted.
We experience the same thing in our office so our solution was:
Install your own version of the java SDK (Ex. using SDKMan)
In your new install import into the default trust store the certificates required to validate the new certificate chain
Helps to access the URL in Chrome to view the certificate chain)
If it doesn't look like the Screenshot then there is a proxy
Update IntelliJ so the Project SDK is the new one
Update IntelliJ so JDK for importer is the new one
Click the Reimport All Maven Projects in IntelliJ
This should allow it to continue to work without problems, alternatively in IntelliJ you can run the adhoc maven goal of:
mvn clean install -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true
And it should install all the required dependencies into the local maven cache by ignoring all the SSL certificate problems however this is generally a bad idea.
At this point you can then click the Reimport All Maven Projects in IntelliJ to have it refresh but I found this always doesn't work as IntelliJ sometimes downloads additional plugin dependencies that it can get hung up on that are outside of the clean install goals.

How to understand/fix 'Could not resolve all files for configuration' during IntelliJ-gradle plugin build

I am just getting started making plugins and am hoping to make an IntelliJ plugin using gradle and java. For now, just to learn the basic, all I am trying to do is change the menubar in IntelliJ. But, following this IntelliJ tutorial, I created a Gradle project with Java and IntelliJ Platform Plugin as the additional libraries/frameworks, and when I build, even if I do not change anything at all once the project is created, I get an error I do not understand and do not know how to fix:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'project.project'.
> Could not resolve all files for configuration ':detachedConfiguration1'.
> Could not resolve com.jetbrains.intellij.idea:ideaIC:2019.2.3.
Required by:
project :
> Could not resolve com.jetbrains.intellij.idea:ideaIC:2019.2.3.
> Could not get resource 'https://cache-redirector.jetbrains.com/www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea/ideaIC/2019.2.3/ideaIC-2019.2.3.pom'.
> Could not GET 'https://cache-redirector.jetbrains.com/www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea/ideaIC/2019.2.3/ideaIC-2019.2.3.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
However, when I create a gradle project, and do not use the IntelliJ Platform Plugin, I am able to build and create tasks etc. and as best I can tell it works fine.
I'm using:
IntelliJ 2019.2.3
Gradle 5.6.2
Java 8
I assume that there is something simple I am missing since I am so new but I haven't seen solutions to this issue elsewhere that I was able to use. Any help with this is appreciated.
The last line in the errors looks like a problem with the chain of certificates. This happens when the Gradle plugin attempts to download a build of IntelliJ IDEA v2019.2.3. But the Gradle plugin for IntelliJ is not involved when you build a generic project.
Have you tried pasting the URL from the failed GET statement into the address bar of your browser?
www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea/ideaIC/2019.2.3/ideaIC-2019.2.3.pom
Does the POM file download or do you get an error about certificates?
If you get certificate errors, searching for sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target will yield postings about how to import a server certificate and install it in your JDK's keystore.

Gradle Plugin Test Project Build Failing

I downloaded the gradle plugin test project from their github here:
https://github.com/gradle/gradle/tree/master/subprojects/docs/src/samples/customPlugin
I also updated gradle to latest (4.7).
When I gradle build the consumer project, I get the following build error:
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'consumer'.
Could not resolve all artifacts for configuration ':classpath'.
Could not find org.gradle:customPlugin:1.0-SNAPSHOT.
Searched in the following locations:
file:/C:/Code/gradle/subprojects/docs/src/samples/customPlugin/repo/org/gradle/customPlugin/1.0-SNAPSHOT/maven-
metadata.xml
file:/C:/Code/gradle/subprojects/docs/src/samples/customPlugin/repo/org/gradle/customPlugin/1.0-SNAPSHOT/custom
Plugin-1.0-SNAPSHOT.pom
file:/C:/Code/gradle/subprojects/docs/src/samples/customPlugin/repo/org/gradle/customPlugin/1.0-SNAPSHOT/custom
Plugin-1.0-SNAPSHOT.jar
Required by:
project :
What's the issue here? I guess I don't understand gradle plugins enough. Does the plugin need to be built somehow? I have no 1.0-SNAPSHOT pat or anything of the sort, which seems to be where its looking.
Does the plugin need to be built somehow ?
Yes, at first, otherwise the consumer project won't find it.
Inside the plugin project, just run gradle uploadArchive
And then retry a gradle build inside the consumer project

Download latest release from Artifactory with Gradle

Artifactory has a feature of their API where you can download the latest release of a jar file (See http://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-RetrieveLatestArtifact).
Their example is:
GET http://localhost:8080/artifactory/ivy-local/org/acme/[RELEASE]/acme-[RELEASE].jar
I'm working on a project where all builds get published and I want to grab the jar from the last one. So what I'm looking for is a dependency like this in gradle:
compile "org.acme:acme:1.0.0.9.[RELEASE]"
This fails due to escaping of the square brackets so I tried:
compile "org.acme:acme:1.0.0.9.%5BRELEASE%5D"
This seems to allow gradle/ivy to find the file but it fails because the .pom file version does not match what is defined.
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':project:compile'.
> Could not resolve org.acme:acme:1.0.0.9.%5BRELEASE%5D.
Required by:
org.acme:acme:unspecified
> Could not resolve org.acme:acme:1.0.0.9.%5BRELEASE%5D.
> inconsistent module metadata found. Descriptor: CachedResource: /Users/xxxx/.gradle/caches/artifacts-26/filestore/org.acme/acme/1.0.0.9.%5BRELEASE%5D/pom/3986d9c1a27873ce92c0dbd089fc1ca9618f8c1a/acme-1.0.0.9.%5BRELEASE%5D.pom for http://localhost/artifactory/org/acme/acme/1.0.0.9.%5BRELEASE%5D/acme-1.0.0.9.%5BRELEASE%5D.pom Errors: bad version: expected='1.0.0.9.%5BRELEASE%5D' found='1.0.0.9.80'
Is there any way to get gradle and ivy to pull the latest release from artifactory?
I was able to get this working using the ivy syntax:
compile "org.acme:acme:1.0.0.9.+"
This solves the problem I have but I never did manage to get it working using the Artifactory [RELEASE] url.

Resources