Johnrengelman shadow 5.1.0 not running in gradle 5.6.3 - kotlin

I'm trying to create a fat jar for my kotlin + micronaut lambda project with shadow plugin.
My build.gradle
plugins {
id "org.jetbrains.kotlin.jvm" version "1.3.41"
id "org.jetbrains.kotlin.kapt" version "1.3.41"
id "io.micronaut.library" version "1.5.4"
id "org.jetbrains.kotlin.plugin.allopen" version "1.3.41"
id "org.jetbrains.kotlin.plugin.serialization" version "1.3.50"
id("com.github.johnrengelman.shadow") version "5.1.0"
}
When i try to execute a gradle task i receive an error to upgrade gradle to 6.x but the shadow 5.1.0 was supposed to work in gradle 5.x
Error:
FAILURE: Build failed with an exception.
* Where:
Build file 'my-app\app\build.gradle' line: 7
* What went wrong:
An exception occurred applying plugin request [id: 'com.github.johnrengelman.shadow', version: '5.1.0']
> Failed to apply plugin [class 'com.github.jengelman.gradle.plugins.shadow.ShadowBasePlugin']
> This version of Shadow supports Gradle 6.0+ only. Please upgrade.

Related

Gradle fails after kotlin serialization plugin update to 1.7.10

My build.gradle.kts starts as follows:
...
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
...
kotlin("jvm") //target version is java 11
kotlin("plugin.serialization") version "1.6.21"
}
When I try to update the kotlin serialization plugin to the more recent 1.7.10 version, I get the following compilation error:
A problem occurred configuring project ':my-little-project'.
> Failed to notify project evaluation listener.
> org.jetbrains.kotlin.gradle.plugin.KotlinGradleSubplugin: org.jetbrains.kotlinx.serialization.gradle.SerializationGradleSubplugin not a subtype
> org.jetbrains.kotlin.gradle.plugin.KotlinGradleSubplugin: org.jetbrains.kotlinx.serialization.gradle.SerializationGradleSubplugin not a subtype
How do I fix this? Thanks!
Stack trace (too large to post completely, for more just ask):
Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':my-little-project'.
at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:75)
at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:68)
at org.gradle.configuration.project.LifecycleProjectEvaluator.access$400(LifecycleProjectEvaluator.java:51)
...
Caused by: org.gradle.internal.event.ListenerNotificationException: Failed to notify project evaluation listener.
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:89)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:346)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:249)
...
Thanks #aSemy for listing what turned out to be the issue. Our microservice architecture meant there was another, overarching, build.gradle.kts file which contained this line that also needed updating:
kotlin("jvm") version "1.6.10" apply false

Quarkus gradle test fails

I am trying to run the simple 'getting-started'-type gradle project with quarkus and my unit test fails everytime with this error
Caused by: io.quarkus.bootstrap.BootstrapException: Failed to locate project pom.xml for C:\Users\myuser\IdeaProjects\myproj\build\classes\java\main
Followed instructions here https://quarkus.io/guides/gradle-tooling
Any suggestions or thoughts on what is going on?
Gradle version details
Gradle 5.4
Build time: 2019-04-16 02:44:16 UTC
Revision: a4f3f91a30d4e36d82cc7592c4a0726df52aba0d
Kotlin: 1.3.21
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 11.0.2 (Oracle Corporation 11.0.2+9)
OS: Windows 10 10.0 amd64
btw. the problem is still open (current version 0.19.1) and issue (2307) is still unresolved.
The reason is that #QuarkusTest points to the QuarkusTestExtension, which in BootstrapClassLoaderFactory.newDeploymentClassLoader attempts to resolve local project with Maven.
We have options:
wait for official solution (see issue)
write own extension overriding BootstrapClassLoaderFactory to "understand" gradle project structure
apply a workaround (for time being), i.e. generate pom.xml from gradle build
Workaround
in build.grade:
plugins {
id 'java'
id 'io.quarkus' version '0.19.1'
// ...
id 'maven-publish'
}
// ...
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
// augment your pom here if necessary
}
}
}
// ...
task createPom(type: Copy) {
description 'This is workaround to generate pom.xml, needed for #QuarkusTest tests.'
dependsOn('generatePomFileForMavenJavaPublication')
from "$buildDir/publications/mavenJava/pom-default.xml"
into '.'
rename('pom-default.xml', 'pom.xml')
}
Note:
use 'maven-publish', not obsolete 'maven' plugin.
do not forget to apply ./gradlew createPom on dependencies changes

Gradle Sync Kotlin Error in Android Studio 3.3.2

Caused by: org.gradle.api.resources.ResourceException: Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.3.11/kotlin-reflect-1.3.11.jar'.
at org.gradle.internal.resource.ResourceExceptions.failure(ResourceExceptions.java:74)
at org.gradle.internal.resource.ResourceExceptions.getFailed(ResourceExceptions.java:57)
at org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor.copyToCache(DefaultCacheAwareExternalResourceAccessor.java:201)
at org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor.access$300(DefaultCacheAwareExternalResourceAccessor.java:54)
at org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor$1.create(DefaultCacheAwareExternalResourceAccessor.java:89)
at org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor$1.create(DefaultCacheAwareExternalResourceAccessor.java:81)
at org.gradle.cache.internal.ProducerGuard$AdaptiveProducerGuard.guardByKey(ProducerGuard.java:97)
at org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor.getResource(DefaultCacheAwareExternalResourceAccessor.java:81)
at org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.downloadByCoords(DefaultExternalResourceArtifactResolver.java:133)
at org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.downloadStaticResource(DefaultExternalResourceArtifactResolver.java:97)
at org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.resolveArtifact(DefaultExternalResourceArtifactResolver.java:66)
at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver$RemoteRepositoryAccess.resolveArtifact(ExternalResourceResolver.java:477)
Fixed by change the gradle version from classpath 'com.android.tools.build:gradle:3.3.0' classpath' to 'com.android.tools.build:gradle:3.3.2'

Android studio 2.2 gradle plugin for instant run error

I am using android studio 2.2 and getting the below error while trying to build the project
Error:Cause: com.android.build.gradle.AppPlugin cannot be cast to groovy.lang.GroovyObject
I added classpath 'com.android.tools.build:gradle:2.2.0'
in my top level gradle
My project has 11 modules and compilesdk version is 23,buildtools version is 24.0.2
How can I build the fix the issues and build the project
I met the same problem。
“Your project may be using a third-party plugin which is not compatible with the other plugins... ”as the console reminders。
So you should check your buildscript{dependencies{}} in build.gradle file。
Like this:
dependencies {
......
classpath 'com.android.tools.build:gradle:2.2'
classpath 'com.xxx.gradle.sign:sign:0.2.0'
......
}
and I update the sign plugin from sign:0.2.0 to sign:0.1.0,then it's ok。So you should find the incompatible plugin and update it。

New Gradle project (command-line and single-module) can't find Android plugin

I had a single-module project working in command-line Ant and want to convert it to Gradle but it fails at: 'gradle tasks', because it can't find the Android plugin.
This failure coincided with an upgrade to the Android SDK/Tools & Support Repository.
I'm using windows 10 and the TextPad editor (DOS command line screen is included).
The Gradle version is 2.12
build.gradle:
apply plugin: 'com.android.library'
android{
compileSdkVersion 20
buildToolsVersion '23'
System.properties['com.android.build.gradle.overrideVersionCheck'] = 'true'
repositories{
jcenter()
}
dependencies{
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
Note:
I've tried moving the repositories and dependencies out from under the android {}'s.
Error Message:
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\Android\Clox\build.gradle' line: 1
* What went wrong:
A problem occurred evaluating root project 'Clox'.
Plugin with id 'com.android.library' not found.
local.properties file:
sdk.dir=c:\users\chatt\AppData\Local\Android\sdk1
or
sdk.dir=C\:\\Users\\chatt\\AppData\\Local\\Android\\sdk1
I included this because it seems to ignore my JDK_HOME.
JDK_HOME started off pointing at JAVA_HOME. I tried changing JDK_HOME to: 'XXX' and it just gave the usual error.
JDK_HOME is now c:\users\chatt\AppData\Local\Android\sdk1, which I got from the header of the Android SDK Manager, and ANDROID_HOME=%JDK_HOME%.
RECENT TESTING:
I had a sequence of errors that I found the answers to in:
https://stackoverflow.com/questions/
(thank you people)
and then I updated the JDK, adding the Build Tools, with the results:
Packages
- Android SDK Tools, revision 25.1.1
- Android SDK Build-tools, revision 23.0.3
...
- Android Support Repository, revision 30
plus I see there is installed:
-Android SDK Platform 6.0 (API 23)
-Android Support Library v.23.2.1
Apparently this update is what caused the com.android.library plugin not found error; apart from a JAVA_HOME error that's all it gives me.
Apparently my build.gradle structure was wasn't sufficiently standard.
I've switched to a version from:
http://tools.android.com/tech-docs/new-build-system/user-guide
buildscript {
System.properties['com.android.build.gradle.overrideVersionCheck'] = 'true'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
}