首页 > 其他分享 >maven-dependency-plugin unpack 使用

maven-dependency-plugin unpack 使用

时间:2022-12-05 23:45:35浏览次数:61  
标签:plugin maven dependency apache org unpack

maven-dependency-plugin 是一个比较有用,但是大家日常使用不是很多的插件,

包含的功能

  • 解析依赖(显示依赖树,解析依赖的插件)
  • copy 依赖
  • 解压copy 依赖(unpack 比如需要部分jar 包中的内容,calcite 扩展开发经常使用到)

unpack 简单使用

比如我们需要依赖的jar的部分功能,但是不想依赖的太多,就可以基于此插件提供的能力解决

  • 参考pom.xml

我们提取webjars 中的内容,到自己的项目中,同时进行文件路径的改写(默认会与原始jar 的路径一致)
原始jar 目录

 

 

 
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
 
    <groupId>org.example</groupId>
    <artifactId>maven-deps-apps</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.webjars.npm</groupId>
            <artifactId>jquery</artifactId>
            <version>3.6.1</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.4.0</version>
                <executions>
                    <execution>
                        <id>unpack-parser-class</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.webjars.npm</groupId>
                                    <artifactId>jquery</artifactId>
                                    <type>jar</type>
                                    <overWrite>true</overWrite>
                                   // fileMappers 支持不少,比如,扁平以及正则处理,此处使用了FlattenFileMapper,注意此功能是3.1.2 开始的
                                    <fileMappers>
                                        <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FlattenFileMapper"/>
                                    </fileMappers>
                                    <outputDirectory>${project.build.directory}/classes/META-INF/resources/jquery/</outputDirectory>
                                    <includes>META-INF/resources/webjars/jquery/3.6.1/dist/**</includes>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
  • 效果

 

 

dremio 参考使用

dremio 在利用calcite 进行sql 扩展的时候就使用了此功能

  • 参考配置

 

 

参考资料

https://sourcegraph.com/github.com/apache/maven-dependency-plugin@master/-/blob/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java?L81
https://maven.apache.org/plugins/maven-dependency-plugin/index.html
https://github.com/apache/maven-dependency-plugin

标签:plugin,maven,dependency,apache,org,unpack
From: https://www.cnblogs.com/rongfengliang/p/16953924.html

相关文章

  • Angular 复习与进阶系列 – Dependency Injection 依赖注入
    前言本来是想先介绍AngularComponent的,但里头有涉及到一些DependencyInjection(简称DI)的概念.所以还是先介绍DI吧. 介绍我在 ASP.NETCore–Depende......
  • maven命令学习-20221205
    1.查看当前maven使用的settting文件mvnhelp:effective-settings2.使用maven把jarinstall进入仓库mvninstall:install-file-Dfile=D:\project\company-biz-11.5.0......
  • maven中的distributionManagement的作用
    mvninstall 会将项目生成的构件安装到本地Maven仓库,mvndeploy 用来将项目生成的构件分发到远程Maven仓库。本地Maven仓库的构件只能供当前用户使用,在分发到远程Mave......
  • Could not resolve dependency:peer swiper@“^5.2.0“ from [email protected].
    在安装vue-awesome-swiper时报错:Couldnotresolvedependency:peerswiper@"^5.2.0"[email protected]_modules/vue-awesome-swipervue-awesome-swiper......
  • maven打jar包到本地仓库
    maven打jar包到本地仓库:mvninstall:install-file-Dfile=jar包的位置(参数一)-DgroupId=groupId(参数二)-DartifactId=artifactId(参数三)-Dversion=version(参数四)......
  • 下载的jar包如何部署到本地Maven库
    1、将jar包放到本地随意文件夹下面2、win+r->cmd进入dos3、执行一下命令,文件夹什么的自行换mvninstall:install-file"-Dfile=D://jar/scm-scmfnd-scmudt-api-0.1.......
  • Maven项目导入本地Jar包
    一、创建lib包,将所需的本地jar包导入二、在pom文件中引导路径<dependency> <groupId>com.aaa</groupId><!--自定义--> <artifactId>aaa-sdk</artifactId><!-......
  • 本地jar包导入maven私服
    一、引入jar包//引入maven命令示例mvninstall:install-file-Dfile=H:\SF-CSIM\SF-CSIM-EXPRESS-SDK-V2.1.7.jar-DgroupId=com.sf-DartifactId=SF-CSIM-EXPRESS-SD......
  • Maven构建过程
    Maven构建过程转载自:https://www.jianshu.com/p/12673e6b9708一、Maven构建生命周期1.1简介项目构建的生命周期概念在Maven之前就已经存在了。软件开发人员每天都要......
  • maven项目中css无法渲染问题
    一.解决1.在spring-mvc.xml中配置(控制层)<!--视图解析器--><beanclass="org.springframework.web.servlet.view.InternalResourceViewResolver"><propert......