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
After creating new java gradle project added following dependencies in build file.
enter image description here
dependencies {
// Use JUnit Jupiter for testing.
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2'
// This dependency is used by the application.
implementation 'com.google.guava:guava:30.1.1-jre'
// https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java
implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.3.0'
// https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager
implementation group: 'io.github.bonigarcia', name: 'webdrivermanager', version: '5.3.0'
// https://mvnrepository.com/artifact/org.testng/testng
testImplementation group: 'org.testng', name: 'testng', version: '7.6.1'
// https://mvnrepository.com/artifact/org.apache.poi/poi
implementation group: 'org.apache.poi', name: 'poi', version: '5.2.2'
// https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api
implementation("javax.annotation:javax.annotation-api:1.3.2")
}
Then following popup appeared on vs code.
"Do you want to synchronize the Java classpath/configuration" once and for all? with yes/always/never option
I tried selecting each option in new project. Still after doing gradle build none of dependency downloaded
So if I am writing WebDriver or WebDriverManager I am not getting import option in quick fix
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'])
}
I'm trying to format the date returned by my rest services application which works fine in my embedded development environment (using https://github.com/akhikhl/gretty).
Some of my webservices are returning dates as string and I'm having different results in different environments.
In Glassfish 5.0 my dates are as 2017-12-05T21:37:24Z[UTC] while Jetty returns 2017-12-05T21:37:24+01:00 (CEST) which is parsable from my angularJS frontend application.
I have the following build.gradle build script in which none of the dependencies is set as provided.
/************* BUILD CONFIGURATION ***************/
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.akhikhl.gretty:gretty:2.0.0'
classpath 'org.hibernate:hibernate-gradle-plugin:5.2.11.Final'
}
}
// Apply the java plugin to add support for Java
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'war'
apply plugin: 'org.akhikhl.gretty'
apply plugin: 'org.hibernate.orm'
hibernate {
enhance {
enableDirtyTracking = true
}
}
gretty {
httpPort = 8080
contextPath = '/restapi'
fastReload = true
// ... many more properties
}
/************* RUNTIME CONFIGURATION ***************/
war.archiveName "restapi.war"
// In this section you declare where to find the dependencies of your project
repositories {
// Use 'jcenter' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
mavenCentral()
jcenter()
}
def jersey_version = 2.26
// In this section you declare the dependencies for your production and test code
dependencies {
// The production code uses the SLF4J logging API at compile time
compile 'org.slf4j:slf4j-api:1.7.21'
compile group: 'org.jboss.spec', name: 'jboss-javaee-7.0', version:'1.0.3.Final'
// groovy
compile 'org.codehaus.groovy:groovy-all:2.4.7'
// rest dependencies
compile 'javax.ws.rs:javax.ws.rs-api:2.0.1'
compile 'org.glassfish.jersey.containers:jersey-container-servlet:' + jersey_version
compile group: 'org.glassfish.jersey.media', name: 'jersey-media-moxy', version: jersey_version
compile group: 'org.glassfish.jersey.ext', name: 'jersey-entity-filtering', version: jersey_version
// id scrambling dependency
compile 'org.hashids:hashids:1.0.1'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'
compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.1'
compile group: 'commons-codec', name: 'commons-codec', version: '1.11'
// database
compile 'javax.el:el-api:2.2'
compile 'mysql:mysql-connector-java:5.1.18'
compile 'org.hibernate:hibernate-core:5.2.11.Final'
compile group: 'org.hibernate', name: 'hibernate-c3p0', version: '5.2.11.Final'
compile 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final'
compile 'org.hibernate:hibernate-entitymanager:5.2.11.Final'
}
I tried using Jackson instead of MOXy by registering a feature in my (jersey) Application class but as soon as I register a whatever Feature in my application it breaks resulting in 404 errors at every resource request. That said I don't know if using Jackson or adding another Feature to manipulate the resulting date object (to even return a timestamp instead of an ISO date.
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'