首页 > 其他分享 >本地扫描maven项目依赖jar的license信息

本地扫描maven项目依赖jar的license信息

时间:2024-03-18 10:33:26浏览次数:22  
标签:project license third jar maven Dlicense party

添加plugin

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <version>2.4.0</version>
        <configuration>
            <!--指定输出内容的模版,方便采集梳理-->
            <fileTemplate>/Users/aaa/your_dir/third-party-file.ftl</fileTemplate>
        </configuration>
        <executions>
            <execution>
                <goals>
                    <goal>add-third-party</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

ftl模版

这里主要是通过 | 符号来分隔 各个字段方便excel导入

<#--
  #%L
  License Maven Plugin
  %%
  Copyright (C) 2012 Codehaus, Tony Chemit
  %%
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Lesser General Public License as
  published by the Free Software Foundation, either version 3 of the
  License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Lesser Public License for more details.

  You should have received a copy of the GNU General Lesser Public
  License along with this program.  If not, see
  <http://www.gnu.org/licenses/lgpl-3.0.html>.
  #L%
  -->
<#-- To render the third-party file.
 Available context :

 - dependencyMap a collection of Map.Entry with
   key are dependencies (as a MavenProject) (from the maven project)
   values are licenses of each dependency (array of string)

 - licenseMap a collection of Map.Entry with
   key are licenses of each dependency (array of string)
   values are all dependencies using this license
-->
<#function licenseFormat licenses>
    <#assign result = ""/>
    <#list licenses as license>
        <#assign result = result + license + " "/>
    </#list>
    <#return result>
</#function>
<#function artifactFormat p>
    <#if p.name?index_of('Unnamed') &gt; -1>
        <#return "|" + p.artifactId + "|" + p.groupId + "|" + p.artifactId + "|\"" + p.version + "\"|" + (p.url!"no url defined")>
    <#else>
        <#return "|" + p.name + "|" + p.groupId + "|" + p.artifactId + "|\"" + p.version + "\"|" + (p.url!"no url defined")>
    </#if>
</#function>
<#if dependencyMap?size == 0>
<#else>
    license| name|groupId| artifactId|version|url
    <#list dependencyMap as e>
        <#assign project = e.getKey()/>
        <#assign licenses = e.getValue()/>
    ${licenseFormat(licenses)} ${artifactFormat(project)}
    </#list>
</#if>

在项目根目录执行命令

通过outputDirectory参数,把所有输出文件汇集到一起,通过thirdPartyFilename参数,区分不同module的文件命名

mvn license:add-third-party -Dlicense.outputDirectory=/your_directory -Dlicense.thirdPartyFilename=project-name-'${project.artifactId}'.txt

标签:project,license,third,jar,maven,Dlicense,party
From: https://www.cnblogs.com/IC1101/p/18079818

相关文章

  • java项目打包(maven+原生)
    一、maven打包1.1普通jarjava-jarmaven项目打包提示.jar中没有主清单属性<build><finalName>${project.artifactId}</finalName><!--修改编译出来的jar包名,仅为{artifactId}.jar--><plugins><plugin><gr......
  • [转]【Qt-license】误操作qt下载导致只能安装商业版试用十天,无法安装社区版
    背景:原本是为了学习qml,需要下载一个designstudio,而这个需要比较新版的安装程序,但新版的安装程序官方都是online安装。于是从官网找下载链接。毕竟是英文的,又心急,误打误撞中我选择了商业版试用。  其实online安装程序是一样的(qt-unified-windows-x64-4.6.1-online.exe),一旦选......
  • Web后端开发-Maven篇
       1)配置本地仓库:打开maven文件中的conf文件夹,点击setting.xml 用文本编辑器打开,为了方便管理,直接在maven文件夹中新建一个mav_repo文件,作为本地仓库。将该目录复制到图中对应的内容中。 2)配置阿里云私服:加快下载速度 在setting.xml文件中找到mirror,将以下内容......
  • 项目管理工具Maven(一)
    1.Maven的相关概念1.1为什么要用maven?在今天的Javaweb 开发领域,有大量的第三方框架和工具可以供我们使用。要使用这些jar包最简单的方法就是复制粘贴到WEB-INF/lib目录下。但是这会导致每次创建一个新的工程就需要将jar包重复复制到lib目录下,从而造成工作区中存......
  • 项目管理工具maven(五)-私服
    4.maven私服架构 4.1maven私服介绍    4.1.1私服介绍正式开发,不同的项目组开发不同的工程。maven-dao工程开发完毕,发布到私服maven-service从私服下载dao。公司在自己的局域网内搭建自己的远程仓库服务器,称为私服,私服服务器即是公司内部的maven远程仓库,......
  • Maven学习总结
    学习课程视频链接:尚硅谷新版Maven教程(高效入门maven,上手又快又稳)_哔哩哔哩_bilibili 尚硅谷新版SSM框架全套视频教程,Spring6+SpringBoot3最新SSM企业级开发_哔哩哔哩_bilibili 以下是一些零碎的知识点总结:maven的gvap属性:groupid:com.{公司/BU}.业务线.{子业务线},最多4级......
  • 修改Maven配置项
    0.打开Maven安装目录>conf>settings.xml1.修改本地仓库地址(默认是Default:${user.home}/.m2/repository也就是用户目录下的/.m2/repository下)修改为自己的本地仓库地址<localRepository>xxx</localRepository>2.了解servers当你将仓库发布到远程仓库时,在这里设置s......
  • 命令行生成jar文件
    做IT也二十年有余了,一直做着运维工作,编程仅是业余兴趣,水平就是在HelloWorld的基础上多做几个练习,行在各语言都能试试手,偶尔也能做些提高效率小工具,多是味都没怎么嚼就新版本了,人也白发生了...运维吗,效率在先,什么容易就用什么,c#,php,autoit,shell,bat,vba,sql,powershell,python,唯java总......
  • [maven] maven settings.xml/pom.xml之repositories/pluginRepositories元素
    0序repositories针对项目本身的【JAR依赖】,通过repositories进行自定义配置。pluginRepositories针对的是maven命令需要的【插件依赖】地址(比如clean、install都是maven的插件),通过pluginRepositories进行自定义配置。如果只配置了repositories,则:打包时,默认的【插件依赖】......
  • maven依赖项爆红解决方法(详细)
    因为解决爆红要反复下载依赖项进行多次尝试,所以maven下载速度慢的小伙伴可以参考这篇文章解决maven依赖下载很慢的问题https://blog.csdn.net/m0_73642416/article/details/136751868 1.尝试删除旧的依赖的缓存有时候依赖问题可能是由于本地仓库缓存中的文件损坏或不一致......