shadow icon indicating copy to clipboard operation
shadow copied to clipboard

No value has been specified for property mainClassName

Open nogo opened this issue 9 years ago • 33 comments

Please check the (User Guide)[http://imperceptiblethoughts.com/shadow] before submitting "how do I do 'x'?" questions!

Shadow Version

2.0.1

Gradle Version

4.3

Expected Behavior

work as in 4.2.1

Actual Behavior

:shadowJar A problem was found with the configuration of task ':shadowJar'. Registering invalid inputs and outputs via TaskInputs and TaskOutputs methods has been deprecated and is scheduled to be removed in Gradle 5.0.

  • No value has been specified for property 'mainClassName'.

Build script

Extract of my build script

apply plugin: 'java' apply plugin: 'application' apply plugin: 'com.github.johnrengelman.shadow'

mainClassName = 'com.package.to.Class'

shadowJar { baseName = 'launcher' classifier = null version = null }

nogo avatar Nov 06 '17 08:11 nogo

same here, just have updated to gradle 4.3, shadow version 2.0.1 (as before)

andrii-kovalenko-ct avatar Nov 06 '17 11:11 andrii-kovalenko-ct

Fwiw the resulting jar still works (for me) despite the warning, what actually breaks with gradle 4.3 is runShadow.

schnapster avatar Nov 08 '17 19:11 schnapster

I'm also seeing this with shadow 2.0.2 and gradle 4.4.

lbergelson avatar Dec 12 '17 16:12 lbergelson

Might just be a missing mainClassName = 'com.package.to.Class' in this plugin's build?

sgnewson avatar Jan 03 '18 00:01 sgnewson

If you define mainClassName before you apply the plugin, the build succeeds. Sounds like an issue with initialization order.

jonwagner avatar Jan 04 '18 20:01 jonwagner

Can confirm, placing the mainClassName after the application plugin and before the shadow plugin lines removes the warnings

sgnewson avatar Jan 04 '18 21:01 sgnewson

I'm also seeing this with shadow 2.0.2 and gradle 4.5.

Mat2095 avatar Feb 03 '18 18:02 Mat2095

yeah, i need to improve this, but the workaround is to specify mainClassName before applying the Shadow plugin.

johnrengelman avatar Feb 04 '18 00:02 johnrengelman

With the build.gradle below, I still get:

A problem was found with the configuration of task ':vertx-web:shadowJar'. Registering invalid inputs and outputs via TaskInputs and TaskOutputs methods has been deprecated and is scheduled to be removed in Gradle 5.0.
- No value has been specified for property 'mainClassName'.
The SimpleWorkResult type has been deprecated and is scheduled to be removed in Gradle 5.0. Please use WorkResults.didWork() instead.

> Task :vertx-web:startShadowScripts 
Using TaskInputs.file() with something that doesn't resolve to a File object has been deprecated and is scheduled to be removed in Gradle 5.0. Use TaskInputs.files() instead.

Gradle version: 4.4

plugins {
    id 'application'
    id 'com.github.johnrengelman.shadow' version '2.0.1'
}

mainClassName = 'io.vertx.core.Launcher'
def vertxVersion = '3.5.0'
def mainVerticleName = 'com.charter.devtool.web.vertx.verticle.MainVerticle'
def watchForChange = 'src/**/*'
def doOnChange = './gradlew classes'

dependencies {
    compile project(':devtool-core')
    compile project(':devtool-db')
    compile project(':devtool-stash-client')

    compile('io.vertx:vertx-core:3.5.0')
    compile('io.vertx:vertx-web:3.5.0')
    compile('com.zandero:rest.vertx:0.7.5')
    compile('org.eclipse.jgit:org.eclipse.jgit:4.9.2.201712150930-r')
    compile('com.github.salomonbrys.kodein:kodein:4.1.0')
}

shadowJar {
    mainClassName = 'io.vertx.core.Launcher'
    classifier = 'fat'
    manifest {
        attributes "Main-Verticle": mainVerticleName
    }
    mergeServiceFiles {
        include 'META-INF/services/io.vertx.core.spi.VerticleFactory'
    }
}

run {
    args = ['run', mainVerticleName, "--redeploy=$watchForChange", "--launcher-class=$mainClassName", "--on-redeploy=$doOnChange"]
}

RaviH avatar Feb 08 '18 18:02 RaviH

Try something like

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
    }
}

plugins {
    id "application"
}

mainClassName = '...'

apply plugin: 'com.github.johnrengelman.shadow'

[...]

Mat2095 avatar Feb 08 '18 18:02 Mat2095

The above workaround fixes the 'mainClassName' issue, but does not address the following warning:

Task :vertx-web:startShadowScripts Using TaskInputs.file() with something that doesn't resolve to a File object has been deprecated and is scheduled to be removed in Gradle 5.0. Use TaskInputs.files() instead.

ljohnston avatar Feb 22 '18 22:02 ljohnston

After a little more digging, seems like this has been fixed but not yet released. Thx @johnrengelman ! Looking forward to 2.0.3.

ljohnston avatar Feb 22 '18 23:02 ljohnston

The application plugin needs this property in gradle build file. It is in docs.

koralgooll avatar Mar 28 '18 13:03 koralgooll

shadow plugin 2.0.3 with gradle 4.6 still have this issue:

buildscript {
    repositories {
        mavenLocal()
        maven { url "http://maven.aliyun.com/nexus/content/groups/public" }
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.3'
    }
}

apply plugin: 'codenarc'
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'idea'

mainClassName='com.zcwl.BarnApplication'
./gradlew shadowjar --warning-mode=all

> Task :shadowJar 
A problem was found with the configuration of task ':shadowJar'. Registering invalid inputs and outputs via TaskInputs and TaskOutputs methods has been deprecated and is scheduled to be removed in Gradle 5.0.
 - No value has been specified for property 'mainClassName'.


BUILD SUCCESSFUL in 6s
5 actionable tasks: 3 executed, 2 up-to-date

abcfy2 avatar Apr 03 '18 03:04 abcfy2

Looks like issue is fixed in Version 2.0.4

hpmtissera avatar May 09 '18 03:05 hpmtissera

I'm still getting the error with version 2.0.4.

Mat2095 avatar May 09 '18 09:05 Mat2095

The problem is still there for me when using 2.0.4 as well.

maikelsteneker avatar May 09 '18 09:05 maikelsteneker

Has there been any progress on this @johnrengelman ?

RichyHBM avatar Jun 28 '18 21:06 RichyHBM

Moving mainClassName before applying the plugin doesn't help for me.

black-snow avatar Jul 30 '18 17:07 black-snow

This is still a problem with gradle 4.10 and shadow 2.0.4.

takirala avatar Sep 11 '18 00:09 takirala