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

标签 php maven

我在 Debian 8.4 上将 Maven 3.3.9 安装为单独的 .deb 我开发 php 代码并预定义了开发文件树,这不能让我遵循 super 严格的 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] ------------------------------------------------------------------------

最佳答案

执行 ID“copy”的 maven-dependency-plugin unpack 目标绑定(bind)到生命周期的 package 阶段。具有相同执行 ID 的 maven-resources-plugin copy-resources 目标绑定(bind)到 validate 阶段。

验证阶段发生在打包之前,因此复制发生在资源解包之前。因此,无需复制任何内容,也无需打包任何内容。将“复制”执行的阶段更改为“验证”,然后它应该可以工作。两个插件执行都将绑定(bind)到同一阶段,因此 POM 中第一个列出的插件首先运行。如果您想让顺序清晰明了,而不管 POM 中的插件顺序如何,那么还可以将“copy-resources”执行更改为在initialize阶段运行。

我猜测它似乎适用于第一个项目,因为依赖项已经在途中的某个地方解压了。如果您将命令更改为 mvn clean package 我怀疑这两个项目都没有任何可打包的内容。

您可能会找到Maven lifecycle reference有帮助。

关于php - JAR 将为空 - 没有内容被标记为包含,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37121354/

相关文章:

php - 在 Paypal 结账时显示所有购物车商品

maven - 如何使用 Maven 将 .war 文件部署到 JBoss AS 7 服务器?

Java-DOM-Parser : Exception on Transformer. 转换

PHP 警告 : Unable to load dynamic library

php - 如何删除输入表单中的引号前

java - 将 Maven 依赖项导入到 Java 项目中

java - Spring Boot 可执行 jar 抛出 java.lang.ClassNotFoundException : org. apache.tomcat.util.descriptor.web.ServletDef

maven - 测试和生产环境中的 Spring Security

php - 使用 Ruby on Rails 保护数据?

php - 在Woocommerce 3中的销售徽章上显示折扣百分比