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

support gradle 6 #10

Merged
merged 15 commits into from
Oct 20, 2020
Merged

support gradle 6 #10

merged 15 commits into from
Oct 20, 2020

Conversation

anatawa12
Copy link
Owner

Fixes #9

Currently, build task runs successfully but deprecated Gradle features are used so I should fix it.

log of build with ForgeGradle-example:

anatawa12:~/IdeaProjects/ForgeGradle-example +(gradle6) $ ./gradlew build --warning-mode all

> Configure project :
The BuildListener.buildStarted(Gradle) method has been deprecated. This is scheduled to be removed in Gradle 7.0. Consult the upgrading guide for further information: https://docs.gradle.org/6.7/userguide/upgrading_version_5.html#apis_buildlistener_buildstarted_and_gradle_buildstarted_have_been_deprecated
        at build_42ucah4m3qwxjewdr1nfscau6.run(/Users/anatawa12/IdeaProjects/ForgeGradle-example/build.gradle:28)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
The maven plugin has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the maven-publish plugin instead. Consult the upgrading guide for further information: https://docs.gradle.org/6.7/userguide/upgrading_version_5.html#legacy_publication_system_is_deprecated_and_replaced_with_the_publish_plugins
        at build_42ucah4m3qwxjewdr1nfscau6.run(/Users/anatawa12/IdeaProjects/ForgeGradle-example/build.gradle:28)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
The compile configuration has been deprecated for dependency declaration. This will fail with an error in Gradle 7.0. Please use the implementation or api configuration instead. Consult the upgrading guide for further information: https://docs.gradle.org/6.7/userguide/upgrading_version_5.html#dependencies_should_no_longer_be_declared_using_the_compile_and_runtime_configurations
        at build_42ucah4m3qwxjewdr1nfscau6.run(/Users/anatawa12/IdeaProjects/ForgeGradle-example/build.gradle:28)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
Adding a Configuration as a dependency is a confusing behavior which isn't recommended. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. If you're interested in inheriting the dependencies from the Configuration you are adding, you should use Configuration#extendsFrom instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.artifacts.Configuration.html#org.gradle.api.artifacts.Configuration:extendsFrom(org.gradle.api.artifacts.Configuration[]) for more details.
        at build_42ucah4m3qwxjewdr1nfscau6.run(/Users/anatawa12/IdeaProjects/ForgeGradle-example/build.gradle:28)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
Internal API constructor DefaultDomainObjectSet(Class<T>) has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use ObjectFactory.domainObjectSet(Class<T>) instead. See https://docs.gradle.org/6.7/userguide/custom_gradle_types.html#domainobjectset for more details.
        at build_42ucah4m3qwxjewdr1nfscau6.run(/Users/anatawa12/IdeaProjects/ForgeGradle-example/build.gradle:28)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
The AbstractArchiveTask.archiveName property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveFileName property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:archiveName for more details.
The AbstractArchiveTask.destinationDir property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the destinationDirectory property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:destinationDir for more details.

> Task :getVersionJson
Property 'file' is not annotated with an input or output annotation. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.7/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Property 'url' is not annotated with an input or output annotation. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.7/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Property 'dieWithError' is not annotated with an input or output annotation. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.7/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.

> Task :extractUserDev UP-TO-DATE
Using insecure protocols with repositories has been deprecated. This is scheduled to be removed in Gradle 7.0. Switch Maven repository 'forge(http://files.minecraftforge.net/maven)' to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/6.7/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details.

> Task :sourceMainJava UP-TO-DATE
Type 'SourceCopyTask': field 'includes' without corresponding getter has been annotated with @Input. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.7/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Property 'incudes' is not annotated with an input or output annotation. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.7/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
The AbstractArchiveTask.baseName property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveBaseName property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:baseName for more details.
The AbstractArchiveTask.appendix property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveAppendix property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:appendix for more details.
The AbstractArchiveTask.version property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveVersion property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:version for more details.
The AbstractArchiveTask.classifier property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveClassifier property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:classifier for more details.
The AbstractArchiveTask.extension property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveExtension property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:extension for more details.

> Task :reobf
Property 'filesToObfuscate' is not annotated with an input or output annotation. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.7/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Property 'obfOutput' is not annotated with an input or output annotation. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.7/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Property 'obfuscated' is not annotated with an input or output annotation. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.7/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Property 'obfuscatedFiles' is not annotated with an input or output annotation. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.7/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.

BUILD SUCCESSFUL in 6s
10 actionable tasks: 4 executed, 6 up-to-date

@anatawa12 anatawa12 marked this pull request as ready for review October 19, 2020 00:59
@anatawa12
Copy link
Owner Author

@NeRdTheNed Can you try with this branch?

To try with this branch,

  1. clone and checkout this branch.
  2. run publishToMavenLocal task.
  3. change version of ForgeGradle to 1.2-1.0.3-SNAPSHOT in your mod project.
  4. If possible, clean the Gradle home, build directory, and .gradle in your mod project.
  5. setup and build your mod.

I know there're many warnings about features to be removed in 7.0. The warning will be fixed soon on another branch I will make.

@NeRdTheNed
Copy link

@NeRdTheNed Can you try with this branch?

To try with this branch,

  1. clone and checkout this branch.
  2. run publishToMavenLocal task.
  3. change version of ForgeGradle to 1.2-1.0.3-SNAPSHOT in your mod project.
  4. If possible, clean the Gradle home, build directory, and .gradle in your mod project.
  5. setup and build your mod.

I know there're many warnings about features to be removed in 7.0. The warning will be fixed soon on another branch I will make.

I've made a branch of my port of the More Bows mod to test the ForgeGradle snapshot, and it is compiling perfectly with Github actions! I've also tested the snapshot on my computer by removing all Gradle directories (Gradle home, build directory, .gradle), and then re-adding a Gradle 6.7 wrapper and compiling my mod, which works perfectly as well! The only "issue" I've found is that Gradle 6.7's new Java toolchain feature doesn't work with the snapshot. This is because setting sourceCompatibility or targetCompatibility is incompatible with toolchains, and ForgeGradle probably sets targetCompatibility when building a file. Here's some sample log output:

Could not determine the dependencies of task ':extractUserDev'.
> Could not resolve all dependencies for configuration ':userDevPackageDepConfig'.
   > The new Java toolchain feature cannot be used at the project level in combination with source and/or target compatibility

You can test this by changing these lines in the Gradle build script of my mod. This isn't a big issue (no one was able to use toolchains until Gradle 6.7, so no one was already using them with this fork!), and everything else works perfectly!

@NeRdTheNed
Copy link

NeRdTheNed commented Oct 19, 2020

I've just discovered a new issue: runClient doesn't work! Here's the output:

Could not determine the dependencies of task ':runClient'.
> Resolving dependency configuration 'runtimeOnly' is not allowed as it is defined as 'canBeResolved=false'.
  Instead, a resolvable ('canBeResolved=true') dependency configuration that extends 'runtimeOnly' should be resolved.

This should be reproducible by running "gradle runClient". runServer ("gradle runServer") has a similar issue:

Could not determine the dependencies of task ':runServer'.
> Resolving configuration 'runtimeOnly' directly is not allowed

@anatawa12
Copy link
Owner Author

The only "issue" I've found is that Gradle 6.7's new Java toolchain feature doesn't work with the snapshot. This is because setting sourceCompatibility or targetCompatibility is incompatible with toolchains, and ForgeGradle probably sets targetCompatibility when building a file. Here's some sample log output:

Could not determine the dependencies of task ':extractUserDev'.
> Could not resolve all dependencies for configuration ':userDevPackageDepConfig'.
   > The new Java toolchain feature cannot be used at the project level in combination with source and/or target compatibility

Thanks for your testing! I can't remove setting sourceCompatibility and runtimeCompatibility because of backwards compatibility but I've found a workaround. The forge plugin sets sourceCompatibility and runtimeCompatibility only during applying so please set both sourceCompatibility and runtimeCompatibility as null after applying forge plugin. I tested with your project and this workaround works well.

@anatawa12
Copy link
Owner Author

I've just discovered a new issue: runClient doesn't work! Here's the output:

Could not determine the dependencies of task ':runClient'.
> Resolving dependency configuration 'runtimeOnly' is not allowed as it is defined as 'canBeResolved=false'.
  Instead, a resolvable ('canBeResolved=true') dependency configuration that extends 'runtimeOnly' should be resolved.

This should be reproducible by running "gradle runClient". runServer ("gradle runServer") has a similar issue:

Could not determine the dependencies of task ':runServer'.
> Resolving configuration 'runtimeOnly' directly is not allowed

I'm sorry to forget to test runClient. I fixed this issue so please test with new version.

@NeRdTheNed
Copy link

NeRdTheNed commented Oct 20, 2020

I've now tested this with a new snapshot, and everything is working fine! I've even got GitHub actions to work with toolchains after a bit of work, which compiles perfectly! runClient is also now working perfectly fine, although I discovered a new bug that already exists in 1.2-1.0.2 during testing! I've written a seperate issue for it, because it's not caused by the new snapshot.

@anatawa12
Copy link
Owner Author

Thanks for testing this plugin. I merge this branch!

@anatawa12 anatawa12 merged commit deb23df into FG_1.2 Oct 20, 2020
@anatawa12 anatawa12 deleted the support-gradle-6 branch October 20, 2020 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Request] Support for Gradle 6
2 participants