Skip to content
This repository has been archived by the owner on Jul 17, 2022. It is now read-only.

When JSHint task added there is always an error #100

Open
rustamk opened this issue Jul 23, 2014 · 10 comments
Open

When JSHint task added there is always an error #100

rustamk opened this issue Jul 23, 2014 · 10 comments

Comments

@rustamk
Copy link

rustamk commented Jul 23, 2014

When the following task is added:

jshint {
    source = fileTree(dir: "${projectDir}/", include: "**/*.js")
    dest = file("${buildDir}/jshint.out")
    reporter = 'checkstyle'
    jshint.options = [expr: "true", unused: "true"]
}

I get the following error:

  • What went wrong:
    A problem occurred evaluating root project 'primetime_js'.

    No such property: source for class: com.eriwen.gradle.js.JsHintExtension_Decorated

@mida87
Copy link

mida87 commented Aug 6, 2014

Same here.
Can it be a problem with new Gradle version (2.0) combined with newest plugin 1.12.1. ?

It is not only source, the same is true for other properties, they are not present in JsHintExtension_Decorated.

UPDATE: The same happens to me for jsdoc task, other tasks like gzipJs works.
Hope it helps..

@gcoonrod
Copy link

I am currently seeing this issue as well with Gradle 2.0 and js plugin version 1.12.1

@gcoonrod
Copy link

I got around this issue by appending tasks.jshint to the options in the jshint closure.

jshint {
    tasks.jshint.source = javascript.source.dev.js.files
    tasks.jshint.dest = file ("${buildDir}/jshint.out")
    tasks.jshint.outputToStdOut = true
    tasks.jshint.reporter = 'checkstyle'
    jshint.options = [expr: "true", unused: "false"]
}

@paleozogt
Copy link

I am also seeing this. Gradle v1.12 works, but v2.0 doesn't. When I do @gcoonrod's workaround of adding tasks.jshint. to the properties, a different error pops up:

* What went wrong:
Execution failed for task ':jshint'.
> Could not resolve all dependencies for configuration ':rhino'.
   > Could not find org.mozilla:rhino:1.7R3.
     Required by:
         :gradle-js-plugin-test:unspecified

This seems like a regression of #15 (also see #98), but the workaround mentioned in that ticket doesn't work.

Here's the full build.gradle that makes this happen:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.eriwen:gradle-js-plugin:1.12.1'
    }
}
apply plugin:'com.eriwen.gradle.js'

javascript.source {
    dev.js {
        srcDir 'src'
        include "**/*.js"
        exclude "*.min.js"
    }
}

jshint {
    tasks.jshint.source = javascript.source.dev.js.files
    tasks.jshint.dest = file ("${buildDir}/jshint.out")
    tasks.jshint.outputToStdOut = true
    tasks.jshint.reporter = 'checkstyle'
    jshint.options = [expr: "true", unused: "false"]
}

@Scuilion
Copy link
Contributor

Scuilion commented Oct 3, 2014

@paleozogt add mavenCentral to your build.

buildscript {
  repositories {
    jcenter()
  }
  dependencies {
    classpath "com.eriwen:gradle-js-plugin:1.12.1"
  }
}

repositories {
    mavenCentral()
}
apply plugin: "com.eriwen.gradle.js"

@Scuilion
Copy link
Contributor

Scuilion commented Oct 3, 2014

@eriwen Should Maven Central be included in the plugin or should a user be responsible for making that reference?

@paleozogt
Copy link

Thanks @Scuilion that worked!

@eriwen I think the plugin should report the error more clearly. Or at least the sample code on the main github page needs to be updated. Right now that sample code doesn't work without obtuse workarounds like this.

@Scuilion
Copy link
Contributor

Scuilion commented Oct 3, 2014

@eriwen I take that back. I don't think maven central should be part of the plugin. Carry on!

@youjenli
Copy link

youjenli commented Nov 6, 2015

Combining all workarounds mention above, jshint finally works.
It am using gradle-js-plugin 1.12.1 with Gradle 2.4
It seems that maven central has included the rhino dependency (org.mozilla:rhino:1.7R3) at this time.

buildscript {
    repositories {
        mavenCentral()
        maven {
            url = "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "com.eriwen:gradle-js-plugin:1.12.1"
    }
}  

repositories {
    mavenCentral()
}  

apply plugin: "com.eriwen.gradle.js"  

javascript.source {
    dev {
        js {
            srcDir file("${mySourcePath}")
            include "*.js"
            exclude "lib/*.js"
        }
    }
}  

jshint {
    tasks.jshint.source = javascript.source.dev.js.files
    tasks.jshint.dest = file("${buildDir}/jshint.out")
    tasks.jshint.outputToStdOut = false
    tasks.jshint.reporter = 'checkstyle'
    jshint.options = [
        expr: "true",
        unused: "true"
    ]
}

@AbhinandanSonvane
Copy link

I using Gradle 2.14.1 and the JsHint plugin 1.12.1 and facing this issue :
Could not create an instance of type com.eriwen.gradle.js.source.internal.DefaultJavaScriptSourceSet_Decorated.

buildscript {
    repositories {
        mavenCentral()
        maven {
            url = "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "com.eriwen:gradle-js-plugin:1.12.1"
    }
} 
apply plugin: "com.eriwen.gradle.js"

javascript.source {
    dev {
        js {
            srcDir file("${mySourcePath}")
            include "*.js"

        }
    }
} 


jshint {
    tasks.jshint.source = javascript.source.dev.js.files
    tasks.jshint.dest = file("src/test/jshint.xml")
    tasks.jshint.outputToStdOut = false
    tasks.jshint.reporter = 'checkstyle'
    jshint.options = [
        expr: "true",
        unused: "true"
    ]
    jshint.predef = [
        define : "true",$ : "true",setTimeout : "true",window : "true",
        require : "true",localStorage : "true",Set : "true",
        alert : "true",console : "true",document : "true",
        FormData : "true",Blob : "true",XMLHttpRequest : "true",
        TextDecoder : "true",DataView : "true",requirejs: "true"
    ]
}

If I remove the block of javascript.source to set the source then it works fine else it gives error.

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

No branches or pull requests

7 participants