grails / grails-gradle-plugin

Apache License 2.0
6 stars 9 forks source link

GrailsGradlePlugin.enableFileWatch should only include micronaut-inject-groovy in developmentOnly #14

Closed jchharris closed 3 years ago

jchharris commented 3 years ago

Thanks for reporting an issue for Grails framework, please review the task list below before submitting the issue. Your issue report will be closed if the issue is incomplete and the below tasks not completed.

NOTE: If you are unsure about something and the issue is more of a question a better place to ask questions is on Stack Overflow (http://stackoverflow.com/tags/grails) or Slack (http://slack-signup.grails.org). DO NOT use the issue tracker to ask questions.

Task List

Steps to Reproduce

The GrailsGradlePlugin.enableFileWatch() method currently brings in the micronaut-inject-groovy into the runtime configuration. It should only be included for developmentOnly. This occurs when you are building the Grails application into an executable JAR/WAR.

Backport the change from the 5.0 branch to 4.0.x so that the method is changed from:

protected void enableFileWatch(Environment environment, Project project) {
       if (environment.isReloadEnabled()) {
            project.configurations {
                agent
            }
            final String micronautVersion = project.properties['micronautVersion']
            project.dependencies.add("runtimeOnly", "io.micronaut:micronaut-inject-groovy:${micronautVersion?:defaultMicronautVersion}")
            project.afterEvaluate(new AgentTasksEnhancer())
        }
    }

to:

    protected void enableFileWatch(Environment environment, Project project) {
        if (environment.isReloadEnabled()) {
            project.configurations {
                agent
            }
            final String micronautVersion = project.properties['micronautVersion']
            if (project.configurations.findByName("developmentOnly")) {
                project.dependencies.add("developmentOnly", "io.micronaut:micronaut-inject-groovy:${micronautVersion?:defaultMicronautVersion}")
            }
            project.afterEvaluate(new AgentTasksEnhancer())
        }
    }

Expected Behaviour

micronaut-inject-groovy should not be inside of a production WAR/JAR file.

Actual Behaviour

when you assemble a WAR file, the micronaut-inject-groovy jar is included in the WAR which slows everything down.

Environment Information

Example Application

jchharris commented 3 years ago

In particular backport https://github.com/grails/grails-core/pull/11704 to 4.0.x