How to apply the gradle js plugin

Hi guys, I’m new here to the forum and to Gradle.

So I am a complete beginner when it comes to gradle. We use it in our project but this is the first time I am actually having to make a gradle related change in build.gradle.

I have added this snippet, which I got from here http://eriwen.github.io/gradle-js-plugin/ to my build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.eriwen:gradle-js-plugin:1.11.0'
    }
}
// Invoke the plugin
apply plugin: 'js'

but I get the following error after right clicking project (in Eclipse) > gradle >refresh all

FAILURE: Build failed with an exception.

What went wrong: A problem occurred configuring project ‘:myapp-web’.
Could not resolve all dependencies for configuration ‘:myapp-web:classpath’. Could not resolve com.eriwen:gradle-js-plugin:1.11.0. Required by: com.app.pfs.myapp:myapp-web:0.0.4-SNAPSHOT Could not GET ‘http://repo1.maven.org/maven2/com/eriwen/gradle-js-plugin/1.11.0/gradle-js-plugin-1.11.0.pom’. repo1.maven.org

However, I am able to hit this url directly http://repo1.maven.org/maven2/com/eriwen/gradle-js-plugin/1.11.0/gradle-js-plugin-1.11.0.pom

anyone have any ideas? did I miss a step?

any help is appreciated. thanks.

-Jack

Hi Jack

Noticed you are trying 1.11.0. Could you try 1.12.1 which is the latest version released to the plugin portal?

Perhaps a dependency changed.

If you still have a problem could you run gradle from the command line with the --stacktrace and the --info parameters so that it generates some more logging? There is also --debug which is noisy but does outline what resources it is trying to find.

Thanks

Kon

Hi Kon,

Thanks for the swift response.

After changing v to 1.12.1 I am now getting the following new error

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ‘:myapp-web’.
    Could not resolve all dependencies for configuration ‘:myapp-web:classpath’.

    Could not find com.eriwen:gradle-js-plugin:1.12.1.
    Required by:
    com.app.pfs.myapp:myapp-web:0.0.4-SNAPSHOT

I ran gradle from the command line with --stacktrace and --info params and, tbh, I got a lot of output which all seems foreign to me and could not pinpoint the error. Best I could is copy paste log and search for “1.12.1”:

Caused by: org.gradle.api.internal.artifacts.ivyservice.ModuleVersionResolveExce
ption: Could not resolve com.eriwen:gradle-js-plugin:1.12.1.
Required by:
com.app.pfs.myapp:myapp-web:0.0.4-SNAPSHOT
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverC
hain.resolve(UserResolverChain.java:67)

Caused by: org.gradle.api.internal.externalresource.transport.http.HttpRequestEx
ception: Could not GET ‘http://repo1.maven.org/maven2/com/eriwen/gradle-js-plugi
n/1.12.1/gradle-js-plugin-1.12.1.pom’.
at org.gradle.api.internal.externalresource.transport.http.HttpClientHel
per.performRequest(HttpClientHelper.java:80)

i got the above two outputs when I reverted back to 1.11.0 as well.

Thanks

-Jack

Scratch that… gradle clean fixed my issue.

Glad to hear you found a way forward. :smile:

Hi Jack,

This is worked for me:

buildscript {
	repositories {
		mavenLocal()
		mavenCentral()
	}
}

plugins {
	id "com.eriwen.gradle.js" version "1.12.1"
}