I’m having an issue with one of my gradle projects in eclipse. When I attempt to build or refresh dependencies within eclipse, I’m receiving the error below. I’m running Eclipse under Java 8 but the project is Java 6. Gradle builds the project fine from the command line (Gradle 2.8, Java 6, 7, 8)
[Fatal Error] :2:140: External DTD: Failed to read external DTD ‘application_1_2.dtd’, because ‘http’ access is not allowed due to restriction set by the accessExternalDTD property.
FAILURE: Build failed with an exception.
Where:
Build file ‘/…/build.gradle’ line: 10
What went wrong:
A problem occurred evaluating root project ‘myrpoject’.
Failed to apply plugin [id ‘ear’]
External DTD: Failed to read external DTD ‘application_1_2.dtd’, because ‘http’ access is not allowed due to restriction set by the accessExternalDTD property.
The STS plugin it maintained by Pivotal. If you encounter an issue, you’d need to report to their forum. Keep in mind that Pivotal will stop supporting their plugin in the next couple of months.
Side note: Neither Buildship nor the STS Gradle plugin currently provide automatic refresh of dependencies if you change the build file.
The STS Gradle plugin has a menu option to ‘Refresh Dependencies’ and also a preference to ‘Enable automatic refresh’. Does the Buildship plugin offer this functionality?
What is the suggested way of refreshing dependencies in eclipse with Buildship? I was stuck using the command line to rebuild the eclipse artifacts using the following process every time I add a new dependency.
Once you imported the project into Buildship, there’s no more need to run gradle eclipse anymore. Generally speaking you don’t actually need to use the Gradle Eclipse plugin at all if your project doesn’t require any customizations.
The workflow would look as such:
Import project into Buildship
Add a new dependency to the build.gradle file within Buildship
Trigger the “Refresh dependency” option in Buildship
Jared, after importing a Gradle project into Eclipse, you can refresh the Eclipse project when dependencies, source sets, etc. change via context menu on the project (or by pressing F5 while the project is select in the project explorer).
Automatic refresh is currently not supported, but it is on our list of things to do. It will require some changes in the Gradle Tooling API first.
The problem is caused by the XML parser the Gradle wrapper uses to read the .XML files in the project to import. Once the Gradle wrapper runs in Eclipse’s JVM, the system properties to control the XML parser have to be defied in the eclipse.ini file.
In eclipse.ini file add the lines:
-Djavax.xml.accessExternalSchema=all
-Djavax.xml.accessExternalDTD=all
They allow the XML parser download the DTD/XSD defined in the XML to parse.