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

gretty 3.0.4 doesn't work in gradle 7.0.2 #229

Closed
ataverasp opened this issue May 28, 2021 · 14 comments
Closed

gretty 3.0.4 doesn't work in gradle 7.0.2 #229

ataverasp opened this issue May 28, 2021 · 14 comments

Comments

@ataverasp
Copy link

Getting an afterEvaluate warning with 6.8.2 and error when running 7.0.2, below is the stack trace:

Using method Project.afterEvaluate(Closure) when the project is already evaluated has been deprecated. This will fail with an error in Gradle 7.0. The configuration given is ignored because the project has already been evaluated. To apply this configuration, remove afterEvaluate. Consult the upgrading guide for further information: https://docs.gradle.org/6.8.2/userguide/upgrading_version_5.html#calling_project_afterevaluate_on_an_evaluated_project_has_been_deprecated
        at org.gradle.api.internal.project.DefaultProject.maybeNagDeprecationOfAfterEvaluateAfterProjectIsEvaluated(DefaultProject.java:1050)
        at org.gradle.api.internal.project.DefaultProject.afterEvaluate(DefaultProject.java:1040)
        at org.gradle.api.Project$afterEvaluate$6.call(Unknown Source)
        at org.akhikhl.gretty.GrettyPlugin.apply(GrettyPlugin.groovy:877)
        at org.akhikhl.gretty.GrettyPlugin.apply(GrettyPlugin.groovy)
        at org.gradle.api.internal.plugins.ImperativeOnlyPluginTarget.applyImperative(ImperativeOnlyPluginTarget.java:43)
        at org.gradle.api.internal.plugins.RuleBasedPluginTarget.applyImperative(RuleBasedPluginTarget.java:51)
        at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:177)
        at org.gradle.api.internal.plugins.DefaultPluginManager.access$100(DefaultPluginManager.java:51)
        at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:272)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:56)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$run$1(DefaultBuildOperationExecutor.java:71)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.runWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:45)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:71)
        at org.gradle.api.internal.plugins.DefaultPluginManager.lambda$doApply$0(DefaultPluginManager.java:157)
        at org.gradle.configuration.internal.DefaultUserCodeApplicationContext.apply(DefaultUserCodeApplicationContext.java:43)
        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:156)
        at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:136)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:160)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:42)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:97)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:183)
        at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:49)
        at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.java:37)
        at org.gradle.api.Script$apply$0.callCurrent(Unknown Source)
@boris-petrov
Copy link
Member

I believe you've hit this. You have a multi-module project?

@boris-petrov
Copy link
Member

@ataverasp - do you mind trying to use a snapshot version from JitPack? Let us know if it fixes your problem,

@ataverasp
Copy link
Author

ataverasp commented May 31, 2021

yes, we have a multi-module project and we conditionally apply the plugin depending on the profile on some of the modules. @boris-petrov I tried the snapshot version and the error went away, I didn't check any of the tasks though, I didn't get that far. But the snapshot version is working fine.

Just a note it doesn't work on gradle 6.8.2 anymore

@boris-petrov
Copy link
Member

@ataverasp - thanks for trying out the snapshot.

The fact that the snapshot doesn't work on Gradle 6 is unfortunate... but I'm not sure how we can fix this.

@f4lco - the problem is that JitPack builds with the Gradle wrapper version that is in the repo. If we put Gradle 7 there, the built plugin will work only on Gradle 7 as was mentioned here. But if we put Gradle 6 as a wrapper, then the CI fails because Gradle 7 tests can't be run via the Gradle 6 wrapper... any ideas?

@f4lco
Copy link
Collaborator

f4lco commented Jun 1, 2021

@boris-petrov yes, Gradle 6 can't run on Java 16, that is the root cause. I'll open a PR so we can discuss more.

@madorb
Copy link

madorb commented Jun 4, 2021

sigh, i can't get this to work with any version of gradle 7.

I tried using jitpack, but actually running is failing with:

gradle appRun

Execution failed for task ':web-app:appRun'.
> Could not resolve all files for configuration ':web-app:grettyRunnerJetty9'.
   > Could not find org.gretty:gretty-runner-jetty9:gretty-3.x-v3.0.4-g4bd3117-41.

my module's build.gradle.kts has:

plugins {
    war
    id("org.gretty") version "gretty-3.x-SNAPSHOT"
}

settings.gradle.kts

pluginManagement {
    repositories {
        maven(url = "https://artifactory.qa.jagundi.com/artifactory/private")
        maven(url = "https://jitpack.io")
    }
    resolutionStrategy {
        eachPlugin {
            if (requested.id.toString() == "org.gretty") {
                useModule("com.github.gretty-gradle-plugin.gretty:gretty:gretty-3.x-SNAPSHOT")
            }
        }
    }
}

@boris-petrov
Copy link
Member

@madorb - did you try following these steps or perhaps this? It should work I guess. Perhaps @ataverasp can say what you've done wrong?

@ataverasp
Copy link
Author

When I tried from Jitpack, I was checking for errors on building the project. After checking running the appRunTask I do get the same errors as @madorb. Tried with several different versions tomcat and jetty version all error out with:

Execution failed for task ':web-app:appRun'.

Could not resolve all files for configuration ':web-app:grettyRunnerJetty9'.
Could not find org.gretty:gretty-runner-jetty9:gretty-3.x-v3.0.4-g4bd3117-41.

I did not try @boris-petrov suggestions yet, will try to post an update later in the week

@f4lco
Copy link
Collaborator

f4lco commented Jun 8, 2021

@madorb @ataverasp please see https://github.com/f4lco/gretty-jitpack for build instructions with JitPack and Gradle 6 or 7. It's my minimal reproducer project for build problems.
From the error message I assume that adjusting the dependency resolution of plugins is not enough. Gretty resolves additional artifacts depending on the selected servlet container using the main dependency configuration, not the one of the build script.

@ataverasp
Copy link
Author

ataverasp commented Jun 15, 2021

after forcing the deps resolutions suggested by @f4lco, gradle was able to resolve the dependencies needed for appRun and the app came up fine; that being said, I believe that this change will resolve the issue in a multi module project.

I had to add:

settings.gradle

pluginManagement {

  plugins {
       id 'org.gretty' version "gretty-3.x-SNAPSHOT" apply false
 }

 resolutionStrategy {
        eachPlugin {
            if (requested.id.toString() == "org.gretty") {
                useModule("com.github.gretty-gradle-plugin.gretty:gretty:gretty-3.x-SNAPSHOT")
            }
        }
    }

  maven {
      url "https://jitpack.io"
  
      metadataSources {
          artifact()
          mavenPom()
      }
}

build.gradle

    buildscript {

       dependencies {
     
          classpath 'com.github.gretty-gradle-plugin:gretty:gretty-3.x-SNAPSHOT'  
      }

   }

   configurations {
   
      all { 
      
        resolutionStrategy {
                dependencySubstitution.all { dependency
                    ->
                    // see https://docs.gradle.org/current/userguide/resolution_rules.html#sub:conditional_dependency_substitution
                    if (dependency.requested instanceof ModuleComponentSelector && dependency.
                            requested.
                            group == "org.gretty") {
                        dependency.
                                useTarget "com.github.gretty-gradle-plugin.gretty:${dependency.requested.module}:8dbea32"
                    }
                }
        }

      }
  
  }

nothing was changed on the build.gradle for the webApp module, we just need to call: ./gradlew :web-app:appRun

@ataverasp
Copy link
Author

@f4lco @boris-petrov is this good enough to publish a new version of gretty?

@boris-petrov
Copy link
Member

@ataverasp - yes, it is, we're working on releasing a new version.

@boris-petrov
Copy link
Member

@ataverasp, @f4lco, @ghid, @madorb - 3.0.5 is out! And on Maven Central! So please try it out and post any new issues you find. :)

@ismart-dev
Copy link

It worked. Thank you!

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

No branches or pull requests

5 participants