Trying to remove shadowJar plugin

I believe that my gradle project no longer needs the shadowJar plugin and so I am trying to remove it but I can’t seem to get rid of the related gradle tasks which is causing my build to fail. In the build.gradle.kts I have removed this:

plugins {
  // Other plugins still in place
  // id("com.github.johnrengelman.shadow") version "6.1.0" // Removed this line
}

I also ran ./gradlew after, but when I look at the list of tasks available I still see all the shadowJar task options. And when I build it is still trying to run the shadowJar tasks which is failing my build. How can I unregister these tasks?

─❯ ./gradlew tasks 
Application tasks
-----------------
run - Runs this project as a JVM application
runShadow - Runs this project as a JVM application using the shadow jar
startShadowScripts - Creates OS specific scripts to run the project as a JVM application using the shadow jar

Build tasks
-----------
assemble - Assembles the outputs of this project.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildKotlinToolingMetadata - Build metadata json file containing information about the used Kotlin tooling
buildNeeded - Assembles and tests this project and all projects it depends on.
classes - Assembles main classes.
clean - Deletes the build directory.
jar - Assembles a jar archive containing the main classes.
testClasses - Assembles test classes.

Build Setup tasks
-----------------
init - Initializes a new Gradle build.
wrapper - Generates Gradle wrapper files.

Distribution tasks
------------------
assembleDist - Assembles the main distributions
assembleShadowDist - Assembles the shadow distributions
distTar - Bundles the project as a distribution.
distZip - Bundles the project as a distribution.
installDist - Installs the project as a distribution as-is.
installShadowDist - Installs the project as a distribution as-is.
shadowDistTar - Bundles the project as a distribution.
shadowDistZip - Bundles the project as a distribution.

Documentation tasks
-------------------
javadoc - Generates Javadoc API documentation for the main source code.

Formatting tasks
----------------
ktlintFormat - Runs the ktlint formatter on all kotlin sources in this project.

Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project 'bushel-trade-futures'.
dependencies - Displays all dependencies declared in root project 'bushel-trade-futures'.
dependencyInsight - Displays the insight into a specific dependency in root project 'bushel-trade-futures'.
help - Displays a help message.
javaToolchains - Displays the detected java toolchains.
kotlinDslAccessorsReport - Prints the Kotlin code for accessing the currently available project extensions and conventions.
ktlintGenerateBaseline - Generates KtLint baseline file
outgoingVariants - Displays the outgoing variants of root project 'bushel-trade-futures'.
projects - Displays the sub-projects of root project 'bushel-trade-futures'.
properties - Displays the properties of root project 'bushel-trade-futures'.
tasks - Displays the tasks runnable from root project 'bushel-trade-futures' (some of the displayed tasks may belong to subprojects).

IDE tasks
---------
cleanIdea - Cleans IDEA project files (IML, IPR)
idea - Generates IDEA project files (IML, IPR, IWS)

Jib tasks
---------
jib - Builds a container image to a registry.
jibBuildTar - Builds a container image to a tarball.
jibDockerBuild - Builds a container image to a Docker daemon.

Shadow tasks
------------
knows - Do you know who knows?
shadowJar - Create a combined JAR of project and runtime dependencies

Verification tasks
------------------
check - Runs all checks.
jacocoTestCoverageVerification - Verifies code coverage metrics based on specified rules for the test task.
jacocoTestReport - Generates code coverage report for the test task.
ktlintCheck - Runs ktlint on all kotlin sources in this project.
sonarqube - Analyzes project ':app:cashbids' and its subprojects with SonarQube.
test - Runs the test suite.

As far as I can tell there isn’t another plugin that is including shadowJar. Is there some way to unregister tasks without coding it up in my gradle.build.kts? I thought that by removing the plugin which added the tasks it would automatically unregister the gradle tasks.

And to be clear, what is failing my build is when I comment out the “mainClassName” property:

project.setProperty("mainClassName", "my.project.AppKt") // <- When I comment out this line it seems to fail the build
application {
    mainClass.set("my.project.AppKt")
}

When I comment out that project property I get the following error on the build

A problem was found with the configuration of task ':app:cashbids:shadowJar' (type 'ShadowJar').
  - In plugin 'com.github.jengelman.gradle.plugins.shadow.ShadowBasePlugin' type 'com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar' property 'mainClassName' doesn't have a configured value.

If I leave that line in there the build succeeds, but of course it is running all these shadowJar tasks that I think are unnecessary.

:man_facepalming: This is very embarrassing! I just discovered that one of my subprojects still had the plugin enabled in the build.gradle.kts. I thought I removed it but I guess not. Yeesh, this issue is resolved now. Wish I could delete this topic :slight_smile:

It remains here, immortalized for future generations, forever educating others to come.

Don’t sweat it, we all need a little public humiliation to keep us in check. :rofl: