Cannot configure the publishing extension for gradle - 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.

Related

Running into Gradle build failure in intellj; it's asking for update 5.0+

Error Message:
Error:(52, 0) This version of Shadow supports Gradle 5.0+ only. Please upgrade.
Open File
build.gradle file(line 52 - apply plugin: "com.github.johnrengelman.shadow)
How can I fix this issue since I'm new to Gradle and learning?
allprojects {
apply plugin: 'idea'
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven { url 'http://packages.confluent.io/maven/' }
}
}
project.ext {
apacheHttpClientVersion = "4.5.6"
commonsCliVersion = '1.4'
h2Version = '1.3.175'
hamcrestVersion = '1.3'
junitVersion = '4.11'
mariadbDriverVersion = '2.4.2'
nettyVersion = '4.1.15.Final'
slf4jVersion = '1.7.25'
mockitoVersion = '1.9.5'
assertjVersion = '3.8.0'
zkToolsVersion = '0.5.0'
yamlVersion = '1.20'
riffVersion = '2.4.2'
jacksonVersion = '2.9.6'
jettyVersion = '9.4.12.v20180830'
mainClass = 'Main'
}
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1'
classpath "com.github.jengelman.gradle.plugins:shadow:5.1.0"
classpath 'se.transmode.gradle:gradle-docker:1.2'
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: 'maven-publish'
apply plugin: 'signing'
configurations.all {
resolutionStrategy {
force "org.hamcrest:hamcrest-all:$hamcrestVersion"
}
}
jar {
manifest {
attributes(
"Implementation-Title": "Waltz",
"Implementation-Version": version)
}
}
compileJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
compileTestJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
checkstyle {
toolVersion = "8.10"
}
checkstyleTest {
configFile = project.file ("${rootProject.projectDir}/config/checkstyle/checkstyle_test.xml")
}
// findbugs html only report
findbugsMain {
reports {
xml.enabled = false
html.enabled = true
}
}
findbugsTest {
reports {
xml.enabled = false
html.enabled = true
}
}
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = 'sources'
}
task javadocJar(type: Jar) {
from javadoc
archiveClassifier = 'javadoc'
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = project.name
from components.java
artifact sourcesJar
artifact javadocJar
pom {
name = 'Waltz'
description = 'Waltz is a distributed/replicated write ahead log for transactions.'
url = 'https://www.github.com/wepay/waltz'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'ymatsuda'
name = 'Yasuhiro Matsuda'
}
}
scm {
connection = 'scm:git:git://github.com/wepay/waltz.git'
developerConnection = 'scm:git:ssh://github.com/wepay/waltz.git'
url = 'https://github.com/wepay/waltz'
}
}
}
}
repositories {
maven {
def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username findProperty('ossrhUsername')?: ''
password findProperty('ossrhPassword')?: ''
}
}
}
}
signing {
sign publishing.publications.mavenJava
}
task execute(type:JavaExec) {
main = mainClass
classpath = sourceSets.main.runtimeClasspath
if (project.hasProperty("commandArgs")) {
args commandArgs.split()
}
standardInput = System.in
}
}
project(':waltz-tools') {
dependencies {
compile (
project(':waltz-client'),
project(':waltz-server'),
project(':waltz-storage'),
"org.apache.httpcomponents:fluent-hc:$apacheHttpClientVersion"
)
testCompile (
// TODO remove cyclic dependency
// Not super thrilled about this, as it creates a circular dependency between
// watlz-util and waltz-test. waltz-tools needs ZK server runner for tests, and
// waltz-test needs to be able to create clusters to run smoke test and demo.
project(':waltz-test'),
"junit:junit:$junitVersion",
"org.mockito:mockito-all:$mockitoVersion"
)
}
task copyLibs(type:Copy) {
into file("$projectDir/build/libs")
from sourceSets.main.runtimeClasspath
}
}
project(':waltz-server') {
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'application'
apply plugin: 'docker'
dependencies {
compile (
project(':waltz-common'),
project(':waltz-storage'),
"com.fasterxml.jackson.core:jackson-databind:$jacksonVersion",
"com.wepay.riff:riff-config:$riffVersion",
"com.wepay.riff:riff-metrics:$riffVersion",
"com.wepay.zktools:zktools:$zkToolsVersion",
"io.netty:netty-all:$nettyVersion",
"org.slf4j:slf4j-api:$slf4jVersion",
"org.eclipse.jetty:jetty-server:$jettyVersion",
"org.eclipse.jetty:jetty-servlet:$jettyVersion",
)
testCompile (
project(':waltz-client'),
project(':waltz-test'),
"junit:junit:$junitVersion",
"org.mockito:mockito-all:$mockitoVersion"
)
}
test {
maxHeapSize = "2G"
jvmArgs '-Xmx2G'
}
distDocker {
mainClassName = 'com.wepay.waltz.server.WaltzServer'
workingDir "${rootProject.name}-${project.version}"
}
}
project(':waltz-storage') {
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'application'
apply plugin: 'docker'
dependencies {
compile (
project(':waltz-common'),
"com.fasterxml.jackson.core:jackson-databind:$jacksonVersion",
"com.wepay.riff:riff-config:$riffVersion",
"com.wepay.riff:riff-metrics:$riffVersion",
"com.wepay.zktools:zktools:$zkToolsVersion",
"io.netty:netty-all:$nettyVersion",
"org.slf4j:slf4j-api:$slf4jVersion",
"org.yaml:snakeyaml:$yamlVersion",
"org.eclipse.jetty:jetty-server:$jettyVersion",
"org.eclipse.jetty:jetty-servlet:$jettyVersion",
)
testCompile (
project(':waltz-test'),
"junit:junit:$junitVersion",
"org.mockito:mockito-all:$mockitoVersion"
)
}
distDocker {
mainClassName = 'com.wepay.waltz.storage.WaltzStorage'
workingDir "${rootProject.name}-${project.version}"
runCommand 'mkdir /waltz_storage'
}
}
project(':waltz-uber') {
dependencies {
compile(
project(':waltz-server'),
project(':waltz-tools')
)
testCompile (
project(':waltz-server')
)
runtime (
"org.slf4j:slf4j-log4j12:$slf4jVersion"
)
}
shadowJar {
baseName = project.name
classifier = null
version = version
}
}
project(':waltz-uber').build.dependsOn project(':waltz-uber').shadowJar
project(':waltz-uber').artifactoryPublish.dependsOn project(':waltz-uber').shadowJar
project(':waltz-client') {
dependencies {
compile (
project(':waltz-common'),
"com.wepay.riff:riff-config:$riffVersion",
"com.wepay.zktools:zktools:$zkToolsVersion",
"io.netty:netty-all:$nettyVersion",
"org.slf4j:slf4j-api:$slf4jVersion"
)
testCompile (
project(':waltz-test'),
"com.h2database:h2:$h2Version",
"junit:junit:$junitVersion"
)
}
}
project(':waltz-common') {
dependencies {
compile (
"com.wepay.riff:riff-config:$riffVersion",
"com.wepay.riff:riff-metrics:$riffVersion",
"com.wepay.riff:riff-networking:$riffVersion",
"com.wepay.zktools:zktools:$zkToolsVersion",
"commons-cli:commons-cli:$commonsCliVersion",
"io.netty:netty-all:$nettyVersion",
"org.slf4j:slf4j-api:$slf4jVersion",
"org.yaml:snakeyaml:$yamlVersion"
)
testCompile (
project(':waltz-test'),
"junit:junit:$junitVersion",
"org.assertj:assertj-core:$assertjVersion",
"org.mockito:mockito-all:$mockitoVersion"
)
}
}
project(':waltz-test') {
dependencies {
compile (
project(':waltz-server'),
project(':waltz-client'),
project(':waltz-storage'),
project(':waltz-tools'),
"com.wepay.zktools:zktools:$zkToolsVersion",
"io.netty:netty-all:$nettyVersion"
)
testCompile (
"junit:junit:$junitVersion"
)
}
task copyLibs(type:Copy) {
into file("$projectDir/build/libs")
from sourceSets.main.runtimeClasspath
}
}
project(':waltz-demo') {
dependencies {
compile (
project(':waltz-server'),
project(':waltz-client'),
project(':waltz-test'),
project(':waltz-tools'),
"org.mariadb.jdbc:mariadb-java-client:$mariadbDriverVersion"
)
testCompile (
"com.h2database:h2:$h2Version",
"junit:junit:$junitVersion"
)
}
shadowJar {
baseName = project.name
classifier = null
version = version
}
}
project(':waltz-demo').build.dependsOn project(':waltz-demo').shadowJar
project(':waltz-demo').artifactoryPublish.dependsOn project(':waltz-demo').shadowJar
Either upgrade your local installation of Gradle by installing a new version. Or upgrade the Gradle wrapper: https://docs.gradle.org/current/userguide/gradle_wrapper.html#sec:upgrading_wrapper
The shadow plugin you're using requires a newer gradle version. You either remove the plugin or update as francisco above suggested

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.

Project doesn't build after upgrading to android gradle plugin 3.0.0+

after migrating to Android 3.0 I've changed gradle configurations in my projects.
In one of them I get errors while trying to do the build:
Execution failed for task ':app:compileDebugKotlin'.
e: C:\dev\myapp\app\src\main\kotlin\com\xxxxx\dialog\DeleteConfirmDialog.kt: (35, 46): Too many arguments for public constructor Builder(p0: Context!) defined in android.app.AlertDialog.Builder
e: C:\dev\myapp\app\src\main\kotlin\com\xxxxx\dialog\HumidityThresholdDialog.kt: (46, 74): Too many arguments for public open fun getString(p0: String!): String! defined in android.os.Bundle
e: C:\dev\myapp\app\src\main\kotlin\com\xxxxx\dialog\PermissionDialog.kt: (45, 50): Unresolved reference: ACTION_APcomICATION_DETAILS_SETTINGS
e: C:\dev\myapp\app\src\main\kotlin\com\xxxxx\dialog\PermissionDialog.kt: (53, 22): Unresolved reference: finishAffinity
e: C:\dev\myapp\app\src\main\kotlin\com\xxxxx\dialog\TemperatureThresholdDialog.kt: (74, 73): Unresolved reference: holo_red_dark
e: C:\dev\myapp\app\src\main\kotlin\com\xxxxx\dialog\TemperatureThresholdDialog.kt: (81, 88): Unresolved reference: holo_red_dark
e: C:\dev\myapp\app\src\main\kotlin\com\xxxxx\fragment\Thresholds.kt: (128, 41): Unresolved reference: fragmentManager
e: C:\dev\myapp\app\src\main\kotlin\com\xxxxx\fragment\Thresholds.kt: (153, 38): Unresolved reference: fragmentManager
...
What is interesting, when I navigate to error lines, eg:
val color = if (it) android.R.color.black else android.R.color.holo_red_dark //Unresolved reference: holo_red_dark
dialog.show(activity.fragmentManager, ThresholdDialog::class.java.simpleName) //Unresolved reference: fragmentManager
the compiler doesn't show an error and I can navigate to those classes.
Project:
buildscript {
repositories {
google()
jcenter()
maven { url 'https://raw.github.com/vRallev/mvn-repo/master/' }
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1' //<--- when reverting back to 2.3.3, the project is built without problems
classpath 'io.fabric.tools:gradle:1.23.0'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
}
App:
buildscript {
ext.versions = [
kotlin : '1.1.60',
crashlytics: '1.16.0'
]
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
maven { url "https://plugins.gradle.org/m2/" }
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath "com.crashlytics.tools.gradle:crashlytics-gradle:$versions.crashlytics"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$versions.kotlin"
classpath "org.kordamp:markdown-gradle-plugin:1.1.0"
classpath 'io.fabric.tools:gradle:1.23.0'
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://jitpack.io' }
mavenLocal()
mavenCentral()
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'org.kordamp.markdown.convert'
apply from: 'signing.gradle'
def version = ["major": 3, "minor": 6, "patch": 1, "build": 0]
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.xxxxx"
minSdkVersion 19
targetSdkVersion 26
versionCode 10000000 * version["major"] + 100000 * version["minor"] + 1000 * version["patch"] + version["build"]
versionName "${version["major"]}.${version["minor"]}.${version["patch"]}"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7 //<- tried to changed to 1_8 with android studio 3, doesn't help
targetCompatibility JavaVersion.VERSION_1_7
}
signingConfigs {
release
}
buildTypes {
release {
// runProguard false
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
zipAlignEnabled true
signingConfig signingConfigs.release
}
debug {
ext.enableCrashlytics = false
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
main.assets.srcDirs += 'build/gen-html'
androidTest.java.srcDirs += 'src/androidTest/kotlin'
}
lintOptions {
checkReleaseBuilds false
disable 'InvalidPackage'
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude 'META-INF/LICENSE.txt'
}
}
ext.versions += [
supportLib : "26.1.0",
logback : '1.1.1-2',
dagger : '1.2.5',
butterknife: '7.0.1'
]
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar']) //changed all 'compile' to 'implementation', doesn't help
compile 'com.xxxxx.lib:1.0.1-SNAPSHOT#aar'
compile "com.android.support:support-v4:$versions.supportLib"
compile "com.android.support:support-v13:$versions.supportLib"
compile "com.squareup.dagger:dagger:$versions.dagger"
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta3'
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta3'
compile 'com.google.guava:guava:20.0'
compile 'de.greenrobot:eventbus:2.2.1'
compile 'org.slf4j:slf4j-api:1.7.6'
compile "com.github.tony19:logback-android-core:$versions.logback"
compile "com.github.tony19:logback-android-classic:$versions.logback"
compile "org.jetbrains.kotlin:kotlin-stdlib:$versions.kotlin"
compile 'io.reactivex:rxjava:1.0.16'
compile 'io.reactivex:rxkotlin:0.40.1'
compile "com.jakewharton.rxbinding:rxbinding:0.4.0"
compile "com.jakewharton.rxbinding:rxbinding-kotlin:0.4.0"
compile "com.jakewharton:butterknife:$versions.butterknife"
compile 'com.jakewharton.threetenabp:threetenabp:1.0.3'
compile('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') { transitive = true }
compile 'com.github.PhilJay:MPAndroidChart:v2.0.7'
kapt "com.jakewharton:butterknife:$versions.butterknife"
kapt "com.squareup.dagger:dagger-compiler:$versions.dagger"
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.9.0'
testCompile 'org.assertj:assertj-core:3.8.0'
}
markdownToHtml {
sourceDir = file('src/main/markdown')
fencedCodeBlocks = true
hardwraps = true
autoLinks = true
}
project.afterEvaluate {
tasks.findByName('mergeDebugAssets')?.dependsOn tasks['markdownToHtml']
tasks.findByName('mergeReleaseAssets')?.dependsOn tasks['markdownToHtml']
}
What could be the issue?
I took a look at dependency tree and noticed that logback library was using an old android library which was pulled by gradle form repository and strangely used to compile the project.
+--- com.github.tony19:logback-android-classic:1.1.1-2
| +--- com.github.tony19:apktool-lib:1.4.4-3
| | \--- com.google.android:android:2.1_r1
After excluding it from gradle dependency the project started to build properly.
implementation('com.github.tony19:logback-android-classic:1.1.1-6') {
exclude group: 'com.google.android', module: 'android'
}

Gradle child modules evaluation dependency

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?

Resources