简体   繁体   English

Maven 许可证插件:未知许可证

[英]Maven License Plugin : Unknown license

We are trying to create a third-party file that lists the licenses from the libraries we are using.我们正在尝试创建一个第三方文件,其中列出了我们正在使用的库中的许可证。 For this, we are using the license maven plugin and it's add third party target.为此,我们使用许可 maven 插件添加第三方目标。

It is working fine, for most of our libraries.对于我们的大多数图书馆来说,它运行良好。 Thing is, some of our dependencies are VERY old, and do not exist on Maven Central.事实是,我们的一些依赖项非常旧,并且在 Maven Central 中不存在。 for some others, we have made modifications.对于其他一些,我们进行了修改。 In both cases, we store those ourselves in the Third Party repo from our Nexus.在这两种情况下,我们都将它们自己存储在我们 Nexus 的第三方存储库中。

These libraries do contain license information, for example as follows :这些库确实包含许可证信息,例如如下:

<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>com.company.lib</groupId>
  <artifactId>lib-jcuda</artifactId>
  <version>0.4.2</version>
  <description>POM was created by Sonatype Nexus</description>
  <licenses>
    <license>
      <name>MIT License</name>
      <url>http://www.opensource.org/licenses/mit-license.php</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
</project>

Thing is, when we run the target they are not recognized, and we get the following message :问题是,当我们运行目标时,它们无法识别,我们收到以下消息:

[WARNING] There are 16 dependencies with no license :
[WARNING]  - com.spacemetric.lib--lib-jcublas--0.4.2
[WARNING]  - com.spacemetric.lib--lib-jcuda--0.4.2
(Unknown license) lib-jcuda (com.spacemetric.lib:lib-jcuda:0.4.2 - no url defined)

When switching the -X flag on, we get some additional information :当打开-X标志时,我们会得到一些额外的信息:

[DEBUG] Verifying availability of C:\Users\me\.m2\repository\com\company\lib\lib-jcuda\0.4.2\lib-jcuda-0.4.2.pom from [central (https://repo.maven.apache.org/maven2, default, releases)]

If I run some java code that I built to test, I can see the license information with no issue :如果我运行一些我为测试而构建的 Java 代码,我可以毫无问题地看到许可证信息:

    MavenXpp3Reader mavenreader = new MavenXpp3Reader();
    String pomfile = "C:\\Users\\me\\.m2\\repository\\com\\company\\lib\\lib-jcuda\\0.4.2\\lib-jcuda-0.4.2.pom";
    try (FileReader reader = new FileReader(pomfile);) {
        Model model = mavenreader.read(reader);
        model.setPomFile(new File(pomfile));
        MavenProject project = new MavenProject(model);

        List<License> licenses = project.getLicenses();
        for (License l : licenses) {
            System.out.println(l.getUrl());
        }
    }
    catch (IOException | XmlPullParserException e) {
        e.printStackTrace();
    }

Is there anything obvious we are missing when grabbing our dependencies?在获取依赖项时,我们是否遗漏了任何明显的东西? The issue only seems to arise for the libraries that we had to add ourselves to Nexus so we are probably doing something wrong.这个问题似乎只出现在我们必须将自己添加到 Nexus 的库中,所以我们可能做错了什么。

I have looked at the doc quite a lot, as well as the source of the plugin, but could not find why the license is not taken into account for those libraries.我已经查看了很多文档以及插件的来源,但找不到为什么这些库没有考虑许可证。

In light of your comment: Have you set up your settings.xml to point to the nexus (mirror) of maven central for the in-house maintained dependencies?根据您的评论:您是否已将 settings.xml 设置为指向内部维护依赖项的 maven 中心的关系(镜像)?

You can configure this something like this:你可以这样配置:

<settings>
...
  <mirrors>
    <mirror>
      <id>UK</id>
      <name>UK Central</name>
      <url>http://uk.maven.org/maven2</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>
  ...
</settings>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM