How to configure selenium tests with gradle? - selenium

i want to run selenium tests with gradle on jboss, and i was able to make the required configuration and i want to share it with the community.

I made a complete example here on my Github acccount.
My dependencies, using only mavenCentral repo are:
dependencies {
compile group: 'org.sikuli', name: 'sikuli-api', version: '1.0.+'
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.+'
compile group: 'commons-io', name: 'commons-io', version: '1.3.+'
compile group: 'junit', name: 'junit', version: '4.+'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.+'
compile group: 'net.sf.opencsv', name: 'opencsv', version: '2.+'
}
I would run JBoss7 as a service (on windows) instead of trying to execute it directly from Gradle. I wrote a script to register a service if you want to use it. Then, you just make a gradle task to execute the script with the "start" argument to start the service.

Solution is as follows:
gradle.build:
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'war'
apply plugin: 'findbugs'
//apply from:'http://github.com/breskeby/gradleplugins/raw/master/emmaPlugin/emma.gradle'
apply from: 'emma.gradle'
buildDir = 'build'
sourceCompatibility = 1.7
version = ''
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.gradle.api.plugins:gradle-cargo-plugin:0.6'
}
}
repositories {
mavenCentral()
mavenRepo url: 'http://repository.primefaces.org'
mavenRepo url: 'http://repository.jboss.org/nexus/content/groups/public'
mavenRepo url: 'http://repository.jboss.org/maven2'
mavenRepo url: 'http://maven.springframework.org/release'
mavenRepo url: 'http://repo1.maven.org/maven2'
mavenRepo url: 'http://git.solutionstream.com/nexus/content/repositories/thirdparty'
}
configurations {
compileOnly
weldEmbeddedTestRuntime { extendsFrom testRuntime }
jbossasRemoteTestRuntime { extendsFrom testRuntime, compileOnly }
}
sourceSets {
main {
compileClasspath = configurations.compile + configurations.compileOnly
}
test {
compileClasspath = compileClasspath + configurations.compileOnly
}
selenium {
compileClasspath = compileClasspath + configurations.compileOnly
}
}
dependencies {
//JSF
compile group: 'com.sun.faces', name: 'jsf-api', version: '2.1.22'
compile group: 'com.sun.faces', name: 'jsf-impl', version: '2.1.22'
compile 'org.ocpsoft.rewrite:rewrite-servlet:2.0.3.Final'
compile 'org.ocpsoft.rewrite:rewrite-config-prettyfaces:2.0.3.Final'
//Servlet
compile group: 'javax.servlet', name: 'jstl', version: '1.2'
providedCompile group: 'org.jboss.spec', name: 'jboss-javaee-6.0', version: '1.0.0.Final'
compile 'taglibs:standard:1.1.2'
compile group: 'org.springframework', name: 'spring-web', version: '3.2.2.RELEASE'
//Omnifaces
compile 'org.omnifaces:omnifaces:1.5'
//Prime Faces
compile group: 'org.primefaces', name: 'primefaces', version: '4.0-SNAPSHOT'
compile 'org.primefaces.themes:bootstrap:1.0.10'
// DB
compile group: 'org.springframework.data', name: 'spring-data-jpa', version: '1.3.1.RELEASE'
compile group: 'org.springframework', name: 'spring-aspects', version: '3.2.2.RELEASE'
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.9'
compile group: 'javax.inject', name: 'javax.inject', version: '1'
compile group: 'javax.enterprise', name: 'cdi-api', version: '1.0-SP4'
compile 'cglib:cglib-nodep:2.2.2'
//Hibernate / JPA
compile 'org.hibernate:hibernate-core:4.1.0.Final'
compile 'org.hibernate:hibernate-entitymanager:4.1.0.Final'
compile 'org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final'
//JSR-303
compile 'org.hibernate:hibernate-validator:4.3.1.Final'
// Spring Security
compile 'org.springframework.security:spring-security-core:3.1.4.RELEASE'
compile 'org.springframework.security:spring-security-web:3.1.4.RELEASE'
compile 'org.springframework.security:spring-security-config:3.1.4.RELEASE'
//Utility
compile 'com.google.guava:guava:14.0.1'
compile 'commons-lang:commons-lang:2.6'
compile 'org.apache.commons:commons-email:1.3.1'
compile 'com.typesafe:config:1.0.0'
compile 'joda-time:joda-time:2.2'
compile 'org.apache.geronimo.javamail:geronimo-javamail_1.4_mail:1.8.3'
compile 'org.slf4j:slf4j-api:1.7.2'
compile 'org.slf4j:jcl-over-slf4j:1.7.2'
compile 'org.slf4j:slf4j-log4j12:1.7.2'
//Mustache Templates
compile 'com.github.jknack:handlebars:1.0.0'
//Projects
//compile project(":ExtraValidators")
////TESTING DEPENDENCIES
testCompile 'com.googlecode.jmockit:jmockit:1.2'
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile 'com.h2database:h2:1.3.172'
//Spring Testing
testCompile 'org.springframework:spring-test:3.2.3.RELEASE'
/* Selenium */
seleniumCompile 'org.seleniumhq.selenium:selenium-java:2.33.0'
seleniumCompile 'junit:junit:4.11'
seleniumCompile 'org.slf4j:slf4j-api:1.7.2'
seleniumCompile 'org.slf4j:slf4j-log4j12:1.7.2'
seleniumCompile 'org.slf4j:jcl-over-slf4j:1.7.2'
/* Remote Jboss */
testCompile group: 'org.jboss.arquillian', name: 'arquillian-junit', version: '1.0.0-SNAPSHOT'
jbossasRemoteTestRuntime group: 'org.jboss.arquillian.container', name: 'arquillian-jbossas-remote-6', version: '1.0.0-SNAPSHOT'
jbossasRemoteTestRuntime group: 'org.jboss.jbossas', name: 'jboss-as-server', classifier: 'client', version: '6.1.0.Final', transitive: false
jbossasRemoteTestRuntime group: 'org.jboss.jbossas', name: 'jboss-as-profileservice', classifier: 'client', version: '6.1.0.Final'
}
task wrapper(type: Wrapper){
gradleVersion = '1.6'
}
eclipse {
classpath {
downloadSources=true
plusConfigurations += configurations.seleniumCompile
}
}
task selenium(type: Test) {
testClassesDir = sourceSets.selenium.output.classesDir
classpath = sourceSets.selenium.runtimeClasspath + files('src/selenium/resources-jbossas') + configurations.jbossasRemoteTestRuntime
}
you need to start jboss server manually then use the command gradlew clean selenium

copy this list to gradle.build for Mobile testing with appium, testng and selenium
// https://mvnrepository.com/artifact/cglib/cglib-nodep
compile 'cglib:cglib-nodep:3.2.6'
// https://mvnrepository.com/artifact/commons-codec/commons-codec
compile 'commons-codec:commons-codec:1.10'
// https://mvnrepository.com/artifact/org.apache.commons/commons-exec
compile 'org.apache.commons:commons-exec:1.3'
// https://mvnrepository.com/artifact/commons-io/commons-io
compile 'commons-io:commons-io:2.6'
// https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
compile 'org.apache.commons:commons-lang3:3.7'
// https://mvnrepository.com/artifact/commons-logging/commons-logging
compile 'commons-logging:commons-logging:1.2'
// https://mvnrepository.com/artifact/net.sourceforge.cssparser/cssparser
compile 'net.sourceforge.cssparser:cssparser:0.9.24'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
compile 'com.google.code.gson:gson:2.8.2'
// https://mvnrepository.com/artifact/com.google.guava/guava
compile 'com.google.guava:guava:23.0'
// https://mvnrepository.com/artifact/org.hamcrest/hamcrest-all
compile 'org.hamcrest:hamcrest-all:1.3'
// https://mvnrepository.com/artifact/net.sourceforge.htmlunit/htmlunit
compile 'net.sourceforge.htmlunit:htmlunit:2.29'
// https://mvnrepository.com/artifact/net.sourceforge.htmlunit/htmlunit-core-js
compile 'net.sourceforge.htmlunit:htmlunit-core-js:2.28'
// https://mvnrepository.com/artifact/org.seleniumhq.selenium/htmlunit-driver
compile 'org.seleniumhq.selenium:htmlunit-driver:2.29.2'
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
compile 'org.apache.httpcomponents:httpclient:4.5.4'
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore
compile 'org.apache.httpcomponents:httpcore:4.4.7'
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime
compile 'org.apache.httpcomponents:httpmime:4.5.4'
// https://mvnrepository.com/artifact/io.appium/java-client
compile 'io.appium:java-client:5.0.3'
// https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api
compile 'javax.servlet:javax.servlet-api:3.1.0'
// https://mvnrepository.com/artifact/com.beust/jcommander
compile 'com.beust:jcommander:1.72'
// https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-client
compile 'org.eclipse.jetty:jetty-client:9.4.8.v20171121'
// https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-http
compile 'org.eclipse.jetty:jetty-http:9.4.8.v20171121'
// https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-io
compile 'org.eclipse.jetty:jetty-io:9.4.8.v20171121'
// https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-util
compile 'org.eclipse.jetty:jetty-util:9.4.8.v20171121'
// https://mvnrepository.com/artifact/net.java.dev.jna/jna
compile 'net.java.dev.jna:jna:4.1.0'
// https://mvnrepository.com/artifact/net.java.dev.jna/jna-platform
compile 'net.java.dev.jna:jna-platform:4.1.0'
// https://mvnrepository.com/artifact/junit/junit
compile 'junit:junit:4.12'
// https://mvnrepository.com/artifact/net.sourceforge.htmlunit/neko-htmlunit
compile 'net.sourceforge.htmlunit:neko-htmlunit:2.28'
// https://mvnrepository.com/artifact/com.codeborne/phantomjsdriver
compile 'com.codeborne:phantomjsdriver:1.4.0'
// https://mvnrepository.com/artifact/org.w3c.css/sac
compile 'org.w3c.css:sac:1.3'
// https://mvnrepository.com/artifact/xalan/serializer
compile 'xalan:serializer:2.7.2'
// https://mvnrepository.com/artifact/org.eclipse.jetty.websocket/websocket-api
compile 'org.eclipse.jetty.websocket:websocket-api:9.4.8.v20171121'
// https://mvnrepository.com/artifact/org.eclipse.jetty.websocket/websocket-client
compile 'org.eclipse.jetty.websocket:websocket-client:9.4.8.v20171121'
// https://mvnrepository.com/artifact/org.eclipse.jetty.websocket/websocket-common
compile 'org.eclipse.jetty.websocket:websocket-common:9.4.8.v20171121'
// https://mvnrepository.com/artifact/xalan/xalan
compile 'xalan:xalan:2.7.2'
// https://mvnrepository.com/artifact/xerces/xercesImpl
compile 'xerces:xercesImpl:2.11.0'
// https://mvnrepository.com/artifact/xml-apis/xml-apis
compile 'xml-apis:xml-apis:2.0.2'
// https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java
compile 'org.seleniumhq.selenium:selenium-java:3.10.0'
// https://mvnrepository.com/artifact/commons-validator/commons-validator
compile 'commons-validator:commons-validator:1.6'
// https://mvnrepository.com/artifact/org.testng/testng
compile 'org.testng:testng:6.11'
// https://mvnrepository.com/artifact/net.sourceforge.jexcelapi/jxl
compile 'net.sourceforge.jexcelapi:jxl:2.6.12'

Related

Gradle Task has not declared any outputs despite executing actions

i use gradle-wrapper and have Gradle 6.8 installed.
Succesfull Runs:
bash gradlew check
bash gradlew test
Failed Runs:
`
Task :findMainClass FAILED
Caching disabled for task ':findMainClass' because:
Build cache is disabled
Task ':findMainClass' is not up-to-date because:
Task has not declared any outputs despite executing actions.
:findMainClass (Thread[Execution worker for ':',5,main]) completed. Took 0.001 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':findMainClass'.
'java.io.File org.gradle.api.tasks.SourceSetOutput.getClassesDir()'
`
This is my build.gradle:
`
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.2.RELEASE")
}
}
ext {
bootVersion = "1.5.2.RELEASE"
}
//apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
repositories {
mavenCentral()
//mavenLocal()
//maven { url "http://repo.springsource.org/snapshot" }
//maven { url "http://repo.springsource.org/milestone" }
maven { url "https://repo.spring.io/libs-snapshot" }
}
dependencies {
implementation group: 'org.springframework.cloud', name: 'spring-cloud-core', version: '1.2.9.RELEASE'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-spring-service-connector', version: '1.2.9.RELEASE'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-cloudfoundry-connector', version: '1.2.9.RELEASE'
implementation "org.springframework.boot:spring-boot-starter-actuator:${bootVersion}"
implementation "org.springframework.boot:spring-boot-starter-tomcat:${bootVersion}"
implementation "org.springframework.boot:spring-boot-starter-web:${bootVersion}"
implementation "org.springframework.boot:spring-boot-starter-data-jpa:${bootVersion}"
implementation "org.springframework.boot:spring-boot-starter-thymeleaf:${bootVersion}"
implementation 'com.amazonaws:aws-java-sdk:1.11.113'
runtimeOnly "org.yaml:snakeyaml:1.18"
runtimeOnly "mysql:mysql-connector-java:6.0.6"
implementation group: 'net.minidev', name: 'json-smart', version: '2.3'
}
task wrapper1(type: Wrapper) {
gradleVersion = '6.0.1'
}
`
and this is my gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=file:///tmp/my-project/gradle-6.8-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists
Can you help me to solve this issue?
I was trying to deploy an cloudfoundry test applciation: https://github.com/cloudfoundry-samples/cf-s3-demo

How to repair broken jar built from an IntellIJ gradle Kotlin project?

I try to build a working jar from my project by IntellIJ.
(I add the artifact and build it from the build menu)
I literally can build it as a clean helloworld but as I keep adding the dependencies it breaks.
The built artifact those not find my main class:
Error: Could not find or load main class hu.qlmdc.drp.HelloWorldKt
After a lot of tests I found the exact dependency causing the problem:
"com.microsoft.sqlserver:mssql-jdbc:6.2.2.jre8"
Without it the project works but I need the dependency.
What causes this?
How can I repair the artifact?
My gradle file:
plugins {
id "application"
id "java"
id "war"
id "org.jetbrains.kotlin.jvm" version "1.5.0"
}
group 'hu.qlmdc.drp'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
flatDir {
dirs 'lib'
}
maven { url 'http://repo.jenkins-ci.org/releases/' }
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib"
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: '1.5.0'
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: '1.5.0', ext: 'pom'
implementation "io.ktor:ktor-server-core:1.5.4"
implementation "io.ktor:ktor-server-netty:1.5.4"
implementation "io.ktor:ktor-metrics:1.5.4"
implementation "io.ktor:ktor-locations:1.5.4"
implementation "io.ktor:ktor-gson:1.5.4"
implementation "io.ktor:ktor-client-core:1.5.4"
implementation "io.ktor:ktor-client-apache:1.5.4"
implementation "ch.qos.logback:logback-classic:1.2.3"
//implementation 'mysql:mysql-connector-java:8.0.23'
implementation "com.microsoft.sqlserver:mssql-jdbc:6.2.2.jre8"
implementation "org.hibernate:hibernate-core:5.4.31.Final"
implementation "org.apache.httpcomponents:httpclient:4.5.13"
implementation "org.apache.httpcomponents:fluent-hc:4.5.13"
// Jenkins plugins
implementation group: 'org.jenkins-ci.plugins', name: 'credentials', version: '2.3.15', ext: 'jar'
implementation group: 'org.jenkins-ci.plugins', name: 'matrix-auth', version: '2.6.6', ext: 'jar'
implementation group: 'org.jenkins-ci.plugins.workflow', name: 'workflow-cps', version: '2.90', ext: 'jar'
implementation fileTree(dir: 'lib', include: ['*.jar'])
}

gradle : java tests ran twice

I am making a skeletton of a java project; the gradle build file has an annoying problem : tests are ran twice, one time by the task 'JUnitPlatformTest' and a second time by the task 'test'.
The first one seems to trigger the second, so I can't disable it, and I would like to keep the second one as there is a little difference between them : the first one is in the console (of intelliJ) and the second uses the integrated intelliJ window.
here is gradle.build
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.3'
classpath group: 'de.dynamicfiles.projects.gradle.plugins', name: 'javafx-gradle-plugin', version: '8.8.2'
classpath 'eu.appsatori:gradle-fatjar-plugin:0.3'
}
}
plugins {
id 'java'
id 'edu.sc.seis.launch4j' version '2.4.4'
}
apply plugin: 'org.junit.platform.gradle.plugin'
apply plugin: 'javafx-gradle-plugin'
apply plugin: 'eu.appsatori.fatjar'
junitPlatform {
platformVersion '1.0.3'
reportsDir file('build/test-results/junit-platform')
enableStandardTestTask true
//show results summary even on success.
details details.SUMMARY
filters {
tags {
// Framework tests need to be run only when required to verify that this framework is still working.
exclude "Framework"
}
includeClassNamePatterns '.*Test', '.*Tests'
}
}
group 'lorry'
version '1'
sourceCompatibility = 1.8
//mainClassName="imports.ColorfulCircles"
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
def final junitVersion = "5.2.0"
compile group: 'com.google.inject', name: 'guice', version: '4.1.0'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.2'
compile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: junitVersion
//compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.11.0'
compile group: 'org.assertj', name: 'assertj-core', version: '3.9.0'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: junitVersion
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.7.22'
testRuntime group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: junitVersion
compile 'org.hamcrest:hamcrest-all:1.3'
testCompile "org.testfx:testfx-core:4.0.13-alpha"
testCompile 'org.testfx:testfx-junit5:4.0.13-alpha'
testRuntime 'org.testfx:openjfx-monocle:8u60-b27'
}
test {
useJUnitPlatform()
jvmArgs = [
"-Dtestfx.robot=glass",
"-Dtestfx.headless=true",
"-Dprism.order=sw",
"-Dprism.text=t2k",
"-Dheadless.geometry=1920x1200-32"
]
}
test.dependsOn 'clean'
jfx {
// minimal requirement for jfxJar-task
mainClass = 'imports.ColorfulCircles'
// minimal requirement for jfxNative-task
vendor = 'lolveley'
}
jar {
baseName = 'executable3'
version = ''
manifest {
attributes(
'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
'Main-Class': 'imports.ColorfulCircles'
)
}
}
launch4j {
outfile='bibliotek-v3.exe'
mainClassName = 'imports.ColorfulCircles'
icon = "${projectDir}\\icons\\hands2.ico"
copyConfigurable = project.tasks.fatJar.outputs.files
jar = "lib/${project.tasks.fatJar.archiveName}"
//headerType = "console"
//jar = "${buildDir}\\productFatJar\\fat.jar"
}
junitPlatformTest {
jvmArgs = [
"-Dtestfx.robot=glass",
"-Dtestfx.headless=true",
"-Dprism.order=sw",
"-Dprism.text=t2k",
"-Dheadless.geometry=1920x1200-32"
]
}
and here is the result:
Testing started at 19:25 ...
19:25:01: Executing task 'test'...
> Task :compileJava
> Task :processResources NO-SOURCE
> Task :classes
> Task :clean
> Task :compileTestJava
> Task :processTestResources NO-SOURCE
> Task :testClasses
> Task :junitPlatformTest
constructeur appelé
Before all
Before each
my test 1
Before each
my test 2
This test method should be run
Test run finished after 3630 ms
[ 4 containers found ]
[ 0 containers skipped ]
[ 4 containers started ]
[ 0 containers aborted ]
[ 4 containers successful ]
[ 0 containers failed ]
[ 7 tests found ]
[ 0 tests skipped ]
[ 7 tests started ]
[ 0 tests aborted ]
[ 7 tests successful ]
[ 0 tests failed ]
> Task :test
constructeur appelé
Before all
Before each
my test 1
Before each
my test 2
This test method should be run
BUILD SUCCESSFUL in 13s
5 actionable tasks: 5 executed
19:25:15: Task execution finished 'test'.
According to this official website, ...
The JUnit Platform Gradle Plugin is deprecated
The very basic junit-platform-gradle-plugin developed by the JUnit team was deprecated in JUnit Platform 1.2 and will be discontinued in 1.3. Please switch to Gradle’s standard test task.
So you should remove this plugin from your build file and, if necessary, try to port the remaining settings to the test task of the java plugin.

Cannot change dependencies of configuration

After I added copyBootstrap to build.gradle I am getting the next error when try to run the build task:
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project '.
Cannot change dependencies of configuration ':providedCompile' after it has been included in dependency resolution.
How could this issue be solved? I have searched on Internet but no solutions were found. I got the copyBootstrap task from this link. Their goal is to extract all content from org.webjars group jars to a specific path.
I am using Gradle 3.2 and Intellij IDEA 2016.2.5
//group 'org'
//version '1.0-SNAPSHOT'
task wrapper(type: Wrapper) {
gradleVersion = '3.2'
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.akhikhl.gretty:gretty:1.4.0'
}
}
repositories {
mavenCentral()
jcenter()
}
//apply plugin: 'java'
//apply plugin: 'eclipse-wtp'
//apply from: 'https://raw.github.com/akhikhl/gretty/master/pluginScripts/gretty.plugin'
apply plugin: 'war'
apply plugin: 'org.akhikhl.gretty'
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
//compile group: 'org.akhikhl.gretty', name: 'gretty', version: '1.4.0'
// ********************************************************************************************************
// SPRING FRAMEWORK, ORM Y H2DB
// ********************************************************************************************************
compile group: 'org.springframework', name: 'spring-webmvc', version: '4.3.4.RELEASE'
compile group: 'org.springframework', name: 'spring-orm', version: '4.3.4.RELEASE'
compile group: 'org.springframework', name: 'spring-jdbc', version: '4.3.4.RELEASE'
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.2.3.Final'
// ********************************************************************************************************
// JACKSON DATABIND
// ********************************************************************************************************
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.4'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.4'
// ********************************************************************************************************
// THYMELEAF
// ********************************************************************************************************
compile group: 'org.thymeleaf', name: 'thymeleaf-spring4', version: '3.0.2.RELEASE'
// ********************************************************************************************************
// SERVLET
// ********************************************************************************************************
compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
// ********************************************************************************************************
// MYSQL CONNECTOR
// ********************************************************************************************************
//compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.5' issues with time zone
compile 'mysql:mysql-connector-java:5.1.6'
// ********************************************************************************************************
// WEB RESOURCES
// ********************************************************************************************************
compile group: 'org.webjars', name: 'angularjs', version: '1.5.8'
compile group: 'org.webjars', name: 'jquery', version: '2.1.4'
compile group: 'org.webjars', name: 'bootstrap', version: '3.3.7'
compile group: 'org.webjars', name: 'jquery-ui', version: '1.12.1'
compile group: 'org.webjars', name: 'modernizr', version: '2.8.3'
// ********************************************************************************************************
// JUNIT AND SPRING TEST
// ********************************************************************************************************
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.springframework', name: 'spring-test', version: '4.3.4.RELEASE'
// ********************************************************************************************************
// GOOGLE DRIVE API
// ********************************************************************************************************
compile group: 'com.google.api-client', name: 'google-api-client', version: '1.22.0'
compile group: 'com.google.apis', name: 'google-api-services-drive', version: 'v2-rev245-1.22.0'
compile group: 'com.google.api-client', name: 'google-api-client-java6', version: '1.22.0'
compile group: 'com.google.oauth-client', name: 'google-oauth-client-jetty', version: '1.22.0'
// ********************************************************************************************************
// DROPBOX API
// ********************************************************************************************************
compile group: 'com.dropbox.core', name: 'dropbox-core-sdk', version: '1.8.2'
// ********************************************************************************************************
// TWITTER API
// ********************************************************************************************************
compile group: 'org.twitter4j', name: 'twitter4j-core', version: '4.0.5'
// compile group: 'org.slf4j', name: 'slf4j-mylearn.api', version: '1.7.21'
// compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.21'
// compile files("twitter/main/webapp/") // add this path as a classpath
}
task copyBootstrap(type: Copy) {
into "$buildDir/static_resources"
configurations.compile
.files({ it.group.equals("org.webjars")})
.each {
from zipTree(it)
}
}
//build.dependsOn(copyBootstrap)
task copyToLib2(type: Copy) {
into "$buildDir/output/libs"
from configurations.runtime
}
war {
archiveName = 'ROOT.war'
destinationDir = file('webapps')
}
// ********************************************************************************************************
// GRETTY SETTINGS
// ********************************************************************************************************
/* Change context path (base url). otherwise defaults to name of project */
gretty {
port = 8081
contextPath = ''
}
This problem seems to be related to the org.akhikhl.gretty plugin you are trying to use. If I try to build a project using the above gradle file I get the following output:
C:\ws\PLAYGROUND\test123>gradle wrapper --stacktrace
Changed dependencies of configuration ':providedCompile' after it has been included in dependency resolution. This behaviour has been deprecated and is cheduled to be removed in Gradle 3.0.
Changed dependencies of parent of configuration ':compile' after it has been resolved. This behaviour has been deprecated and is scheduled to be removed in Gradle 3.0
Changed strategy of configuration ':compile' after it has been resolved. This behaviour has been deprecated and is scheduled to be removed in Gradle 3.0
Changed dependencies of configuration ':grettyProvidedCompile' after it has been included in dependency resolution. This behaviour has been deprecated and is scheduled to be removed in Gradle 3.0.
⋮
* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'test123'.
at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:79)
at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:74)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61)
⋮
Caused by: org.gradle.api.InvalidUserDataException: Cannot change dependencies of configuration ':compile' after it has been resolved.
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.validateMutation(DefaultConfiguration.java:578)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$2.run(DefaultConfiguration.java:137)
⋮
at org.akhikhl.gretty.GrettyPlugin$_addDependencies_closure11.doCall(GrettyPlugin.groovy:130)
⋮
That is the gretty plugin seems to use functionality that has been removed with gradle 3.0
There is issue #306 that has been reported a short time ago which describes pretty much your problem.
Given the number of open issues for such a small project and the lack of activity on the issues, I don't think this plugin is much of a help and you will probably be better off using something different.

Failed to instantiate spec 'KernelTest'

I only try spock test, and get "Failed to instantiate spec 'KernelTest'", here is my full code
following is my code:
// build.gradle
apply plugin: 'groovy'
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.9'
compile gradleApi()
testCompile 'junit:junit:+'
testCompile project(":ro")
testCompile 'org.spockframework:spock-core:1.0-groovy-2.3'
}
my test is:
// KernelTest.groovy
package ro.gd
class KernelTest extends spock.lang.Specification {
def 'test smth'() {
expect: 1 == 1
}
}
it raise:
ro.gd.KernelTest > initializationError FAILED
org.spockframework.util.InternalSpockError
Caused by: java.lang.ExceptionInInitializerError at KernelTest.groovy:-1
Caused by: groovy.lang.GroovyRuntimeException at KernelTest.groovy:-1
I can get it to work with the latest gradle if I change ro/build.gradle to use a specific version of groovy:
compile 'org.codehaus.groovy:groovy-all:2.3.9'
And then change the dependencies of ro-gd/build.gradle to:
dependencies {
compile gradleApi()
testCompile project(":ro")
testCompile 'org.spockframework:spock-core:1.0-groovy-2.3', {
exclude module: 'groovy-all'
}
}