Gradle child modules evaluation dependency - spring

I have a bunch of projects whose configuration should be based on a template (only name changes, different dependencies). To do that I defined a parent project called "server" that holds that common configuration part in subprojects section.
group 'com.kbhit.orangebox.server'
version '1.0-SNAPSHOT'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.3.5.RELEASE"
classpath 'com.bmuschko:gradle-docker-plugin:3.0.1'
}
}
import com.bmuschko.gradle.docker.tasks.container.DockerCreateContainer
import com.bmuschko.gradle.docker.tasks.container.DockerStartContainer
import com.bmuschko.gradle.docker.tasks.container.DockerStopContainer
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import com.bmuschko.gradle.docker.tasks.image.Dockerfile
ext.defineArtifact = { Map artifact ->
ext {
projectName = "$artifact.name"
projectVersion = '1.0.0'
artifactName = "$artifact.name-artifact.version.jar"
dockerBuildDir = "$buildDir/docker/"
}
springBoot {
executable = true
}
docker {
url = 'http://192.168.99.101:2376'
certPath = file(System.getProperty('docker.cert.path') ?: "${System.getProperty('user.home')}/.docker/machine/machines/default")
}
jar {
baseName = projectName
version = projectVersion
}
task createDockerfile(type: Dockerfile) {
destFile = file("$buildDir/docker/Dockerfile")
from 'java:8u91'
exposePort 8080
copyFile "$buildDir/docker/app.jar", '/app/app.jar'
workingDir '/app'
defaultCommand 'java', '-jar', 'app.jar'
}
task buildImage(type: DockerBuildImage, group: 'docker') {
dependsOn 'bootRepackage', 'createDockerfile'
inputDir = file("$buildDir/docker")
doFirst {
copy {
from "$buildDir/libs"
into dockerBuildDir
include artifactName
rename artifactName, 'app.jar'
}
}
}
task createContainer(type: DockerCreateContainer, group: 'docker') {
dependsOn buildImage
targetImageId { buildImage.getImageId() }
containerName projectName
}
task startContainer(type: DockerStartContainer, group: 'docker') {
dependsOn createContainer
targetContainerId { createContainer.getContainerId() }
}
task stopContainer(type: DockerStopContainer, group: 'docker') {
targetContainerId { createContainer.getContainerId() }
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'com.bmuschko.docker-remote-api'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
maven {
url('http://localhost:10001/content/groups/public/')
}
}
dependencyManagement {
imports {
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Brixton.RELEASE'
}
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web") {
exclude module: "spring-boot-starter-tomcat"
}
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.5.0'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.5.0'
compile("org.springframework.boot:spring-boot-starter-jetty")
compile("org.springframework.boot:spring-boot-starter-actuator")
testCompile("junit:junit")
testCompile("org.springframework.boot:spring-boot-starter-test")
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
}
afterEvaluate {
task startServer() {
dependsOn subprojects.startContainer
}
}
Here's the configuration of one of the modules:
defineArtifact(name: 'orb-api-gateway', version: '1.0.0')
dependencies {
compile 'org.springframework.cloud:spring-cloud-starter-zuul'
compile 'org.springframework.cloud:spring-cloud-starter-eureka'
compile 'org.springframework.cloud:spring-cloud-starter-config'
testCompile group: 'com.jayway.restassured', name: 'rest-assured', version: '2.9.0'
}
The problem is that:
Child projects need to "inject" their properties "up" before those are requested in task definitions, eg. buildImage task - I'd use $dockerBuildDir variable which should be defined in defineArtifact method based on the arguments provided by the child module.
Parent module must have access to tasks created for child modules. See startServer task at the bottom.
Of course this won't work as at the time no task are created. If I were to fix this I would have to make server project evaluate after it's children but then I would not be able to define defineArtifact method before children request it. How to solve this problem?

Related

Problem with the IntelliJ version in the plug-in

When I set an IntelliJ version as described below I have the following error
intellij {
version '2022.3'
}
A problem occurred configuring root project 'brs-plugin'.
Failed to notify project evaluation listener.
Failed to query the value of extension 'intellij' property 'version'.
> The value for the 'intellij.version' property was not specified, see:
https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#intellij-extension-version
But if I add the equal operator have the following
intellij {
version = '2022.3'
}
Caused by: org.gradle.internal.exceptions.DefaultMultiCauseException:
Could not resolve com.jetbrains.intellij.idea:ideaIC:2022.3.
This is my full version of the build.gradle. As you can see I have added several repos, but it's not helped. Full version of the project you can found on this link
How to fix my problem? Regards
buildscript {
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
url "https://plugins.gradle.org/m2/"
}
maven {
url "https://www.jetbrains.com/intellij-repository/releases"
}
maven {
url "https://www.jetbrains.com/intellij-repository/snapshots"
}
maven {
url "https://cache-redirector.jetbrains.com/intellij-dependencies"
}
}
}
plugins {
id "org.jetbrains.intellij" version "1.11.0"
id "org.jetbrains.grammarkit" version "2020.1"
}
configurations {
configurations.compileOnly.setCanBeResolved(true)
}
group 'com.interfaced'
version = '0.2.7'
apply plugin: 'kotlin'
apply plugin: 'org.jetbrains.intellij'
sourceSets {
all {
java.srcDirs += ['src/main/gen']
kotlin.srcDirs += ['src/main/kotlin']
resources.srcDirs = ['src/main/resources']
}
}
intellij {
version = '2022.3'
}
grammarKit {
jflexRelease = '1.7.0-2'
}
repositories {
mavenCentral()
maven {
url "https://cache-redirector.jetbrains.com/intellij-dependencies"
}
}
dependencies {
// https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: '1.7.22'
implementation files('jars/grammar-kit.jar')
implementation group: 'junit', name: 'junit', version: '4.12'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7"
// https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-gradle-plugin
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-gradle-plugin', version: '1.6.0'
}
import org.jetbrains.grammarkit.tasks.GenerateLexer
import org.jetbrains.grammarkit.tasks.GenerateParser
def GENERATE_GROUP = 'Generate'
task setConfiguration() {
configurations.compileOnly.setCanBeResolved(true)
}
task generateLexer(type: GenerateLexer) {
source = "src/main/grammar/BrightScript.flex"
targetDir = "src/main/gen/com/interfaced/brs/lang/lexer"
targetClass = "_BrsLexer"
skeleton = "src/main/grammar/idea-flex.skeleton"
purgeOldFiles = true
description = 'Generate Lexer Java sources for BrightScript'
group = GENERATE_GROUP
}
task generateParser(type: GenerateParser) {
source = "src/main/grammar/BrightScript.bnf"
targetRoot = 'src/main/gen'
pathToParser = 'src/main/gen/com/interfaced/brs/lang/BrsParser.java'
pathToPsiRoot = 'src/main/gen/com/interfaced/brs/lang/psi'
purgeOldFiles = true
description = 'Generate Parser Java sources for BrightScript'
group = GENERATE_GROUP
// patch up to date check
outputs.upToDateWhen { false }
}
compileKotlin {
kotlinOptions.jvmTarget = "17"
}
compileKotlin.dependsOn(setConfiguration, generateLexer, generateParser)

Provider org.jetbrains.plugins.gradle.tooling.builder.WarModelBuilderImpl could not be instantiated

I am writing the example codes of the book Pro Spring MVC:With Web Flow.
However I receive the following error when I try to import the Gradle project:
Cause: org.jetbrains.plugins.gradle.tooling.ModelBuilderService: Provider org.jetbrains.plugins.gradle.tooling.builder.WarModelBuilderImpl could not be instantiated
Here is the build.gradle file of the parent project:
apply plugin: 'base'
ext.springVersion = '3.2.3.RELEASE'
ext.tilesVersion = '2.2.2'
ext.springSecurityVersion = '3.1.4.RELEASE'
ext.springSwfVersion = '2.3.2.RELEASE'
ext.hibernateVersion = '4.2.3.Final'
ext.hibernateValidatorVersion = '5.0.1.Final'
ext.ehCacheVersion = '2.7.2'
ext.aspectJVersion = '1.7.3'
ext.tomcatVersion = '7.0.42'
ext.cargoVersion = '1.3.3'
ext.webProjects = subprojects.findAll { project -> project.name.endsWith('bookstore') }
buildscript {
repositories {
maven { url 'http://jcenter.bintray.com/' }
}
dependencies {
classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:1.2.4'
classpath 'org.gradle.api.plugins:gradle-cargo-plugin:1.5'
}
}
allprojects {
description = 'Bookstore Sample Application'
group = 'com.apress.prospringmvc'
version = '1.0.0'
repositories {
mavenRepo url: 'http://maven.springframework.org/release'
mavenRepo url: 'http://maven.springframework.org/snapshot'
mavenCentral()
mavenRepo url: 'http://maven.springframework.org/milestone'
mavenRepo url: 'https://repository.jboss.org/nexus/content/repositories/releases/'
mavenRepo url: 'http://download.java.net/maven/glassfish/org/glassfish/'
}
tasks.withType(Compile) {
options.compilerArgs << "-g"
}
}
configure(webProjects) {
apply plugin: 'war'
apply plugin: 'jetty'
apply plugin: 'tomcat'
apply plugin: 'cargo'
dependencies() {
compile project(':bookstore-shared'), project(':bookstore-web-resources')
compile "org.apache.tiles:tiles-servlet:$tilesVersion"
compile "org.apache.tiles:tiles-jsp:$tilesVersion"
compile "org.apache.tiles:tiles-api:$tilesVersion"
compile "org.apache.tiles:tiles-core:$tilesVersion"
runtime "jstl:jstl:1.2"
providedCompile 'javax.servlet:javax.servlet-api:3.0.1'
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
cargo "org.codehaus.cargo:cargo-core-uberjar:${cargoVersion}",
"org.codehaus.cargo:cargo-ant:${cargoVersion}"
}
}
cargo {
containerId = 'tomcat7x'
port = 8080
local {
homeDir = file('container/apache-tomcat-7.0.42')
output = file('container/apache-tomcat-7.0.42/output.log')
}
}
war {
version = '' //We do this to make the wars versionless, when they are deployed with cargo, the context
//root of the app is equal to the file name, which is equal to the sample directory name.
}
task systemTest(type: Test) {
include '**/*FrontendTest.*'
dependsOn(war)
doFirst {
cargoStartLocal.execute()
}
}
test {
exclude '**/*FrontendTest.*'
}
}
subprojects() {
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'idea'
sourceCompatibility = 1.7
targetCompatibility = 1.7
dependencies() {
compile "org.springframework:spring-orm:$springVersion"
compile "org.springframework:spring-aop:$springVersion"
compile "org.springframework:spring-webmvc:$springVersion"
compile "org.springframework:spring-oxm:$springVersion"
compile 'org.slf4j:jcl-over-slf4j:1.7.2'
compile 'ch.qos.logback:logback-classic:1.0.9'
compile 'org.apache.commons:commons-lang3:3.0.1'
compile 'com.thoughtworks.xstream:xstream:1.4.2'
compile 'com.h2database:h2:1.3.168'
compile 'cglib:cglib-nodep:2.2.2'
compile "org.aspectj:aspectjrt:$aspectJVersion"
compile "org.aspectj:aspectjweaver:$aspectJVersion"
compile "org.hibernate:hibernate-entitymanager:$hibernateVersion"
compile "org.hibernate:hibernate-core:$hibernateVersion"
compile "org.hibernate:hibernate-ehcache:$hibernateVersion"
compile "org.hibernate:hibernate-validator:$hibernateValidatorVersion"
compile "net.sf.ehcache:ehcache:$ehCacheVersion"
compile 'com.lowagie:itext:2.1.7'
compile 'net.sourceforge.jexcelapi:jxl:2.6.12'
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.11'
compile 'commons-codec:commons-codec:1.6'
compile 'joda-time:joda-time:2.1'
testCompile 'junit:junit:4.11'
testCompile "org.springframework:spring-test:$springVersion"
}
eclipse {
project.natures "org.springframework.ide.eclipse.core.springnature"
}
}
task wrapper(type: Wrapper) { gradleVersion = '1.6' }
What can I do?
Bump up gradle version its the only solution I have for now; 4.0 should work:
change:
task wrapper(type: Wrapper) { gradleVersion = '1.6' }
to:
task wrapper(type: Wrapper) { gradleVersion = '4.0' }
I am trying to resolve it other way to use 1.7 so far - failing.

CordaFTP Unable to transfer Large files because of Artemis probably

I'm using this demo.CordaFTPdemo to get hands-on attachment. However, I figured out that large files cannot be transferred and are giving an exception
java.lang.IllegalArgumentException: Missing validated user from the Artemis message
ServerSession doesn't set validated users when called from slowPacketHandler in ServerSessionPacketHandler.
JIRA Here The thing is when I update the build.gradle to force to version 2.5.0 for Artemis. it just doesn't work. when I checked the gradle dependencies
tree it has 2.5.0, then why is it that Corda jar is picking up 2.2.0 in classpath is unknown I can see it in the nodes logs. I've already deleted it ./gradle folder and cleared all cached and tried. below is my chaned build.gradle :
buildscript {
ext.corda_release_version = '3.1-corda'
ext.corda_gradle_plugins_version = '3.1.0'
ext.quasar_version = '0.7.9'
ext.junit_version = '4.12'
ext.spring_boot_version = '2.0.2.RELEASE'
ext.corda_release_group = 'net.corda'
ext.kotlin_version = '1.1.60'
ext.username = "corda"
ext.password = "corda_initial_password"
ext.client_port = 10009
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version"
classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version"
classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version"
classpath "io.spring.gradle:dependency-management-plugin:1.0.5.RELEASE"
}
}
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven { url 'https://dl.bintray.com/kotlin/exposed' }
maven { url 'https://jitpack.io' }
maven { url 'https://ci-artifactory.corda.r3cev.com/artifactory/corda-releases' }
maven { url 'https://ci-artifactory.corda.r3cev.com/artifactory/corda-dev/' }
}
apply plugin: 'kotlin'
apply plugin: "io.spring.dependency-management"
apply plugin: 'net.corda.plugins.cordapp'
apply plugin: 'net.corda.plugins.cordformation'
apply plugin: 'net.corda.plugins.quasar-utils'
dependencyManagement {
dependencies {
dependencySet(group: 'org.apache.activemq', version: '2.5.0') {
entry 'artemis-amqp-protocol'
entry 'artemis-commons'
entry 'artemis-core-client'
entry 'artemis-jdbc-store'
entry 'artemis-jms-client'
entry 'artemis-journal'
entry 'artemis-native'
entry 'artemis-selector'
entry 'artemis-server'
}
}
}
sourceSets {
main {
resources {
srcDir "config/dev"
}
}
test {
resources {
srcDir "config/test"
}
}
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
testCompile "junit:junit:$junit_version"
// Corda integration dependencies
cordaCompile "$corda_release_group:corda-core:$corda_release_version"
cordaCompile "$corda_release_group:corda-finance:$corda_release_version"
cordaCompile "$corda_release_group:corda-jackson:$corda_release_version"
cordaCompile "$corda_release_group:corda-rpc:$corda_release_version"
cordaCompile "$corda_release_group:corda-node-api:$corda_release_version"
cordaCompile "$corda_release_group:corda-webserver-impl:$corda_release_version"
cordaRuntime "$corda_release_group:corda:$corda_release_version"
cordaRuntime "$corda_release_group:corda-webserver:$corda_release_version"
testCompile "$corda_release_group:corda-test-utils:$corda_release_version"
testCompile "$corda_release_group:corda-node-driver:$corda_release_version"
// GraphStream: For visualisation (required by TemplateClientRPC app)
compile "org.graphstream:gs-core:1.3"
compile("org.graphstream:gs-ui:1.3") {
exclude group: "bouncycastle"
}
// CorDapp dependencies
// Specify your cordapp's dependencies below, including dependent cordapps
compile "io.reactivex:rxjava:1.2.4"
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
languageVersion = "1.1"
apiVersion = "1.1"
jvmTarget = "1.8"
javaParameters = true // Useful for reflection.
}
}
def copyConfigTask(nodeName) {
return tasks.create("copy${nodeName}", Copy) {
from "${nodeName}.json"
into "./build/nodes/${nodeName}/"
rename {
"cordaftp.json"
}
}
}
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', copyConfigTask("CorpA"), copyConfigTask("CorpB")]) {
directory "./build/nodes"
node {
name "O=R3Corp,OU=corda,L=London,C=GB"
notary = [validating : false]
p2pPort 10002
rpcSettings {
address("localhost:10003")
adminAddress("localhost:10043")
}
cordapps = []
}
node {
name "O=CorpA,L=Paris,C=FR"
p2pPort 10005
rpcSettings {
address("localhost:10006")
adminAddress("localhost:10046")
}
extraConfig = [
jvmArgs : [ "-Xmx1g"],
attachmentContentCacheSizeMegaBytes: 100
]
cordapps = []
// TODO: Replace username / password with vars such that we can DRY the username, password
rpcUsers = [[ "user": "corda", "password": "corda_initial_password", "permissions": ["ALL"]]]
}
node {
name "O=CorpB,L=Rome,C=IT"
p2pPort 10008
rpcSettings {
address("localhost:10009")
adminAddress("localhost:10049")
}
extraConfig = [
jvmArgs : [ "-Xmx1g"],
attachmentContentCacheSizeMegaBytes: 100
]
cordapps = []
// TODO: Ditto
rpcUsers = [[ "user": "corda", "password": "corda_initial_password", "permissions": ["ALL"]]]
}
}
task(runClientB, dependsOn: 'classes', type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'net.corda.cordaftp.SenderKt'
args "localhost:$client_port", "$username", "$password", "build/nodes/CorpB/cordaftp.json"
}
This appears to be a bug in Corda 3.1 OS. I have reported it here: https://github.com/corda/corda/issues/3649.

Cannot configure the publishing extension for gradle

I am using gradle v3.4 with the following build.gradle file. However, I get the error copied below with any tasks. Any thoughts on what might be misconfigured in the build.gradle file?
error
What went wrong:
A problem occurred evaluating root project 'some-test'.
> Cannot configure the 'publishing' extension after it has been accessed.
The error points to where the publishing task begins.
build.gradle
group 'some.group'
version '0.0.1' //-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'idea'
apply plugin: 'com.google.protobuf'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin:'com.github.johnrengelman.shadow'
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven {
credentials {
username project.properties['nexusUsername']
password project.properties['nexusPassword']
}
url project.properties['nexus.url.snapshot']
}
jcenter()
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.0'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
}
}
if (!JavaVersion.current().java8Compatible) {
throw new IllegalStateException("Must be built with Java 8 or higher")
}
mainClassName = "com.some.project.some.class"
defaultTasks 'clean', 'build', 'shadowJar', 'install'
compileJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
repositories {
maven {
credentials {
username project.properties['nexusUsername']
password project.properties['nexusPassword']
}
url project.properties['nexus.url.snapshot']
}
mavenLocal()
mavenCentral()
jcenter()
}
def grpcVersion = '1.1.2'
def log4j2Version = '2.8.1'
def configVersion = '1.3.1'
def jacksonVersion = '2.8.7'
dependencies {
compile "io.grpc:grpc-netty:${grpcVersion}"
compile "io.grpc:grpc-protobuf:${grpcVersion}"
compile "io.grpc:grpc-stub:${grpcVersion}"
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: jacksonVersion
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jacksonVersion
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: jacksonVersion
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: log4j2Version
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: log4j2Version
compile 'io.netty:netty-tcnative-boringssl-static:1.1.33.Fork26'
compile group: 'org.bouncycastle', name: 'bcprov-jdk16', version: '1.46'
compile "com.typesafe:config:${configVersion}"
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile "org.mockito:mockito-core:1.9.5"
compile 'commons-lang:commons-lang:2.3'
}
sourceSets {
main {
proto {
srcDir '../../proto' // In addition to the default 'src/main/proto'
}
java {
}
}
test {
proto {
srcDir '../../proto' // In addition to the default 'src/test/proto'
}
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.2.0'
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
}
}
generateProtoTasks {
all()*.plugins {
grpc {
// To generate deprecated interfaces and static bindService method,
// turn the enable_deprecated option to true below:
option 'enable_deprecated=false'
}
}
}
}
idea {
module {
sourceDirs += file("${projectDir}/build/generated/source/proto/main/java");
sourceDirs += file("${projectDir}/build/generated/source/proto/main/grpc");
}
}
jar {
manifest {
attributes(
'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
'Main-Class': 'com.some.project.some.class'
)
}
}
shadowJar {
baseName = 'commons-java'
classifier = null
version = null
}
artifacts {
archives shadowJar
}
publishing {
publications {
shadow(MavenPublication) {
from components.shadow
}
}
repositories {
maven {
credentials {
username "someuser"
password "somepassword"
}
url "http://nexus.somewhere.com/repository/some-test-snapshots/"
}
}
}
tasks.publish.dependsOn 'shadowJar'
startScripts.enabled = false
The issue was how I was reading the properties - also, I no longer use both maven and maven-publish plugins (I am using maven-publish only). I am currently able to publish to nexus successfully.

Specify war in gradle's tomcatRunWar

I'm playing with the tomcat plugin for gradle and in my build/tmp/tomcatRun/work/Tomcat/localhost/myWebApp directory its empty. Is there a way for me to specify the location of my war to deploy?
I tried
[tomcatRun, tomcatRunWar]*.destinationDir= new File("$buildDir/libs").getAbsoluteFile().getPath()
and
[tomcatRun, tomcatRunWar]*.warDirectory= new File("$buildDir/libs").getAbsoluteFile().getPath()
Update
I've added the build scripts below. When I run my new tasks I've been running
gradle build integrationTest
Here is a snippet from the parent build.gradle:
buildscript {
repositories {
add(new org.apache.ivy.plugins.resolver.URLResolver()) {
name = 'GitHub'
addArtifactPattern 'http://cloud.github.com/downloads/[organisation]/[module]/[module]-[revision].[ext]'
}
}
dependencies {
classpath 'bmuschko:gradle-tomcat-plugin:0.9.2'
}
}
allprojects {
apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "idea"
ext.springVersion = "3.1.1.RELEASE"
ext.hibernateVersion = "3.6.7.Final"
ext.mysqlVersion = "5.1.20"
ext.tomcatVersion = "7.0.26"
ext.junitVersion = "4.10"
ext.httpClientVersion = "4.2"
ext.pdfboxVersion = "1.7.1"
ext.resxWebserviceVersion = "10.4.2"
loadConfiguration()
}
and my webapps build.gradle:
apply plugin: "maven"
apply plugin: "war"
apply plugin: "tomcat"
def now = new Date()
def cssDir = new File("truexpense-web/src/main/webapp/css").getAbsoluteFile().getPath()
def minCssName = 'all-min.css'
def jsDir = new File("truexpense-web/src/main/webapp/js").getAbsoluteFile().getPath()
def minJsName = 'all-min.js'
ext.requestor = ''
ext.fromAddress = ''
ext.replyAddress = ''
ext.formattedDate = now.format('dd MMM yyy HH:mm')
ext.product = 'Truexpense'
configurations {
deployerJars
jasper
mail
}
dependencies {
//Compile time but not included dependencies
providedCompile "javax.servlet:javax.servlet-api:3.0.1"
providedCompile "org.apache.tomcat:tomcat-jdbc:$tomcatVersion"
//Compile time dependencies
compile project(":truexpense-domain")
compile project(":truexpense-repository")
compile project(":truexpense-service")
compile "org.springframework:spring-core:$springVersion"
compile "org.springframework:spring-web:$springVersion"
compile "org.hibernate:hibernate-core:$hibernateVersion"
compile "org.hibernate:hibernate-envers:$hibernateVersion"
compile "org.hibernate:hibernate-ehcache:$hibernateVersion"
compile "org.hibernate:hibernate-validator:4.2.0.Final"
compile "commons-io:commons-io:2.3"
compile "commons-codec:commons-codec:1.6"
compile "org.springframework.security:spring-security-core:3.1.0.RELEASE"
compile "org.springframework.security:spring-security-config:3.1.0.RELEASE"
compile "org.springframework.security:spring-security-web:3.1.0.RELEASE"
compile "javax.mail:mail:1.4"
compile "mysql:mysql-connector-java:$mysqlVersion"
compile "com.google.visualization:visualization-datasource:1.0.2"
compile "org.ostermiller:utils:1.07.00"
compile "net.sf.ofx4j:ofx4j:1.4"
compile "org.jpedal:jbig2:1"
compile "org.apache.pdfbox:txp-fontbox:$pdfboxVersion"
compile "org.apache.pdfbox:txp-jempbox:$pdfboxVersion"
compile "org.apache.pdfbox:txp-pdfbox:$pdfboxVersion"
compile "taglibs:taglibs-unstandard:1"
compile "org.codehaus.jackson:jackson-mapper-asl:1.9.7"
compile "org.apache.httpcomponents:httpclient:$httpClientVersion"
//Runtime only dependencies
runtime "commons-beanutils:commons-beanutils-core:1.8.3"
runtime "joda-time:joda-time:2.1"
runtime "org.springframework.security:spring-security-taglibs:3.1.0.RELEASE"
runtime "org.springframework:spring-beans:$springVersion"
runtime "org.springframework:spring-context:$springVersion"
runtime "org.springframework:spring-core:$springVersion"
runtime "org.springframework:spring-expression:$springVersion"
runtime "org.springframework:spring-instrument:$springVersion"
runtime "org.springframework:spring-instrument-tomcat:$springVersion"
runtime "org.springframework:spring-jdbc:$springVersion"
runtime "org.springframework:spring-jms:$springVersion"
runtime "org.springframework:spring-orm:$springVersion"
runtime "org.springframework:spring-oxm:$springVersion"
runtime "org.springframework:spring-tx:$springVersion"
runtime "org.springframework:spring-web:$springVersion"
runtime "org.springframework:spring-webmvc:$springVersion"
runtime ("commons-fileupload:commons-fileupload:1.2.2") {
exclude group: "javax.servlet", module: "javax.servlet-api"
exclude group: "portlet-api"
}
runtime ("javax.servlet:jstl:1.2") {
exclude group: "javax.servlet", module: "javax.servlet-api"
exclude group: "javax.servlet", module: "jsp-api"
}
//Test only dependencies
tomcat "org.apache.tomcat:tomcat-dbcp:${tomcatVersion}"
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
}
//Deployments
deployerJars "org.apache.maven.wagon:wagon-http:1.0-beta-2"
[tomcatRun, tomcatRunWar]*.httpPort = 8090
[tomcatRun, tomcatStop]*.stopPort = 8081
[tomcatRun, tomcatStop]*.stopKey = 'stopKey'
task integrationTest(type: Test) {
include '**/*IntegrationTest.*'
doFirst {
tomcatRun.daemon = true
tomcatRun.execute()
}
doLast {
tomcatStop.execute()
}
}
test {
exclude '**/*IntegrationTest.*'
}
}
war {
baseName='truexpense'
eachFile {
if (it.name == 'login_css_include.jsp') {
it.expand(loginCSS: "login-min.css?t=${now.getTime()}")
}
else if (it.name == 'all_css_include.jsp') {
it.expand(allCSS: "all-min.css?t=${now.getTime()}")
}
else if (it.name == 'all_js_include.jsp') {
it.expand(allJS: "all-min.js?t=${now.getTime()}")
}
}
}
task deploy << { deploy() }
task minifyCSS << {
def files = fileTree(dir: "${cssDir}", includes: [
"analysis.css",
"header.css",
"footer.css",
"blocks.css",
"chosen.css",
"grids.css",
"space.css",
"dataTables.css",
"newCore.css",
"core.css",
"skin_clean.css",
"plugins.css",
"css3.css",
"jquery-ui.css",
"jquery.lightbox-0.5.css",
"jqueryFileTree.css",
"jquery.qtip.css",
"expense.css",
"report.css",
"zentab.css"
]).getFiles().sort({it.name})
concatenate("${cssDir}/all.css", files)
yuiCompressor("${cssDir}/all.css", "${cssDir}/${minCssName}")
yuiCompressor("${cssDir}/login.css", "${cssDir}/login-min.css")
}
task minifyJS << {
def files = fileTree(dir: "${jsDir}", excludes:[
'all*.js',
'jqtouch*.js'
]).getFiles().sort({it.name})
concatenate("${jsDir}/all.js", files)
yuiCompressor("${jsDir}/all.js", "${jsDir}/${minJsName}")
}
def yuiCompressor(from, to) {
ant.java(jar:"tools/yuicompressor-2.4.7.jar", fork: true, failonerror: true) {
arg(value: from)
arg(value: "-o")
arg(value: to)
}
}
def concatenate(filePath, files) {
File file = new File(filePath)
if (file.exists()) {
file.write("")
}
files.each { File f ->
file.append(f.getText() + '\n')
}
}
def deploy() {
println "Deleting ${tomcatHome}/webapps/${war.baseName}"
delete "${tomcatHome}/webapps/${war.baseName}"
println "Deleting ${tomcatHome}/work/Catalina/localhost/${war.baseName}"
delete "${tomcatHome}/work/Catalina/localhost/${war.baseName}"
println "Copying ${war.archiveName} to ${tomcatHome}/webapps"
copy {
from war.archivePath
into "${tomcatHome}/webapps"
}
}
How do you reference your applicationContext.xml in your web.xml? If you use the full path (/WEB-INF/classes/applicationContext.xml) then I'd probably change it to search for it on the classpath:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>

Resources