Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No value has been specified for property mainClassName #336

Closed
nogo opened this issue Nov 6, 2017 · 33 comments
Closed

No value has been specified for property mainClassName #336

nogo opened this issue Nov 6, 2017 · 33 comments
Labels
Milestone

Comments

@nogo
Copy link

nogo commented Nov 6, 2017

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
}

@andrii-kovalenko-ct
Copy link

andrii-kovalenko-ct commented Nov 6, 2017

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

@schnapster
Copy link

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

@lbergelson
Copy link

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

@sgnewson
Copy link

sgnewson commented Jan 3, 2018

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

@jonwagner
Copy link

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

@sgnewson
Copy link

sgnewson commented Jan 4, 2018

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

@Mat2095
Copy link

Mat2095 commented Feb 3, 2018

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

@johnrengelman
Copy link
Collaborator

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

@RaviH
Copy link

RaviH commented Feb 8, 2018

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"]
}

@Mat2095
Copy link

Mat2095 commented Feb 8, 2018

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'

[...]

@ljohnston
Copy link

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
Copy link

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

albertogoffi added a commit to albertogoffi/toradocu that referenced this issue Feb 28, 2018
@koralgooll
Copy link

koralgooll commented Mar 28, 2018

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

@abcfy2
Copy link

abcfy2 commented Apr 3, 2018

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

hayco pushed a commit to HuygensING/lobsang that referenced this issue May 8, 2018
@hpmtissera
Copy link

Looks like issue is fixed in Version 2.0.4

@Mat2095
Copy link

Mat2095 commented May 9, 2018

I'm still getting the error with version 2.0.4.

@maikelsteneker
Copy link

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

alpar-t added a commit to alpar-t/elasticsearch that referenced this issue May 9, 2018
- Apply workaround for: GradleUp/shadow#336
- bump plugin to 2.0.4

Changes between 2.0.2 and 2.0.4 of the plugin:
```
477db40 12 days ago [email protected] Release 2.0.4
3e3da37 3 weeks ago [email protected] Remove internal Gradle API and annotation internal getters on shadow jar.
31e2380 3 weeks ago [email protected] Close input streams. Closes elastic#364
f712cc8 3 weeks ago [email protected] Upgrade ASM to 6.1.1 to address perf issues. Closes elastic#374
2f94b2b 3 weeks ago [email protected] next version
23bbf3d 7 weeks ago [email protected] Add some gradle versions. Update changelog for 2.0.3
7435c74 7 weeks ago [email protected] Merge pull request elastic#367 from ttsiebzehntt/366-java10
325c002 7 weeks ago [email protected] Update ASM to 6.1
94550e5 3 months ago [email protected] Merge pull request elastic#356 from sgnewson/update-file-to-files
66b691e 4 months ago [email protected] Merge pull request elastic#358 from 3flex/patch-1
14761b1 4 months ago [email protected] fix markdown for User Guide URL in issue template
a3f6984 4 months ago [email protected] update inputs.file to inputs.files, to remove warning
```

closes elastic#30389
alpar-t added a commit to elastic/elasticsearch that referenced this issue May 10, 2018
* Solve Gradle deprecation warnings around shadowJar

- Apply workaround for: GradleUp/shadow#336
- bump plugin to 2.0.4

Changes between 2.0.2 and 2.0.4 of the plugin:
```
477db40 12 days ago [email protected] Release 2.0.4
3e3da37 3 weeks ago [email protected] Remove internal Gradle API and annotation internal getters on shadow jar.
31e2380 3 weeks ago [email protected] Close input streams. Closes #364
f712cc8 3 weeks ago [email protected] Upgrade ASM to 6.1.1 to address perf issues. Closes #374
2f94b2b 3 weeks ago [email protected] next version
23bbf3d 7 weeks ago [email protected] Add some gradle versions. Update changelog for 2.0.3
7435c74 7 weeks ago [email protected] Merge pull request #367 from ttsiebzehntt/366-java10
325c002 7 weeks ago [email protected] Update ASM to 6.1
94550e5 3 months ago [email protected] Merge pull request #356 from sgnewson/update-file-to-files
66b691e 4 months ago [email protected] Merge pull request #358 from 3flex/patch-1
14761b1 4 months ago [email protected] fix markdown for User Guide URL in issue template
a3f6984 4 months ago [email protected] update inputs.file to inputs.files, to remove warning
```

closes #30389

* Improove comment as suggested
@RichyHBM
Copy link

Has there been any progress on this @johnrengelman ?

@black-snow
Copy link

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

@takirala
Copy link

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

@sora4222
Copy link

For those that are having a struggle in Intellij and their Gradle build, please check your gradle build in gradle/wrapper/graddle-wrapper.jar
I was having this issue until I changed my gradle version to 4.9, I actually did this by just changing the referenced gradle file to */gradle-4.9-bin.zip. 4.9 solved it for me.

@takirala
Copy link

@sora4222 When you say solved do you mean that the warning no longer appears or were you able to compile the code ?

I am using gradle 4.10 and the warning still appears for me with 2.0.4

@maikelsteneker
Copy link

No longer an issue for me using Gradle 4.4 and shadow 4.0.1.

devinbileck added a commit to devinbileck/bisq that referenced this issue Nov 14, 2018
Updating to the latest shadow plugin version will resolve the following
deprecation warning:

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

See: GradleUp/shadow#336
@sasconsul
Copy link

I have the problem with shadow plugin version 4.0.3, dropping back to 4.0.2 works.

@yinxing2008
Copy link

update to shadow plugin version 5.0.0

@lUNuXl
Copy link

lUNuXl commented Apr 9, 2020

$ ./gradlew --version

------------------------------------------------------------
Gradle 5.6.2
------------------------------------------------------------

Build time:   2019-09-05 16:13:54 UTC
Revision:     55a5e53d855db8fc7b0e494412fc624051a8e781

Kotlin:       1.3.41
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.14 compiled on March 12 2019
JVM:          1.8.0_242 (Oracle Corporation 25.242-b08)
OS:           Linux 4.19.107-2-lts amd64
buildscript {
    repositories {
        jcenter()
    }
    
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
    }
}

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

mainClassName = "io.ktor.server.jetty.EngineMain"
group 'pl.smiesznadomena'
version '0.0.2'


sourceSets {
    main.kotlin.srcDirs = main.java.srcDirs = ['src']
    test.kotlin.srcDirs = test.java.srcDirs = ['test']
    main.resources.srcDirs = ['resources']
    test.resources.srcDirs = ['testresources']
}

repositories {
    mavenLocal()
    jcenter()
    maven { url 'https://kotlin.bintray.com/ktor' }
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation "io.ktor:ktor-server-jetty:$ktor_version"
    implementation "ch.qos.logback:logback-classic:$logback_version"
    implementation "io.ktor:ktor-server-core:$ktor_version"
    implementation "io.ktor:ktor-server-host-common:$ktor_version"
    implementation "io.ktor:ktor-locations:$ktor_version"
    testImplementation "io.ktor:ktor-server-tests:$ktor_version"
    implementation 'net.dv8tion:JDA:4.1.1_133'
}

// This task will generate your fat JAR and put it in the ./build/libs/ directory
shadowJar {
    manifest {
        attributes 'Main-Class': mainClassName
    }
}

A problem was found with the configuration of task ':shadowJar'.
> No value has been specified for property 'mainClassName'.

@jsonwan
Copy link

jsonwan commented Jul 27, 2020

I have the problem with shadow plugin version 2.0.2 and gradle version 6.1.0, upgrade shadow plugin to 5.1.0 works.

@eric-ampire
Copy link

I have the same problem but I solved it by updating Gradle to version 6.1.1 and I also updated the version of shadow classpath "com.github.jengelman.gradle.plugins:shadow:6.0.0".

@red-avtovo
Copy link

red-avtovo commented Nov 18, 2020

In order to fix the issue you need to add the following block in build.gradle:

application {
	// Desired way mainClass.set("<main class>") causes an issue during jar packaging
	@Suppress("DEPRECATION")
	mainClassName ="<your main class here>"
}

@vojkny
Copy link

vojkny commented Nov 28, 2020

        // Desired way mainClass.set("<main class>") causes an issue during jar packaging
	@Suppress("DEPRECATION")
	mainClassName ="<your main class here>"

This is not a solution - the mainClassName should not be used anymore, so the shadow plugin should not use it.

@joffrey-bion
Copy link

joffrey-bion commented Dec 15, 2020

@knyttl for this reason I believe the issue should be reopened. This is a bug in the shadow plugin, using a deprecated API, and it should be fixed.

I'm surprised on Gradle side, though, that calling mainClass.set("...") doesn't also set mainClassName for backwards compat.

EDIT: my bad, I just noticed that this is tracked here already: #609

@pmorch
Copy link

pmorch commented Jan 6, 2021

This solution doesn't work with gradle 6.7 and shadowJar 6.1.0:

application {
	// Desired way mainClass.set("<main class>") causes an issue during jar packaging
	@Suppress("DEPRECATION")
	mainClassName ="<your main class here>"
}

It removes the strikethrough formatting from Intellij, but ./gradlew shadowJar still reports:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings

And it sounds like suppression of warnings from gradle is not possible by choice...

@jspetrak
Copy link

jspetrak commented Apr 14, 2021

This solution doesn't work with gradle 6.7 and shadowJar 6.1.0:

And it sounds like suppression of warnings from gradle is not possible by choice...

@pmorch I have just had the same issue on Gradle 7.0 and ShadowJar 6.1.0... After gradle clean build shadowJar the error did not occur.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests