[PR] ear-plugin: Support external DTDs in descriptor when using Java8

In Gradle 2.1’s ear plugin, it is impossible to use an existing descriptor that references an external DTD when Java8 is used to run gradle. JAXP as of 1.5 / Java as of Java8 won’t allow referencing external DTDs e.g. using http URLs by default.

D:\tmp\gradle-test\ear-proj>gradle tasks --stacktrace
[Fatal Error] :2:134: Externe DTD: Lesen von externer DTD "application_1_3.dtd" nicht erfolgreich, da "http"-Zugriff
wegen der von der Eigenschaft "accessExternalDTD" festgelegten Einschrõnkung nicht zulõssig ist.
  FAILURE: Build failed with an exception.
  * Where:
Build file 'D:\tmp\gradle-test\ear-proj\build.gradle' line: 1
  * What went wrong:
A problem occurred evaluating root project 'ear-proj'.
> Failed to apply plugin [id 'ear']
   > Externe DTD: Lesen von externer DTD "application_1_3.dtd" nicht erfolgreich, da "http"-Zugriff wegen der von der Eigenschaft "accessExternalDTD" festgelegten Einschrõnkung nicht zulõssig ist.
  * Try:
Run with --info or --debug option to get more log output.
  * Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'ear-proj'.
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
        at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:190)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:39)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
        at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:521)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:82)
        at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:31)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:33)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'ear']
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:117)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:80)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:131)
        at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:37)
        at org.gradle.api.Project$apply.call(Unknown Source)
        at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.groovy:34)
        at org.gradle.api.Script$apply.callCurrent(Unknown Source)
        at build_45n9h2e857003vei2uv9a4m3qh.run(D:\tmp\gradle-test\ear-proj\build.gradle:1)
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
        ... 31 more
Caused by: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 134; Externe DTD: Lesen von externer DTD "application_1_3.dtd" nicht erfolgreich, da "http"-Zugriff wegen der von der Eigenschaft "accessExternalDTD" festgelegte
n Einschrõnkung nicht zulõssig ist.
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1239)
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
        at org.gradle.plugins.ear.descriptor.internal.DefaultDeploymentDescriptor.readFrom(DefaultDeploymentDescriptor.groovy:126)
        at org.gradle.plugins.ear.descriptor.internal.DefaultDeploymentDescriptor$readFrom.callCurrent(Unknown Source)
        at org.gradle.plugins.ear.descriptor.internal.DefaultDeploymentDescriptor.readFrom(DefaultDeploymentDescriptor.groovy:117)
        at org.gradle.plugins.ear.descriptor.DeploymentDescriptor$readFrom.call(Unknown Source)
        at org.gradle.plugins.ear.EarPluginConvention.setAppDirName(EarPluginConvention.groovy:41)
        at org.gradle.plugins.ear.EarPluginConvention_Decorated.setAppDirName(Unknown Source)
        at org.gradle.plugins.ear.EarPlugin.apply(EarPlugin.java:66)
        at org.gradle.plugins.ear.EarPlugin.apply(EarPlugin.java:45)
        at org.gradle.api.internal.plugins.DefaultPluginContainer.providePlugin(DefaultPluginContainer.java:188)
        at org.gradle.api.internal.plugins.DefaultPluginContainer.addPluginInternal(DefaultPluginContainer.java:137)
        at org.gradle.api.internal.plugins.DefaultPluginContainer.apply(DefaultPluginContainer.java:103)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:115)
        ... 40 more
  BUILD FAILED

However, those exact URLs might be required in the descriptor by some application servers at ear deploy time.

I have created a pull request fixing the issue: https://github.com/gradle/gradle/pull/336

Cheers :slight_smile: - Mike

My pull request has been merged, I guess this will make it into Gradle 2.3, so this can be marked as fixed :slight_smile: