📜 ⬆️ ⬇️

ExtJs as a maven dependency

What for


I have several Java projects using ExtJs applications as a web client. Library frankly not small. The full archive of more than 60M megabytes weighs, and applications in active development have to drag and drop all this from CVS. And if you add the slow Internet to the latter, then everything becomes completely sad. The application also has a dozen classes there, and the weight is already over fifty megabytes.

what


There was an idea to arrange this library in the form of a plug-in. After a certain share of RTFM, it was decided to do it through maven.
He has such a thing as war-layout. Allows you to "glue" several applications into one, and you can clearly specify what to include and what not.

how


  1. Creating an overlay project

    It's simple.
    1. Create an empty web application.
    2. To folder
      src/main/webapp/lib/extJs/ 
      (Ways regarding the root of the project. May depend on your configuration and your desire to be CVN)
      we unpack archive with ExtJs, downloaded from a site of sencha.
      Attention! At the time of writing the post, the archive contained the ext-NUMBER_VERSIONS_ExtJs folder . We do not need this folder. It is necessary to unpack its contents. This will allow us to have the same path for any version of extJs. We will manage the version elsewhere.
    3. In pom.xml in the project settings do not forget to register
       <version>__ExtJs-RELEASE</version> 
      and
       <packaging>war</packaging> 

      Now it’s enough for us to perform
       mvn clean install 
      to download to the local maven repository, or, like ours, configure Jenkins to monitor the CSV repository and automatically download new versions to nexus.

  2. Connect to another project

    In pom.xml, you must specify the dependence on the above created project.
      <!--Overlays--> <dependency> <groupId>org.me</groupId> <artifactId>extjs-overlay</artifactId> <type>war</type> <version>4.2-RELEASE</version> <scope>runtime</scope> </dependency> 

    and customize the plugin
     <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.3</version> <configuration> <overlays> <overlay> <groupId>org.me</groupId> <artifactId>extjs-overlay</artifactId> </overlay> </overlays> </configuration> </plugin> 

    You can also specify which files to include in the assembly.
     <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.3</version> <configuration> <overlays> <overlay> <groupId>org.me</groupId> <artifactId>extjs-overlay</artifactId> <excludes> <exclude>lib/extjs/*</exclude> </excludes> </overlay> </overlays> </configuration> </plugin> 


Total


We were able to update the ExtJs version by simply changing the dependency version in pom.xml. On the other side of the scale, the maveno overlays are not too fast, but this is solved by discarding all unnecessary. Moreover, if we decide to overload some basic functions of ExtJs, we will not need to copy the code into all projects.

Maven war plugin documentation

')

Source: https://habr.com/ru/post/188110/


All Articles