Scala, IntelliJ and Gradle dependencies - apache-spark

I am trying to change my project dependencies to Scala 2.11 as I am having troubles with 2.12. My current plugin installation is 2.12. How can I change everything to 2.11?
My project is built on Gradle and this is my build.gradle class:
group 'ics5114'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'idea'
sourceCompatibility = 1.8
idea {
project {
jdkName = '1.8'
languageLevel = '1.8'
}
}
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.apache.spark', name: 'spark-core_2.11', version: '2.3.0'
compile group: 'org.apache.spark', name: 'spark-sql_2.11', version: '2.3.0'
compile group: 'org.apache.spark', name: 'spark-graphx_2.11', version: '2.3.0'
}
jar {
zip64 true
archiveName = "music-graph-spark.jar"
from {
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}
}
manifest {
attributes 'Main-Class': 'com.sparkTutorial.sparkSql.StackOverFlowSurvey'
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'
}

Related

NoClassDefFoundError: org.junit.rules.TestName in Spock 2.0:

I'm trying to update my test project from Spock 1.3 to 2.0:
testImplementation group: 'org.spockframework', name: 'spock-core', version: '2.0-groovy-2.5'
But getting the following error at the test start:
':compileTestGroovy'. Caused by: java.lang.NoClassDefFoundError: org.junit.rules.TestName
As I understand, Spock 2.0 does not contain required internal dependency with this class anymore.
I added the junit-4 dependency explicitly as it is in the Sample project:
testImplementation group: 'org.spockframework', name: 'spock-junit4', version: '2.0-groovy-2.5'
And this solved the above issue. But Now I'm getting "test events were not received" error.
Could anyone explain please what else should be changed in order to make new Spock launch the tests?
UPDATE
Adding the build.gradle. Tests have started with the below configuration:
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
jcenter()
}
dependencies {
classpath "io.qameta.allure:allure-gradle:2.8.1"
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.24.5'
classpath "io.spring.gradle:dependency-management-plugin:1.0.6.RELEASE"
}
}
plugins {
id "idea"
id "groovy"
id "io.qameta.allure" version "2.5"
}
apply plugin: "application"
apply plugin: "groovy"
apply plugin: 'maven-publish'
apply plugin: 'io.qameta.allure'
sourceCompatibility = 1.8
dependencies {
compile 'org.codehaus.groovy:groovy:2.5.2'
implementation group: 'org.codehaus.groovy', name: 'groovy-dateutil', version: '2.5.2'
implementation group: 'org.codehaus.groovy', name: 'groovy-json', version: '2.5.2'
compile "org.testng:testng:6.9.8"
compileOnly "io.micronaut:micronaut-bom:$micronautVersion"
implementation "io.micronaut:micronaut-security-jwt"
implementation "io.micronaut:micronaut-inject-groovy"
implementation "io.micronaut:micronaut-validation"
implementation "io.micronaut:micronaut-http-server-netty"
implementation "io.micronaut:micronaut-http-client"
compile "io.micronaut:micronaut-aop"
implementation "io.micronaut:micronaut-runtime"
compile 'ch.qos.logback:logback-classic:1.1.7'
compile "org.aspectj:aspectjweaver:1.9.2"
testImplementation "io.micronaut.test:micronaut-test-spock"
testImplementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
testCompile group: 'io.github.bonigarcia', name: 'webdrivermanager', version: '3.0.0'
testImplementation group: 'org.spockframework', name: 'spock-core', version: '2.0-groovy-2.5'
testImplementation group: 'org.spockframework', name: 'spock-junit4', version: '2.0-groovy-2.5'
testCompile("org.gebish:geb-spock:3.4") {
/* https://github.com/micronaut-projects/micronaut-test/issues/100 */
exclude group: "org.codehaus.groovy", module: "groovy-all"
}
testCompile "org.seleniumhq.selenium:selenium-java:3.141.59"
compile "com.codeborne:selenide:4.12.0"
testCompile 'org.slf4j:slf4j-jdk14:1.7.25'
testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
implementation group: 'io.qameta.allure', name: 'allure-spock', version: '2.15.0'
testCompile group: 'org.monte', name: 'screen-recorder', version: '0.7.7'
compile group: 'org.springframework', name: 'spring-messaging', version: '4.3.27.RELEASE'
compile group: 'org.springframework', name: 'spring-websocket', version: '4.3.27.RELEASE'
compile group: 'javax.websocket', name: 'javax.websocket-api', version: '1.1'
compile group: 'org.apache.tomcat', name: 'tomcat-websocket', version: '8.0.20'
compile group: 'io.github.http-builder-ng', name: 'http-builder-ng-core', version: '1.0.4'
driver group: 'mysql', name: 'mysql-connector-java', version: '8.0.15'
}
test {
exclude '**/*/**'
}
allure {
version = '2.15.0'
aspectjweaver = true
autoconfigure = false
resultsDir = file("$buildDir/allure-results")
reportDir = file("$buildDir/allure-report")
useSpock {
version = '2.15.0'
}
useTestNG {
version = '2.15.0'
}
}
task apiTest(type: Test, group: 'verification', dependsOn: ['fetchTestFiles']) {
outputs.upToDateWhen { false }
include '**/api/**'
getFilter().setFailOnNoMatchingTests(false)
useJUnitPlatform()
List<String> testNamePatterns = System.getProperty('API_TEST_NAME_PATTERNS')?.split(' ')?.findAll { it }
if (testNamePatterns) {
println("GOT API_TEST_FILTER PROPAGATED $testNamePatterns")
filter {
testNamePatterns.each {
includeTestsMatching(it)
}
}
}
doFirst {
def weaver = configurations.compile.find { it.name.contains("aspectjweaver") }
jvmArgs = jvmArgs << "-javaagent:$weaver"
project.gradle.startParameter.systemPropertiesArgs.entrySet().collect() {
systemProperty it.key, it.value
}
}
}
For now, I'm getting reporting error, which is not related to the initial question. Am I righ assuming that current Allure-Spock implementation does not support spock 2.0? :
org.spockframework.runtime.model.FeatureInfo.getDescription()Lorg/junit/runner/Description;
java.lang.NoSuchMethodError: org.spockframework.runtime.model.FeatureInfo.getDescription()Lorg/junit/runner/Description;
I'm guessing as you didn't provide your build.gradle, but I'm pretty sure you forgot to add
test {
useJUnitPlatform()
}

Cassandra not working after upgrading to Finchley.RELEASE

PFB the error details.
Caused by:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'session' defined in class path resource [com/walgreens/coupons/config/CommonConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.cassandra.config.CassandraSessionFactoryBean]: Factory method 'session' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cluster' defined in class path resource [com/walgreens/coupons/config/CommonConfig.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.datastax.driver.core.Cluster
build.gradle
import com.bmuschko.gradle.docker.tasks.image.Dockerfile
import java.text.SimpleDateFormat;
import org.apache.tools.ant.taskdefs.condition.Os
buildscript {
ext
{ springBootVersion = '2.0.1.RELEASE' }
{{dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath ("com.bmuschko:gradle-docker-plugin:3.2.1")
classpath ("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5")
classpath("au.com.dius:pact-jvm-provider-gradle_2.12:3.5.13")
classpath ("com.moowork.gradle:gradle-node-plugin:1.2.0")
}}}
}
plugins
{ //id "au.com.dius.pact" version "3.5.7" id "com.gorylenko.gradle-git-properties" version "1.4.17" id "de.undercouch.download" version "3.4.2" }
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.bmuschko.docker-remote-api'
apply plugin: 'jacoco'
apply plugin: 'maven-publish'
apply plugin: 'org.sonarqube'
apply plugin: 'au.com.dius.pact'
apply plugin: 'scala'
sourceCompatibility = 1.8
ext
{ springCloudVersion = 'Finchley.RELEASE' }
pact {
serviceProviders {
rxorder {
publish
{ pactDirectory = '/Users/sv/Documents/doccc/target/pacts' // defaults to $buildDir/pacts pactBrokerUrl = '[http://localhost:80|http://localhost/]' version=2.0 }
}
}
}
//start of integration tests changes
sourceSets {
integrationTest {
java
{ compileClasspath += main.output + test.output runtimeClasspath += main.output + test.output srcDir file('test/functional-api/java') }
resources.srcDir file('test/functional-api/resources')
}
}
configurations
{ integrationTestCompile.extendsFrom testCompile integrationTestRuntime.extendsFrom testRuntime }
//end of integration tests changes
dependencies {
//web (Tomcat, Logging, Rest)
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web'
// Redis
//compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-redis'
//Mongo Starter
compile group: 'org.springframework.boot', name:'spring-boot-starter-data-mongodb'
{{// Configuration processor - To Generate MetaData Files. The files are designed to let developers offer “code completion� as users are working with application.properties
compile group: 'org.springframework.boot', name: 'spring-boot-configuration-processor'
// Actuator - Monitoring
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
//Sleuth - Tracing
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-sleuth'
//Hystrix - Circuit Breaker
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-hystrix'
// Hystrix - Dashboard
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-hystrix-dashboard'
// Thymeleaf
compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf'
//Voltage
// Device Detection
//compile group: 'com.datastax.cassandra', name: 'cassandra-driver-core', version: '3.3.0'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-cassandra', version:'1.5.12.RELEASE'
compile('com.google.code.gson:gson:2.8.0')
compile('org.json:json:20170516')
//Swagger
compile group: 'io.springfox', name: 'springfox-swagger2', version:'2.8.0'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version:'2.8.0'
//Lombok
compileOnly group: 'org.projectlombok', name: 'lombok'
compile group: 'io.smartcat', name: 'cassandra-diagnostics-connector21', version: '1.4.10'
//Testing
//Spring WS Test
testCompile group: 'org.springframework.ws', name: 'spring-ws-test', version:'2.4.0.RELEASE'
testCompile('org.springframework.boot:spring-boot-starter-test')
{ exclude group: "com.vaadin.external.google", module:"android-json" }
//Pact
testCompile group: 'au.com.dius', name: 'pact-jvm-provider-gradle_2.12', version: '3.5.7'
testCompile group: 'au.com.dius', name:'pact-jvm-provider-junit_2.12',version:'3.5.13'
testCompile group: 'au.com.dius', name:'pact-jvm-consumer-junit_2.12', version:'3.5.13'
//Embedded mongo for testing
testCompile group: 'de.flapdoodle.embed', name:'de.flapdoodle.embed.mongo',version:'2.0.1'
//testCompile group: 'cz.jirutka.spring', name: 'embedmongo-spring', version: '1.1'
compile group: 'info.cukes', name: 'cucumber-jvm', version: '1.2.5'
testCompile group: 'info.cukes', name: 'cucumber-junit', version: '1.2.5'
testCompile group: 'info.cukes', name: 'cucumber-spring', version: '1.2.5'
testCompile('org.cassandraunit:cassandra-unit-spring:3.5.0.1')
{ exclude group: 'org.cassandraunit', module: 'cassandra-unit' }
// https://mvnrepository.com/artifact/org.cassandraunit/cassandra-unit-shaded
compile group: 'org.cassandraunit', name: 'cassandra-unit-shaded', version: '3.5.0.1'
// https://mvnrepository.com/artifact/org.hectorclient/hector-core
compile group: 'org.hectorclient', name: 'hector-core', version: '2.0-0'
integrationTestCompile group: 'org.springframework.ws', name: 'spring-ws-test', version:'2.4.0.RELEASE' //changes for integration tests
integrationTestCompile("org.springframework.boot:spring-boot-starter-test")
{ //changes for integration tests exclude group: "com.vaadin.external.google", module:"android-json" }
integrationTestCompile group: 'info.cukes', name: 'cucumber-junit', version: '1.2.5' //changes for integration tests
integrationTestCompile group: 'info.cukes', name: 'cucumber-spring', version: '1.2.5' //changes for integration tests}}
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
Thanks everyone for the help. We were able to resolve the issue by adding the following dependencies separately.
compile group: 'com.google.guava', name: 'guava', version: '23.2-jre'
compile group: 'org.apache.cassandra', name: 'cassandra-all', version: '3.11.3'

How do I import ok.io into android studio locally?

I have been trying to use ok.io, (version 1.14.1), locally in my project and it's been quite a struggle getting through the gradle requirements. My project requires that I include the source locally. I have managed to import the module but when attempting to run a build I end up with this error
Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve project :okio.
Unable to resolve dependency for ':app#debugAndroidTest/compileClasspath': Could not resolve project :okio.
Unable to resolve dependency for ':app#debugUnitTest/compileClasspath': Could not resolve project :okio.
Unable to resolve dependency for ':app#release/compileClasspath': Could not resolve project :okio.
Unable to resolve dependency for ':app#releaseUnitTest/compileClasspath': Could not resolve project :okio.
I had thought this solution would be the way to go as it says all modules need to have the same build types and flavours. But this has not made a difference.
My (app) build.gradle looks like this
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.some.app.id"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
debug {}
}
productFlavors {
}
compileOptions {
targetCompatibility 1.7
sourceCompatibility 1.7
}
}
dependencies {
.....
implementation project(path: ':okio')
}
The ok.io build.gradle looks like this
import com.github.jengelman.gradle.plugins.shadow.transformers.DontIncludeResourceTransformer
import com.github.jengelman.gradle.plugins.shadow.transformers.IncludeResourceTransformer
apply plugin: 'java-library'
apply plugin: 'org.jetbrains.kotlin.platform.jvm'
apply plugin: 'ru.vyarus.animalsniffer'
apply plugin: 'me.champeau.gradle.japicmp'
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: 'me.champeau.gradle.jmh'
apply from: "$rootDir/gradle/gradle-mvn-push.gradle"
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
jar {
manifest {
attributes('Automatic-Module-Name': 'okio')
}
}
animalsniffer {
sourceSets = [sourceSets.main]
}
configurations {
baseline
}
jmhJar {
def excludeAllBenchmarkLists = new DontIncludeResourceTransformer()
excludeAllBenchmarkLists.resource = "META-INF/BenchmarkList"
transform(excludeAllBenchmarkLists)
def includeCorrectBenchmarkList = new IncludeResourceTransformer()
includeCorrectBenchmarkList.resource = "META-INF/BenchmarkList"
includeCorrectBenchmarkList.file = new File("$rootDir/okio/jvm/build/classes/java/jmh/META-INF/BenchmarkList")
transform(includeCorrectBenchmarkList)
}
jmh {
// The JMH plugin currently requires the Shadow plugin also be installed.
// See: https://github.com/melix/jmh-gradle-plugin/issues/97#issuecomment-374866151
include = ['com\\.squareup\\.okio\\.benchmarks\\.SelectBenchmark.*']
duplicateClassesStrategy = 'warn'
}
dependencies {
signature 'org.codehaus.mojo.signature:java16:1.1#signature'
expectedBy project(':okio')
implementation deps.kotlin.stdLib.jdk6
compileOnly deps.animalSniffer.annotations
compileOnly deps.jsr305
testImplementation deps.test.junit
testImplementation deps.test.assertj
testImplementation deps.kotlin.test.jdk
baseline('com.squareup.okio:okio:1.14.1') {
transitive = false
force = true
}
jmh deps.jmh.core
jmh deps.jmh.generator
}
task japicmp(type: me.champeau.gradle.japicmp.JapicmpTask, dependsOn: 'jar') {
oldClasspath = configurations.baseline
newClasspath = files(jar.archivePath)
onlyBinaryIncompatibleModified = true
failOnModification = true
txtOutputFile = file("$buildDir/reports/japi.txt")
ignoreMissingClasses = true
includeSynthetic = true
classExcludes = [
'okio.SegmentedByteString', // internal
'okio.Util', // internal
]
methodExcludes = [
'okio.ByteString#getByte(int)', // became 'final' in 1.15.0
'okio.ByteString#size()', // became 'final' in 1.15.0
]
}
check.dependsOn(japicmp)
assemble.dependsOn(tasks['jmhJar'])
The module's structure in my project looks like this
Any advice on how to integrate ok.io locally and/or just "happy" module integration is greatly appreciated.

Android Studio doesn't compile test classes for Java library modules during Make Project

I have a multi-project Gradle build in Android Studio 2.2.3, containing Java library (core and codegen) and Android library (android) modules. Make Project shows executed tasks in Gradle console:
Executing tasks: [:android:generateDebugSources, :android:generateDebugAndroidTestSources, :android:mockableAndroidJar, :android:prepareDebugUnitTestDependencies, :android:compileDebugSources, :android:compileDebugAndroidTestSources, :android:compileDebugUnitTestSources, :codegen:compileJava, :core:compileJava]
But compileJava compiles only the main classpath, not tests, and testClasses tasks for core and codegen are not listed. On the other hand, ./gradlew build does run testClasses.
How can I make Android Studio compile tests for Java library modules as well?
settings.gradle:
include 'core'
include 'codegen'
include 'android'
Main build.gradle:
buildscript {
repositories {
maven {
url "http://10.122.85.159:9081/nexus/content/groups/public"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
url "http://10.122.85.159:9081/nexus/content/groups/public"
}
}
}
dependencies {
}
core/build.gradle:
apply plugin: 'java'
version = '1.0.0'
sourceCompatibility = '1.7'
sourceSets {
generated {
java {
srcDirs = ['src/generated/java']
}
}
}
test {
filter {
}
}
dependencies {
compile fileTree(dir: '../lib', include: '*.jar')
generatedCompile project(':core')
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
compile 'org.javatuples:javatuples:1.2'
}
codegen/build.gradle:
apply plugin: 'java'
dependencies {
compile project(':core')
compile group: 'com.squareup', name: 'javapoet', version: '1.8.0'
}
android/build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
minSdkVersion 24
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
disable 'OldTargetApi'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':core')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
}

Downloading for too long time with gradle in IDEA

When I start a new project,it take me too long time to download the whole jar libs(for more than 5 hours),how can I deal with it?
This is the code in my build.gradle file:
import com.sun.org.apache.xalan.internal.xsltc.cmdline.Compile
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'war'
sourceCompatibility = 1.7
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
compile 'javax:javaee-api:7.0'
compile 'mysql:mysql-connector-java:5.1.39'
compile 'jstl:jstl:1.2'
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.3'
compile 'org.mybatis:mybatis:3.4.1'
compile 'commons-fileupload:commons-fileupload:1.3.1'
compile 'org.springframework:spring-context:4.3.4.RELEASE'
compile 'org.springframework:spring-jdbc:4.3.4.RELEASE'
compile 'org.springframework:spring-webmvc:4.3.4.RELEASE'
compile 'org.springframework:spring-context-support:4.3.4.RELEASE'
compile 'org.projectlombok:lombok:1.16.6'
compile 'org.mybatis:mybatis-spring:1.3.0'
compile 'org.freemarker:freemarker:2.3.23'
compile 'org.jasypt:jasypt:1.9.2'
}
you can use the nearest maven repositories for gradle;
add the repositories into builde.gradle:
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
in builde.gradle:
buildscript {
repositories {
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
maven { url "https://repo.spring.io/plugins-release" }
}
dependencies {
classpath("org.springframework.build.gradle:propdeps-plugin:0.0.7")
classpath("org.asciidoctor:asciidoctor-gradle-plugin:1.5.3")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.0.5-2"
classpath("io.spring.gradle:docbook-reference-plugin:0.3.1")
}
}
details: https://pingcai.me/2016/12/16/Maven-Gradle-Resolve-Dependencies-%E9%80%9F%E5%BA%A6%E5%A5%87%E6%85%A2%E6%97%A0%E6%AF%94/

Resources