JAR将为空 - 没有内容标记为包含

时间:2016-05-09 16:54:07

标签: php maven

我在Debian 8.4上将Maven 3.3.9作为单独的.deb安装 我开发PHP代码并具有预定义的开发文件树,这不能让我遵循超严格的Maven约定。 我有两个具有相同结构的项目目录:

.  
├── admin5.php  
.  
├── app  
│   ├── addons  
.   .  
│   └── Tygh  
├── bower_components  
│   └── jquery-sticky  
├── bower.json  
.   .  
├── js  
│   ├── addons  
│   ├── lib  
│   └── tygh  
├── pom.xml  
├── target  
│   ├── classes  
│   ├── dependency-maven-plugin-markers  
│   ├── ip5_bestore-1.0.jar  
│   ├── maven-archiver  
│   └── original-ip5_bestore-1.0.jar  
└── var  

我在两者中都有相同的pom.xml:

<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>ru.ip-5</groupId>  
  <artifactId>ip5_coolposter</artifactId>  
  <version>1.0</version>  
  <properties>  
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
  </properties>  
  <build>  
    <plugins>  
      <plugin>  
        <artifactId>maven-resources-plugin</artifactId>  
        <version>2.7</version>  
        <executions>  
          <execution>  
            <id>copy-resources</id>  
            <phase>validate</phase>  
            <goals>  
              <goal>copy-resources</goal>  
            </goals>  
          </execution>  
        </executions>  
        <configuration>  
          <outputDirectory>  {basedir}/src/main/js/addons/ip5_bestore/dependencies/</outputDirectory>  
          <resources>  
            <resource>  
              <directory>  {basedir}/bower_components/fabric.js/dist/</directory>  
              <includes>  
                <include>fabric.min.js</include>  
              </includes>  
            </resource>  
          </resources>  
        </configuration>  
      </plugin>  
      <plugin>  
        <groupId>org.apache.maven.plugins</groupId>  
        <artifactId>maven-shade-plugin</artifactId>  
        <version>2.4.1</version>  
        <executions>  
          <execution>  
            <phase>package</phase>  
            <goals>  
              <goal>shade</goal>  
            </goals>  
            <configuration>  
              <filters>  
                <filter>  
                  <artifact>*:*</artifact>  
                  <excludes>  
                    <exclude>META-INF/</exclude>  
                  </excludes>  
                </filter>  
              </filters>  
            </configuration>  
          </execution>  
        </executions>  
      </plugin>  
    </plugins>  
    <resources>  
      <resource>  
        <directory>  {basedir}</directory>  
        <includes>  
          <include>app/addons/ip5_*/</include>  
          <include>design/backend/css/addons/ip5_*/</include>  
          <include>design/backend/media/images/ip5_*/</include>  
          <include>design/backend/templates/addons/ip5_*/</include>  
          <include>design/themes/responsive/css/addons/ip5_*/</include>  
          <include>design/themes/responsive/media/images/addons/ip5_*/</include>  
          <include>design/themes/responsive/media/fonts/ip5_fonts/</include>  
          <include>design/themes/responsive/styles/data/IP5_*</include>  
          <include>design/themes/responsive/templates/addons/ip5_*/</include>  
          <include>js/addons/ip5_*/</include>  
          <include>var/langs/*/addons/ip5_*.po</include>  
          <include>cmsmagazined1992e543a5d7b4d64afe783fffdbc8d.txt</include>  
        </includes>  
      </resource>  
    </resources>  
  </build>  
</project>  

当我在其中一个人做“mvn package”时,每件事都成功了,但另一件事我得到了:

[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ ip5_bestore ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO]
[INFO] --- maven-shade-plugin:2.4.1:shade (default) @ ip5_bestore ---
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing /var/www/bestore/target/ip5_bestore-1.0.jar with /var/www/bestore/target/ip5_bestore-1.0-shaded.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

2 个答案:

答案 0 :(得分:2)

具有执行ID的#maven-dependency-plugin unpack目标&#34; copy&#34;与生命周期的package阶段绑定。具有相同执行ID的maven-resources-plugin copy-resources目标绑定到validate阶段。

validate阶段发生在package之前,因此副本在资源解包之前发生。因此没有什么可以复制,也没有什么可以打包的。更改&#34;复制&#34;的阶段执行到validate,然后它应该工作。两个插件执行都将绑定到同一个阶段,因此首先在POM中列出的那个执行。无论POM中的插件顺序如何,如果您想使订单清晰,那么也要更改&#34; copy-resources&#34;执行以使用阶段initialize运行。

我猜测它似乎在工作&#34;与第一个项目,因为依赖已经在解决方案的某个地方解压缩。如果您将命令更改为mvn clean package,我怀疑这两个项目都无法打包。

您可能会发现Maven lifecycle reference有帮助。

答案 1 :(得分:0)

好的,它是: copy-resources插件的配置部分必须在执行部分:

<plugin>  
  <artifactId>maven-resources-plugin</artifactId>  
  <version>2.7</version>  
  <executions>  
    <execution>  
      <id>copy-resources</id>  
      <phase>validate</phase>  
      <goals>  
        <goal>copy-resources</goal>  
      </goals>  
        <configuration>  
          <outputDirectory>${basedir}/js/addons/ip5_bestore/dependencies/</outputDirectory>  
          <resources>  
            <resource>  
              <directory>bower_components/jquery-sticky/</directory>  
              <includes>  
                <include>jquery.sticky.js</include>  
              </includes>  
            </resource>  
          </resources>  
        </configuration>  
      </execution>  
    </executions>                         
</plugin>