Gradle doesn't download correct version - gradle

I want to download dependencies compile 'mule-devkit-annotations-3.3.2.jar'.
But instead of downloading 3.3.2, it download version 3.4.2.
Here is my build.gradle file
import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'application'
//apply plugin: 'mule'
//the naming of this artifact
group = 'com.my.project'
version = '0.9.0'
description = "Description here"
//dependencies versions
ext {
muleVersion = '3.6.2'
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
//application properties
mainClassName = 'org.mule.MuleServer'
repositories {
mavenLocal()
maven { url "https://repository.mulesoft.org/nexus-ee/content/repositories/releases-ee/" }
}
configurations {
compile
}
dependencies {
compile group: 'ca.uhn.hapi', name: 'hapi-base', version:'2.2'
compile group: 'ca.uhn.hapi', name: 'hapi-structures-v231', version:'2.2'
compile group: 'com.google.guava', name: 'guava', version:'18.0'
compile group: 'com.googlecode.json-simple', name: 'json-simple', version:'1.1.1'
compile group: 'com.mulesoft.muleesb.modules', name: 'mule-module-data-mapper', version:muleVersion
compile group: 'com.sun.codemodel', name: 'codemodel', version:'2.2'
compile group: 'com.sun.mail', name: 'javax.mail', version:'1.5.2'
compile group: 'com.sun.xml.bind', name: 'jaxb1-impl', version:'2.0'
compile(group: 'com.sun.xml.bind', name: 'jaxb-xjc', version:'2.2.7') {
exclude(module: 'jaxb-core')
exclude(module: 'jaxb-impl')
}
compile group: 'commons-beanutils', name: 'commons-beanutils', version:'1.8.0'
compile group: 'javax.activation', name: 'activation', version:'1.1.1'
compile group: 'javax.xml', name: 'jax-qname', version:'1.1'
compile group: 'javax.xml', name: 'namespace', version:'1.0.1'
compile group: 'javax.xml.bind', name: 'jaxb-api', version:'2.2.2'
compile group: 'javax.xml.parsers', name: 'jaxp-api', version:'1.4.5'
compile group: 'joda-time', name: 'joda-time', version:'2.6'
compile group: 'junit', name: 'junit', version:'4.9'
compile group: 'log4j', name: 'apache-log4j-extras', version:'1.2.17'
compile group: 'mockobjects', name: 'mockobjects-core', version:'0.09'
compile group: 'net.sf.json-lib', name: 'json-lib', version:'2.4', classifier:'jdk15'
compile group: 'opensymphony', name: 'oscore', version:'2.2.4'
compile group: 'org.apache.ftpserver', name: 'ftplet-api', version:'1.0.6'
compile group: 'org.apache.ftpserver', name: 'ftpserver-core', version:'1.0.6'
compile group: 'org.apache.geronimo.specs', name: 'geronimo-javamail_1.4_spec', version:'1.7.1'
compile group: 'org.apache.mina', name: 'mina-core', version:'2.0.4'
compile group: 'org.apache.sshd', name: 'sshd-core', version:'0.6.0'
compile group: 'org.bitbucket.dollar', name: 'dollar', version:'1.0-beta3'
compile group: 'org.bouncycastle', name: 'bcpkix-jdk15on', version:'1.52'
compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version:'1.52'
compile group: 'org.fusesource.jansi', name: 'jansi', version:'1.8'
compile group: 'org.glassfish.extras', name: 'bean-validator', version:'4.0.0.Alpha3'
compile group: 'org.kitchen-eel', name: 'json-schema-validator', version:'1.3.0'
compile group: 'org.mockito', name: 'mockito-core', version:'1.9.5'
compile group: 'org.mule', name: 'mule-core', version:muleVersion
compile group: 'org.mule.modules', name: 'marketo-connector', version:'1.2.5'
compile group: 'org.mule.modules', name: 'mule-module-apikit', version:'1.3'
compile group: 'org.mule.modules', name: 'mule-module-apple-push', version:'4.0.0'
compile group: 'org.mule.modules', name: 'mule-module-devkit-support', version:muleVersion
compile group: 'org.mule.modules', name: 'mule-module-ms-dynamics-crm-ondemand', version:'1.8.3'
compile group: 'org.mule.modules', name: 'mule-module-ms-dynamics-crm-onpremise', version:'1.8.3'
compile group: 'org.mule.modules', name: 'mule-module-s3', version:'2.8.3'
compile group: 'org.mule.modules', name: 'mule-module-twilio', version:'1.4'
compile 'org.mule.tools.devkit:mule-devkit-annotations:3.3.2'
testCompile group: 'org.mule.tests', name: 'mule-tests-functional', version:muleVersion
testCompile group: 'com.cloveretl', name: 'cloveretl-engine', version:muleVersion
}
distTar.enabled = false
task buildZip (type: Zip){
def muleconfig='local'
def muleenv='local'
def filename = 'twilio' + '-'+ version
if(project.hasProperty('mule_config') ){
muleconfig = mule_config
}
if(project.hasProperty('mule_env') ){
muleenv = mule_env
}
doFirst{
println "Copying lib"
copy {
from configurations.compile
into 'build/resources/lib'
}
println "Copying src/main/app"
copy {
from 'src/main/app'
into 'build/resources/classes'
filter(ReplaceTokens, tokens: [muleconfig: muleconfig, muleenv: muleenv])
}
copy {
from 'src/main/app'
into 'build/resources/'
filter(ReplaceTokens, tokens: [muleconfig: muleconfig, muleenv: muleenv])
}
println "Copying src/main/api"
copy {
from 'src/main/api'
into 'build/resources/classes'
}
println "Copying build/resources/main"
copy {
from 'build/resources/main'
into 'build/resources/classes'
}
println "Copying deployement script"
copy {
from 'src/deployment-script'
into 'build/deployment-script'
filter(ReplaceTokens, tokens: [filename: filename])
}
}
doLast{
println "Copying zip file to deployment-script"
copy {
from 'build/distributions/'
include '*.zip'
into 'build/deployment-script'
rename ('build/distributions/*.zip',
'build/distributions/${filename}')
}
}
println "Building zip file"
from 'build/resources/'
exclude 'build/resource/main'
}
The mule-module-twilio-1.4.jar is correctly downloaded based on the version stated above.
Any suggestion would be appreciated.

You can force dependency version with gradle, but be aware that code which transitively depends on newer version may break
configurations.all {
resolutionStrategy {
force 'org.mule.tools.devkit:mule-devkit-annotations:3.3.2'
}
}

Related

Set VM option for TestNG in Gradle

I need to pass VM option argument to gradle. So far I configured it in IntelliJ as on the screen below and it works fine, but when I run the tests through gradle commands it doesn't work.
I need to pass -javaagent:"C:\aspectjweaver-1.9.5.jar" somewhere in the code. I tried jvmArgs and gradle.properties but no success.
Is there any way to make it working?
My build.gradle file:
plugins {
id 'java'
id 'maven'
}
sourceCompatibility = 1.12
targetCompatibility = 1.12
repositories {
maven { url "http://repo.maven.apache.org/maven2" }
maven { url "https://dl.bintray.com/cbeust/maven/" }
maven { url "https://plugins.gradle.org/m2/" }
}
tasks.withType(Test) {
outputs.upToDateWhen { false }
environment 'driver_type', project.hasProperty('driver_type') ? project.driver_type : 'chrome'
environment 'env', project.hasProperty('env') ? project.env : 'dev'
useTestNG() {
if (project.getProperties().get("env") == "prod") {
suites 'src/test/resources/testSuites/testng_prod.xml'
} else if (project.getProperties().get("env") == "stg") {
suites 'src/test/resources/testSuites/testng_stg.xml'
} else if (project.getProperties().get("env") == "dev") {
suites 'src/test/resources/testSuites/testng_dev.xml'
}
}
testLogging {
events "PASSED", "SKIPPED", "FAILED"
showExceptions true
exceptionFormat = 'full'
}
}
dependencies {
compile group: 'org.aspectj', name: 'aspectjweaver', version: "$aspectjVersion"
compile group: 'org.aspectj', name: 'aspectjrt', version: "$aspectjVersion"
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '3.15'
compile group: 'org.seleniumhq.selenium', name: 'selenium-api', version: "$seleniumVersion"
compile group: 'org.seleniumhq.selenium', name: 'selenium-server', version: "$seleniumVersion"
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: "$seleniumVersion"
compile group: 'org.seleniumhq.selenium', name: 'selenium-support', version: "$seleniumVersion"
compile group: 'org.testng', name: 'testng', version: '6.14.3'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.0'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.0'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.8.0'
compile group: 'commons-io', name: 'commons-io', version: '2.5'
compile group: 'org.apache.commons', name: 'commons-csv', version: '1.4'
compile group: 'org.apache.poi', name: 'poi', version: '3.14'
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '3.14'
compile group: 'com.opencsv', name: 'opencsv', version: '3.8'
compile group: 'org.assertj', name: 'assertj-core', version: '3.13.2'
compile group: 'com.mashape.unirest', name: 'unirest-java', version: '1.4.9'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
compile group: 'com.google.guava', name: 'guava', version: '28.1-jre'
compile group: 'log4j', name: 'log4j', version: '1.2.16'
compile group: 'com.aventstack', name: 'extentreports', version: '4.0.9'
compileOnly 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'org.projectlombok:lombok:1.18.10'
}
The doFirst did the job. Also I added ${aspectPath} to gradle.properties
tasks.withType(Test) {
useTestNG() {
...
}
doFirst {
jvmArgs "-javaagent:${aspectPath}"
}
}

Kotlin 1.3+ breaking SLF4J/log4j

I'm attempting to upgrade a project to Kotlin 1.3, but I'm facing trouble because we use HikariCP and a number of other libraries that use SLF4J/log4j and all of them get broken for some reason on Kotlin 1.3 and above.
The issue occurs just by changing the Kotlin version. Why is a change of Kotlin effecting SLF4J/log4j behavior?
java.lang.NoSuchMethodError: org.apache.log4j.Level.isGreaterOrEqual(Lorg/apache/log4j/Priority;)Z
at org.apache.log4j.Category.isDebugEnabled(Category.java:736)
at org.slf4j.impl.Log4jLoggerAdapter.debug(Log4jLoggerAdapter.java:251)
at com.zaxxer.hikari.HikariConfig.attemptFromContextLoader(HikariConfig.java:901)
at com.zaxxer.hikari.HikariConfig.setDriverClassName(HikariConfig.java:474)
at ps.eden.server.game.system.mysql.SQLManager.init(SQLManager.java:86)
This is the gradle build config we use, the only difference in ours is the version is 1.2.71 rather than 1.3.11:
buildscript {
ext.kotlin_version = '1.3.11'
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.2'
}
}
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'application'
mainClassName = "ps.eden.server.Eden"
group 'ps.eden'
version '1.4.0'
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_8
eclipse {
classpath {
containers 'org.jetbrains.kotlin.core.KOTLIN_CONTAINER'
}
}
compileKotlin {
kotlinOptions.suppressWarnings = true
}
sourceSets {
main.kotlin.srcDirs += 'src/main/kotlin'
main.java.srcDirs += 'src/main/java'
}
repositories {
jcenter()
flatDir { dirs 'lib' }
maven { url 'https://jitpack.io' }
maven { url "https://dl.bintray.com/kotlin/kotlinx/" }
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile group: 'org.jetbrains.kotlin', name: 'kotlin-scripting-common', version: "$kotlin_version"
compile group: 'org.jetbrains.kotlin', name: 'kotlin-scripting-jvm', version: "$kotlin_version"
compile group: 'org.jetbrains.kotlin', name: 'kotlin-scripting-jvm-host', version: "$kotlin_version"
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.47'
compile group: 'joda-time', name: 'joda-time', version: '2.10.1'
compile(group: 'com.zaxxer', name: 'HikariCP', version: '3.3.0') {
exclude module: 'slf4j-api'
}
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.8.1'
compile group: 'org.apache.commons', name: 'commons-email', version: '1.5'
compile group: 'org.apache.commons', name: 'commons-compress', version: '1.18'
compile(group: 'org.apache.hadoop', name: 'hadoop-common', version: '3.1.1') {
exclude module: 'slf4j-api'
exclude module: 'slf4j-log4j'
exclude module: 'slf4j-log412j'
}
compile group: 'org.apache.ant', name: 'ant', version: '1.10.5'
compile group: 'it.unimi.dsi', name: 'fastutil', version: '8.2.2'
compile group: 'io.netty', name: 'netty-all', version: '4.1.32.Final'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
compile group: 'org.reflections', name: 'reflections', version: '0.9.11'
compile group: 'com.github.salomonbrys.kotson', name: 'kotson', version: '2.5.0'
compile group: 'com.mashape.unirest', name: 'unirest-java', version: '1.4.9'
compile 'com.github.rockaport:alice:0.9.0'
compile group: 'at.favre.lib', name: 'bcrypt', version: '0.6.0'
compile group: 'net.openhft', name: 'zero-allocation-hashing', version: '0.8'
compile('net.dv8tion:JDA:3.8.1_437') {
exclude module: 'opus-java'
}
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.1'
}
compileJava {
options.encoding = "UTF-8"
//enable compilation in a separate daemon process
options.fork = true
//enable incremental compilation
options.incremental = true
}
You're using kotlin scripting libraries, in particular kotlin-scripting-jvm-host, which pulls the kotlin compiler jar. You can try to use kotlin-scripting-jvm-host-embeddable instead: it depends on the "embeddable" version of the compiler jar, where bundled 3-rd party classes are "shaded".
Edit: the kotlin-scripting-jvm-host-embeddable is available starting from Kotlin version 1.3.20 (at the moment of writing - only in the pre-release form).

Why is my gradle task skipped when executed during build?

I am currently migrating an application from maven to gradle (4.10.2).
In maven, a tar.gz-file would be generated with configuration, dependencies and some empty directories that would then be used by the application during runtime.
In gradle i am using the distribution plugin to create the tar.gz using the distTar-Task.
To create the empty directories inside the tar.gz, i create them in the build-directory and then have them copied by distTar into the tar.gz.
I managed to finally get this by creating a task createEmptyDirectories that would just create the directories and be done with it.
distTar would dependOn this task so that the directories are created before the tar.gz or so i thought.
The task createEmptyDirectories however is always skipped during build (using gradle clean build):
:createEmptyDirectories (Thread[Daemon worker Thread 7,5,main]) started.
> Task :createEmptyDirectories
Skipping task ':createEmptyDirectories' as it has no actions.
:createEmptyDirectories (Thread[Daemon worker Thread 7,5,main]) completed. Took 0.0 secs.
When i run the task by itself using gradle createEmptyDirectories the task is executed properly:
> Configure project :
build/mailmanager/var/rtc/command_control created[true]
build/mailmanager/var/rtc/resources created[true]
build/mailmanager/var/log created[true]
What am i doing wrong? And is there a better way to get those empty directories into the tar?
Here is my build.gradle:
buildscript {
dependencies {
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.8'
classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.15'
}
}
plugins {
id 'org.asciidoctor.convert' version '1.5.3'
id 'java'
id 'distribution'
}
group = 'de.printcom'
version = '4.4.0'
description = 'MailManager'
sourceCompatibility = 1.8
targetCompatibility = 1.8
//mainClassName = 'de.printcom.mailmanager.StartManagerWithoutUi'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
task('createEmptyDirectories') {
dependsOn jar
boolean created = new File(project.buildDir.name + "/mailmanager/var/rtc/command_control").mkdirs()
System.println(project.buildDir.name + "/mailmanager/var/rtc/command_control created[" + created + "]")
created = new File(project.buildDir.name + "/mailmanager/var/rtc/resources").mkdirs()
System.println(project.buildDir.name + "/mailmanager/var/rtc/resources created[" + created + "]")
created = new File(project.buildDir.name + "/mailmanager/var/log").mkdirs()
System.println(project.buildDir.name + "/mailmanager/var/log created[" + created + "]")
}
distTar {
dependsOn check, createEmptyDirectories
compression = Compression.GZIP
extension = 'tar.gz'
}
distributions {
main {
contents {
into("mailmanager/lib") {
from jar
from configurations.runtime
fileMode = 744
}
from("src/main/scripts/release_preprocessing/Release_4_3_0/Preprocessing") {
into("mailmanager/sql")
fileMode = 750
}
from("src/main/scripts/release_preprocessing/Release_4_3_0/Rollback") {
into("mailmanager/sql")
}
from("src/main/scripts/") {
include("startup.sh")
into("mailmanager/bin")
}
from("src/main/scripts/commands") {
include("*.mmc")
into("mailmanager/commands")
fileMode = 640
}
from("src/main/scripts/configuration") {
include("*.mmc")
into("mailmanager/commands")
fileMode = 640
}
from("src/main/resources/properties/deploy") {
include("default.properties", "live.properties", "test.properties", "wallet_example.properties")
into("mailmanager/conf")
rename("default.properties", "default.properties.template")
rename("live.properties", "live.properties.template")
rename("test.properties", "test.properties.template")
rename("wallet_example.properties", "wallet_example.properties.template")
fileMode = 640
}
from("src/main/resources") {
include("quartz.properties", "ehcache.xml")
into("mailmanager/conf")
fileMode = 640
}
from(project.buildDir.name + "/classes") {
include("log4j-updated.xml")
into("mailmanager/conf")
rename("log4j-updated.xml", "log4j.xml")
fileMode = 644
}
from(project.buildDir.name + "/resources/main/version.html") {
include("version.html")
into("mailmanager")
fileMode = 644
}
from("README.txt") {
into("mailmanager")
fileMode = 644
}
from("KnownBugs.txt") {
into("mailmanager")
fileMode = 644
}
from("ReleaseNotes.txt") {
into("mailmanager")
fileMode = 644
}
into("mailmanager/docs") {
from asciidoctor
include("Handbuch.pdf")
fileMode = 644
}
into ("var") {
from createEmptyDirectories
include("rtc/command_control")
include("rtc/resources")
include("log")
fileMode = 644
includeEmptyDirs=true
}
// from(project.buildDir.name + "/mailmanager/var") {
// include("rtc/command_control")
// include("rtc/resources")
// include("log")
// into("var")
// fileMode = 644
// includeEmptyDirs=true
// }
}
}
}
asciidoctorj {
version = '1.5.5'
}
asciidoctor {
backends 'pdf'
attributes 'build-gradle': file('build.gradle'),
'sourcedir': 'src/docs/asciidoc',
'source-highlighter': 'coderay',
'imagesdir': 'images',
'toc': 'left',
'icons': 'font',
'setanchors': '',
'idprefix': '',
'idseparator': '-',
'docinfo1': '',
'revnumber': project.version,
'revdate': getDate()
}
def getDate() {
new Date().format('d.MM.yyyy')
}
test {
testLogging {
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
}
}
dependencies {
compile group: 'commons-lang', name: 'commons-lang', version: '2.6'
compile group: 'commons-io', name: 'commons-io', version: '2.4'
compile group: 'commons-codec', name: 'commons-codec', version: '1.10'
compile group: 'org.apache.ant', name: 'ant', version: '1.9.6'
compile group: 'org.antlr', name: 'antlr', version: '3.5.2'
compile group: 'javax.el', name: 'javax.el-api', version: '2.2.4'
compile group: 'org.glassfish.web', name: 'javax.el', version: '2.2.4'
compile group: 'org.apache.commons', name: 'commons-email', version: '1.5'
compile group: 'org.apache.commons', name: 'commons-compress', version: '1.17'
compile group: 'org.projectlombok', name: 'lombok', version: '1.18.2'
compile group: 'com.google.guava', name: 'guava', version: '18.0'
compile group: 'javax.annotation', name: 'jsr250-api', version: '1.0'
compile group: 'org.eclipse.persistence', name: 'javax.persistence', version: '2.1.0'
compile group: 'org.springframework', name: 'spring-core', version: '4.1.7.RELEASE'
compile group: 'org.springframework', name: 'spring-beans', version: '4.1.7.RELEASE'
compile group: 'org.springframework', name: 'spring-orm', version: '4.1.7.RELEASE'
compile group: 'org.springframework', name: 'spring-jdbc', version: '4.1.7.RELEASE'
compile group: 'org.springframework', name: 'spring-tx', version: '4.1.7.RELEASE'
compile(group: 'org.springframework', name: 'spring-context', version: '4.1.7.RELEASE') {
exclude(module: 'commons-logging')
}
compile group: 'org.springframework', name: 'spring-context-support', version: '4.1.7.RELEASE'
compile group: 'org.hibernate', name: 'hibernate-core', version: '4.3.10.Final'
compile group: 'org.hibernate', name: 'hibernate-entitymanager', version: '4.3.10.Final'
compile group: 'org.hibernate', name: 'hibernate-c3p0', version: '4.3.10.Final'
compile group: 'org.hibernate', name: 'hibernate-ehcache', version: '4.3.10.Final'
compile group: 'org.hibernate.common', name: 'hibernate-commons-annotations', version: '4.0.5.Final'
compile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.1-api', version: '1.0.0.Final'
compile group: 'org.hibernate', name: 'hibernate-validator', version: '4.3.2.Final'
compile group: 'javax.validation', name: 'validation-api', version: '1.1.0.Final'
compile group: 'net.sf.ehcache', name: 'ehcache-core', version: '2.6.11'
compile group: 'com.mchange', name: 'c3p0', version: '0.9.5.1'
compile group: 'com.sun.mail', name: 'javax.mail', version: '1.6.0'
compile group: 'dom4j', name: 'dom4j', version: '1.6.1'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.12'
compile group: 'commons-logging', name: 'commons-logging', version: '1.2'
compile(group: 'org.quartz-scheduler', name: 'quartz', version: '2.2.1') {
exclude(module: 'c3p0')
}
compile group: 'org.quartz-scheduler', name: 'quartz-jobs', version: '2.2.1'
compile group: 'com.cronutils', name: 'cron-utils', version: '5.0.5'
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.36'
compile group: 'hsqldb', name: 'hsqldb', version: '1.8.0.10'
compile group: 'com.oracle', name: 'ojdbc7', version: '12.1.0.2'
compile group: 'com.oracle', name: 'oraclepki', version: '12.1.0.2'
compile group: 'com.oracle', name: 'osdt_cert', version: '12.1.0.2'
compile group: 'com.oracle', name: 'osdt_core', version: '12.1.0.2'
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.12'
compile group: 'log4j', name: 'log4j', version: '1.2.17'
testCompile group: 'com.h2database', name: 'h2', version: '1.4.193'
testCompile group: 'org.junit.vintage', name: 'junit-vintage-engine', version: '4.12.2'
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.0.0'
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.0.0'
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.0.0'
testCompile group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.0.2'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.19.1'
testCompile group: 'com.github.stefanbirkner', name: 'system-rules', version: '1.16.0'
testCompile group: 'net.jodah', name: 'concurrentunit', version: '0.4.2'
testCompile group: 'org.springframework', name: 'spring-test', version: '4.1.7.RELEASE'
testCompile group: 'org.assertj', name: 'assertj-core', version: '3.2.0'
testCompile(group: 'org.dbunit', name: 'dbunit', version: '2.5.1') {
exclude(module: 'junit')
}
testCompile group: 'com.github.springtestdbunit', name: 'spring-test-dbunit', version: '1.2.1'
testCompile group: 'pl.pragmatists', name: 'JUnitParams', version: '1.0.5'
testCompile group: 'com.tngtech.archunit', name: 'archunit', version: '0.8.0'
}
First thing: you should wrap custom stuff that you want your task to do in a doLast { ... } closure.
task createDirectories {
doLast {
// do stuff
}
}
Second, to create directories you should use mkdir method: https://docs.gradle.org/current/userguide/working_with_files.html#sec:creating_directories_example which by the way will default to creating directories under the main project directory.
So your task should become:
task createEmptyDirectories {
dependsOn jar
doLast {
mkdir "mailmanager/var/rtc/command_control"
mkdir "mailmanager/var/rtc/resources"
mkdir "mailmanager/var/log"
}
}
Here is a working example that you can adapt to your needs:
Directory structure (very basic)
gradle-test
src/main/java/Main.java
build.gradle
settings.gradle
Main.java
public class Main {
public static void main(String[] args) {
System.out.println("Hello world");
}
}
settings.gradle
rootProject.name = 'gradle-test'
build.gradle
apply plugin: 'java'
apply plugin: 'distribution'
task createEmptyDirectories {
doLast {
mkdir 'var/test'
}
}
distTar.dependsOn createEmptyDirectories
distributions {
main {
contents {
into('lib') {
from jar
}
into('var') {
from 'var'
}
}
}
}
After running gradle distTar, build/distributions/gradle-test.tar will be produced.
gradle-test> tar tvf build/distributions/gradle-test.tar
drwxr-xr-x 0 0 0 0 1 Nov 00:51 gradle-test/
drwxr-xr-x 0 0 0 0 1 Nov 00:51 gradle-test/lib/
-rw-r--r-- 0 0 0 684 1 Nov 00:44 gradle-test/lib/gradle-test.jar
drwxr-xr-x 0 0 0 0 1 Nov 00:51 gradle-test/var/
drwxr-xr-x 0 0 0 0 1 Nov 00:45 gradle-test/var/test/
As you can see, the jar file is in the lib folder and /var/ has the desired directory structure. Hope this makes it clear. It's likely not working for you now because you're using from createEmptyDirectories but that takes the output of the createEmptyDirectories task which is empty (mkdir does not add the created directories to the tasks outputs where it is used, so you have to be explicit)

neo4j-2.2.5.pom cannot be read of is not a valid zip file error

After I updated spring-data-neo4j to latest version: 4.0.0.RELEASE, I am getting the java build path error as follows:
'C:/Users/UserName/.gradle/caches/modules-2/files-2.1/org.neo4j/neo4j/2.2.5/c7c8174f5a175a96686a461033a9f7e01d24df1d/neo4j-2.2.5.pom'
in project 'movements-jhipster-neo4j-4-issue' cannot be read or is not
a valid ZIP file movements-jhipster-neo4j-4-issue Build path Build
Path Problem
build.gradle:
buildscript {
repositories {
mavenLocal()
maven { url "https://repo.spring.io/libs-release"}
jcenter()
}
dependencies {
classpath('org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE')
classpath('com.moowork.gradle:gradle-node-plugin:0.10')
classpath('com.moowork.gradle:gradle-grunt-plugin:0.10')
}
}
apply plugin: 'java'
sourceCompatibility=1.7
targetCompatibility=1.7
apply plugin: 'maven'
apply plugin: 'spring-boot'
apply plugin: 'war'
bootRepackage {
mainClass = 'com.movements.jhipster.Application'
}
springBoot {
mainClass = 'com.movements.jhipster.Application'
}
bootRun {
addResources = false
}
apply from: 'yeoman.gradle'
apply from: 'gatling.gradle'
if (project.hasProperty('prod')) {
apply from: 'profile_prod.gradle'
} else if (project.hasProperty('fast')) {
apply from: 'profile_fast.gradle'
} else {
apply from: 'profile_dev.gradle'
}
group = 'com.movements.jhipster'
version = '0.1-SNAPSHOT'
description = ''
configurations {
providedRuntime
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/libs-release"
maven { url 'https://repository.jboss.org/nexus/content/repositories/releases' }
maven { url 'https://oss.sonatype.org/content/repositories/releases' }
}
}
dependencies {
compile group: 'io.dropwizard.metrics', name: 'metrics-core'
compile group: 'io.dropwizard.metrics', name: 'metrics-graphite'
compile group: 'io.dropwizard.metrics', name: 'metrics-healthchecks'
compile group: 'io.dropwizard.metrics', name: 'metrics-jvm', version: dropwizard_metrics_version
compile group: 'io.dropwizard.metrics', name: 'metrics-servlet', version: dropwizard_metrics_version
compile group: 'io.dropwizard.metrics', name: 'metrics-json', version: dropwizard_metrics_version
compile group: 'io.dropwizard.metrics', name: 'metrics-servlets'
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-json-org', version: jackson_version
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-hppc', version: jackson_version
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-joda'
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-hibernate4', version: jackson_version
compile (group: 'com.ryantenney.metrics', name: 'metrics-spring', version: metrics_spring_version) {
exclude(module: 'metrics-core')
exclude(module: 'metrics-healthchecks')
}
compile(group: 'com.zaxxer', name: 'HikariCP-java6') {
exclude(module: 'tools')
}
compile group: 'commons-lang', name: 'commons-lang', version: commons_lang_version
compile group: 'commons-io', name: 'commons-io', version: commons_io_version
compile group: 'javax.inject', name: 'javax.inject', version: javax_inject_version
compile group: 'javax.transaction', name: 'javax.transaction-api'
compile group: 'joda-time', name: 'joda-time'
compile group: 'org.apache.geronimo.javamail', name: 'geronimo-javamail_1.4_mail', version: geronimo_javamail_1_4_mail_version
compile group: 'org.hibernate', name: 'hibernate-validator'
compile group: 'org.springframework.boot', name: 'spring-boot-actuator'
compile group: 'org.springframework.boot', name: 'spring-boot-autoconfigure'
compile group: 'org.springframework.boot', name: 'spring-boot-loader-tools'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-logging'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-aop'
//Neo4j
compile("org.springframework.boot:spring-boot-starter-data-rest")
compile 'org.springframework.data:spring-data-neo4j:4.0.0.RELEASE' //3.3.2.RELEASE'
//Mongo
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-mongodb'
compile 'org.springframework.data:spring-data-mongodb:1.8.0.RELEASE'
//Redis
compile group: 'org.springframework.boot', name: 'spring-boot-starter-redis'
compile 'org.springframework.data:spring-data-redis:1.6.0.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-security'
compile(group: 'org.springframework.boot', name: 'spring-boot-starter-web') {
exclude module: 'spring-boot-starter-tomcat'
}
compile group: 'org.springframework.boot', name: 'spring-boot-starter-websocket'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf'
//compile group: 'org.springframework.cloud', name: 'spring-cloud-cloudfoundry-connector'
compile group: 'org.springframework.cloud', name: 'spring-cloud-spring-service-connector'
compile group: 'org.springframework.cloud', name: 'spring-cloud-localconfig-connector'
compile(group: 'org.springframework', name: 'spring-context-support') {
exclude(module: 'quartz')
}
compile group: 'org.springframework.security', name: 'spring-security-config', version: spring_security_version
compile group: 'org.springframework.security', name: 'spring-security-data', version: spring_security_version
compile group: 'org.springframework.security', name: 'spring-security-web', version: spring_security_version
compile group: 'org.springframework.security', name: 'spring-security-messaging', version: spring_security_version
compile group: 'org.springframework.security.oauth', name: 'spring-security-oauth2', version: spring_security_oauth2_version
compile group: 'org.mongeez', name: 'mongeez', version: mongeez_version
compile(group: 'io.springfox', name: 'springfox-swagger-ui', version: springfox_version)
compile(group: 'io.springfox', name: 'springfox-swagger2', version: springfox_version){
exclude module: 'org.mapstruct.mapstruct'
}
//AWS
compile 'com.amazonaws:aws-java-sdk-core:1.10.1'
compile 'com.amazonaws:aws-java-sdk-sns:1.10.1'
compile 'com.amazonaws:aws-java-sdk-s3:1.10.1'
compile 'com.amazonaws:aws-java-sdk-cloudfront:1.10.1'
compile 'com.amazonaws:aws-java-sdk-elastictranscoder:1.10.1'
compile 'com.amazonaws:aws-java-sdk-sts:1.10.1'
compile 'org.springframework.cloud:spring-cloud-aws-messaging:1.0.1.RELEASE'
testCompile group: 'com.jayway.awaitility', name: 'awaitility', version: awaility_version
testCompile group: 'com.jayway.jsonpath', name: 'json-path'
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-jetty'
testCompile group: 'org.assertj', name: 'assertj-core', version: assertj_core_version
testCompile group: 'junit', name: 'junit'
testCompile group: 'org.mockito', name: 'mockito-core'
testCompile group: 'cz.jirutka.spring', name: 'embedmongo-spring', version: embedmongo_spring_version
testCompile group: 'org.hamcrest', name: 'hamcrest-library'
testCompile group: 'io.gatling.highcharts', name: 'gatling-charts-highcharts', version: gatling_version
testCompile group: 'com.h2database', name: 'h2'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.4'
}
task stage(dependsOn: 'bootRepackage') {
}

How to build on travis-ci with gradle and cobertura

Today I've tried to connect my travis-ci with coveralls using cobertura reports. Unfortunatelly after adding cobertura to my project travis cannot succeed in building my project.
Here's exemplary build: https://travis-ci.org/bandrzejczak/activiti-console-rest/jobs/38356310
And here's my build.gradle file:
plugins {
id 'java'
id 'war'
id 'idea'
id 'net.saliman.cobertura' version '2.2.5'
id 'com.github.kt3k.coveralls' version '2.0.1'
}
sourceCompatibility = 1.7
version = '0.0.1'
repositories {
mavenCentral()
maven{
url 'http://maven.restlet.org'
}
}
dependencies {
//compile dependencies
compile group: 'org.jetbrains', name: 'annotations', version: '13.0'
compile group: 'org.activiti', name: 'activiti-engine', version: '5.15.1'
compile group: 'org.activiti', name: 'activiti-spring', version: '5.15.1'
compile group: 'org.restlet.jee', name: 'org.restlet', version: '2.2.1'
compile group: 'org.restlet.jee', name: 'org.restlet.ext.spring', version: '2.2.1'
compile group: 'org.restlet.jee', name: 'org.restlet.ext.jackson', version: '2.2.1'
compile group: 'org.reflections', name: 'reflections', version: '0.9.8'
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.6'
//runtime dependencies
runtime group: 'mysql', name: 'mysql-connector-java', version: '5.1.31'
//test dependencies
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile group: 'org.springframework', name: 'spring-test', version: '3.2.7.RELEASE'
testCompile group: 'com.google.code.gson', name: 'gson', version: '2.3'
testRuntime group: 'com.h2database', name: 'h2', version: '1.4.178'
testRuntime group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'
}
cobertura.coverageFormats = ['html', 'xml']
I've found the answer to my question but I've forgotten to post it here. My mistake came from using wrong coveralls plugin. This is what you need to use when faced with such a problem:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.0.0'
}
}
apply plugin: 'com.github.kt3k.coveralls'
You can see whole build.gradle that I've used here.

Resources