微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Maven:mave-assemby-plugin 的问题:它正在尝试处理项目中不存在的虚拟第二个 assembly.xml

如何解决Maven:mave-assemby-plugin 的问题:它正在尝试处理项目中不存在的虚拟第二个 assembly.xml

当执行 mvn asembly:single 时它工作正常(生成所需的文件)但最后失败......如果我用 -X 执行,这是输出

    ...
    [INFO] Reading assembly descriptor: ../assembly.xml
    [DEBUG] Field directory source: ${project.build.directory} interpolated to: target
    [DEBUG] After assembly is interpolated:
    
            <?xml version="1.0"?>
            <assembly xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd" xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
              <id>bin</id>
              <formats>
                <format>tar.gz</format>
              </formats>
              <fileSets>
                <fileSet>
                  <outputDirectory></outputDirectory>
                  <includes>
                    <include>*</include>
                  </includes>
                  <excludes>
                    <exclude>objs</exclude>
                    <exclude>archive-tmp</exclude>
                    <exclude>**/*.o</exclude>
                    <exclude>**/*.gz</exclude>
                  </excludes>
                  <directory>target</directory>
                </fileSet>
              </fileSets>
            </assembly>
        
        **( SINCE HERE ALL IS OK!)**
        
        [DEBUG] Field directory source: ${project.basedir} interpolated to: .
        [DEBUG] Field directory source: ${project.build.directory} interpolated to: target
        [DEBUG] Field directory source: ${project.build.directory}/site interpolated to: target/site
        [DEBUG] After assembly is interpolated:
        
        <?xml version="1.0" encoding="UTF-8"?>
        <assembly xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd" xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
          <id>bin</id>
          <formats>
            <format>tar.gz</format>
            <format>tar.bz2</format>
            <format>zip</format>
          </formats>
          <fileSets>
            <fileSet>
              <outputDirectory></outputDirectory>
              <includes>
                <include>README*</include>
                <include>LICENSE*</include>
                <include>NOTICE*</include>
              </includes>
              <directory>.</directory>
            </fileSet>
            <fileSet>
              <outputDirectory></outputDirectory>
              <includes>
                <include>*.jar</include>
              </includes>
              <directory>target</directory>
            </fileSet>
            <fileSet>
              <outputDirectory>docs</outputDirectory>
              <directory>target/site</directory>
            </fileSet>
          </fileSets>
        </assembly>
    
    (**Where the hell does he get this second XML from???)**
    
    [WARNING] The assembly id bin is used more than once.
    [DEBUG] All kNown ContainerDescriptorHandler components: [plexus,MetaInf-spring,file-aggregator,MetaInf-services]
    [DEBUG] FileSet[] dir perms: -1 file perms: -1
    [DEBUG] The archive base directory is 'null'
    [DEBUG] NOT reformatting any files in F:\Desarrollo\MAVENIZADO\Log\target
    [DEBUG] Adding file-set in: ... to archive location: .../
    [DEBUG] Adding exclude for assembly working-directory: assembly/work
    File-Set source directory: .../target
    [INFO] Building **tar: xxxxxxxx\target\xxxx-1.0-bin.tar.gz** **<-- THIS IS THE WANTED FILE AND IT'S OK!!!**
    
    **Now IT'S PROCESSING THE FILESETS OF THE OTHER XML invented by himself!!!! :**
    
    [DEBUG] All kNown ContainerDescriptorHandler components: [plexus,MetaInf-services]
    [DEBUG] FileSet[] dir perms: -1 file perms: -1
    [DEBUG] The archive base directory is 'null'
    [DEBUG] NOT reformatting any files in ...
    [DEBUG] Adding file-set in: ...0/
    [DEBUG] FileSet[] dir perms: -1 file perms: -1
    [DEBUG] The archive base directory is 'null'
    [DEBUG] NOT reformatting any files in ...target
    [DEBUG] Adding file-set in: F:\Desarrollo\MAVENIZADO\Log\target to archive location: ...
    [DEBUG] Adding exclude for assembly working-directory: assembly/work
    File-Set source directory: ....target
    [DEBUG] FileSet[docs/] dir perms: -1 file perms: -1
    [DEBUG] The archive base directory is 'null'
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  2.046 s
    [INFO] Finished at: 2021-07-26T11:36:22+02:00
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:3.3.0:single (default-cli) on project Log: Failed to create assembly: Error creating assembly archive bin: archive cannot be empty -> [Help 1]
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:3.3.0:single (default-cli) on project Log: Failed to create assembly: Error creating assembly archive bin: archive cannot be empty

它没有做一些不符合要求的事情...... 我想要的文件已正确生成

解决方法

该插件使用名为“bin”的默认程序集定义(如果没有人想要这个发明的防御,他们为什么要这样做???)。解决方案:不要在 assenbly 中使用“bin”id,也不要在 pom.xml 中引用名为“bin”(<descriptorRef>bin</descriptorRef>) 的程序集。 “bin”仅供创作者使用!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。