Trying to import the gpars withPool method into my project. The import works in groovyconsole but not when building in gradle.
Both groovyconsole and gradle are running groovy version 2.4.5
Any ideas?
Groovy Console
import static groovyx.gpars.GParsPool.withPool
withPool(2) { (1..5).collectParallel { println it.toString() } }
Output:
1
3
2
4
5
Result: [null, null, null, null, null]
Gradle compileGroovy
Same import step as above:
import static groovyx.gpars.GParsPool.withPool
Gradle output:
:compileGroovystartup failed:
C:\Programming\Projects\groovy\src\main\groovy\lib.groovy: 18: unable to resolve class groovyx.gpars.GParsPool
# line 18, column 1.
import static groovyx.gpars.GParsPool.withPool
^
1 error
FAILED
If you wish to import something into your build script, then you have to provide it as a build script dependency, in order to make Gradle know, where to find it, just like:
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath group: 'org.codehaus.gpars', name: 'gpars', version: '1.1.0'
}
}
import static groovyx.gpars.GParsPool.withPool
If you navigate to the location where groovy is installed - might be under $GROOVY_HOME and list the folders you'll notice the lib folder. Listing the content of the lib folder shows that gpars-1.2.1.jar is present there (groovy v2.4.5).
All these jar file located in lib folder are added to classpath when groovy is started via groovysh or groovyConsole.
However this doesn't happen when it comes to gradle and as #Stanislav answered you need to add it to classpath manually.
Related
I'm trying to use the attachments module, specifically these features:
https://pnp.github.io/pnpjs/sp/attachments/
I've installed all pnp/sp modules necessary (I think!) using : https://pnp.github.io/pnpjs/getting-started/ as a reference.
Problem is I'm getting a 'cannot find module' for the attachments module. Below are the imports:
import { default as pnp } from 'sp-pnp-js';
import { ItemAddResult, Web } from 'sp-pnp-js';
import { sp } from "#pnp/sp"; //this is fine, which suggests it's installed properly?
import { IItem } from '#pnp/sp/attachments'; //cannot find this module
import "#pnp/sp/webs";
import "#pnp/sp/lists/web";
import "#pnp/sp/items";
import "#pnp/sp/attachments";
I've been successfully using pnp.sp features in this particular project so am stumped why I can't import and use the attachments feature.
If this is an existing project, that you've had for a bit, and you've already got #pnp in the package.json file, it may be you're using version 1 of #pnp, and you are reading the documentation for version 2.
I get the same error cannot find module when I add it to a project #pnp/sp 1.3.7
But don't get it with version 2.0.0
Version 1 document for attachments:
https://pnp.github.io/pnpjs/v1/sp/docs/attachments/
Version 2:
https://pnp.github.io/pnpjs/sp/attachments/
I recently migrated my app from AppCompat to Androidx but now I'm facing a serious issue with GlideApp. Whenever I try building the project, it shows compilation failed.
I tried changing the following import statements,
import android.support.annotation.CheckResult;
import android.support.annotation.NonNull;
in the build folder to:
import androidx.annotation.CheckResult;
import androidx.annotation.NonNull;
But whenever I rebuild it just regenerates the former import statement and returns the following errors:
error: package android.support.annotation does not exist error:
cannot find symbol class NonNull
I found the fix by adding annotationProcessor 'androidx.annotation:annotation:1.1.0' to my dependencies in app build.gradle and was able to build the project with no errors.
Got the solution from here: https://github.com/bumptech/glide/issues/3080#issuecomment-426331231
I'm trying to import this two Libraries :
import com.google.android.gms.location.ActivityRecognitionClient;
import com.google.android.gms.location.DetectedActivity;
but the .android turns to red.
this what it shows
Did i forget to add a package to my project ?
You need to add this in your gradle file :
implementation 'com.google.android.gms:play-services:12.0.1'
Check out this : Can't find the class com.google.android.gms.location.LocationClient (android)
I am learning about GEB and i would like to play around with it in Groovy console. I am tying to run:
import geb.Browser
Browser.drive {
go "http://googel.com/"
assert title == "Google"
}
But this gives an error
unable to resolve class geb.Browser
at line: 1, column: 1
I have downloaded Geb core jar (http://search.maven.org/#artifactdetails%7Corg.codehaus.geb%7Cgeb-core%7C0.7.2%7Cjar) and put it in the PATH, but is not importing in the groovy console. What am i doing wrong and how to run the simple Geb inline scripting?
Thank you
p.s. mac 10.7, geb 0.7.2
Try putting that at the top of your file :
#Grapes([
#Grab("org.codehaus.geb:geb-core:0.7.2"),//always use latest version of geb and selenium drivers
#Grab("org.seleniumhq.selenium:selenium-firefox-driver:2.46.0"),
#Grab("org.seleniumhq.selenium:selenium-support:2.46.0")
])
Then, you won't have to deal with classpath issues and you'll got geb in groovy console easily
What's causing this?
$ echo -e "import groovy.io.FileType;\nprintln 'hello'" > foo.groovy
$ groovy foo.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, /work/fun/BitMarket/database/foo.groovy: 1: unable to resolve class groovy.io.FileType
# line 1, column 1.
import groovy.io.FileType;
^
1 error
My Groovy version is 1.6.4. Was this class added in a later version?
Based on the GroovyDocs the class groovy.io.FileType was introduced in Groovy version 1.7.1. The GroovyDocs for version 1.6.4 don't indicate that this class exists. I guess you have to upgrade your Groovy JDK.