In a recent project, build your project using Gradle, the next-generation build tool.
A problem was found in use, Gradle. jar files downloaded from the Central Library in other directories in the system, and when you add eclipse support using Gradle Eclipse, the jar files are imported as external dependencies. When Eclipse publishes Web projects to Tomcat, these dependencies are not automatically published.
With eclipse, you can right-click-Propertics-deployment Assembly on the project, add "Java Build Path Entries", add all the dependent jar packages, and publish the externally dependent jar packages automatically when you publish.
However, manually added, is not in line with the requirements of automated construction, open the. classpath file, found that Gradle automatically generated files contain code similar to the following
<ClasspathentrySourcePath= "C:/Documents and settings/xxx/.gradle/caches/artifacts-24/filestore/commons-collections/ Commons-collections/3.2/source/73d0340eaecbb0ec9d3e0ace90547ef08cbfaf27/commons-collections-3.2-sources.jar " Kind= "Lib"Path= "C:/Documents and settings/xxx/.gradle/caches/artifacts-24/filestore/commons-collections/ Commons-collections/3.2/jar/f951934aa5ae5a88d7e6dfaa6d32307d834a88be/commons-collections-3.2.jar "exported= "true" />
After you set up deployment assembly in Eclipse, the code changes to this
<ClasspathentrySourcePath= "C:/Documents and settings/xxx/.gradle/caches/artifacts-24/filestore/commons-collections/ Commons-collections/3.2/source/73d0340eaecbb0ec9d3e0ace90547ef08cbfaf27/commons-collections-3.2-sources.jar " Kind= "Lib"Path= "C:/Documents and settings/xxx/.gradle/caches/artifacts-24/filestore/commons-collections/ Commons-collections/3.2/jar/f951934aa5ae5a88d7e6dfaa6d32307d834a88be/commons-collections-3.2.jar "exported= "true"> <attributes> <attributename= "Org.eclipse.jst.component.dependency"value= "/web-inf/lib" /> </attributes> </Classpathentry>
This is simple, we let gradle automatically add deployment Assembly
Add the following code in the Gradle.build
Automatic generation of deployment Assembly ECLIPSE.CLASSPATH.FILE.WITHXML {def node = It.asnode () when generating eclipse support; For (Node N:node.children ()) {if ("Lib". Equals (N.attribute ("kind"))) {def node_attributes =new Nod E (n, "attributes"); def map =new HashMap (); Map.put ("name", "Org.eclipse.jst.component.dependency"); Map.put ("Value", "/web-inf/lib"); def node_attribute =new node (node_attributes, "attribute", map); } } } |
Save later rerun Gradle Eclipse, go back to Eclipse Refresh project, publish project now, can automatically publish all external dependent jar package to Tomcat
Resolves an issue where Tomcat lost dependent jar packages was released after Gradle generated eclipse support