dpb_4431 2010-05-04 09:50
浏览 106
已采纳

是否可以使用Maven for PHP构建多模块结构?

I have to build an application using Maven for PHP that has multiple modules. The scenario in which the maven seems to not work is this: I have a common module and a client module depending on the first one. When doing "mvn test" on the client module which depends on the common module, the test fails to see the paths to the common module. Is there a flow in my build or this is just not possible?

I attached my pom.xml files.

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.sample</groupId>
    <artifactId>my-app_package</artifactId>
    <packaging>pom</packaging>
    <name>Sample PHP Maven multi module project</name>
    <version>1.0-SNAPSHOT</version>
    <modules>
        <module>common-module</module>
        <module>client1-module</module>
    </modules>
    <build>
        <plugins>
            <plugin>
                <groupId>org.phpmaven</groupId>
                <artifactId>maven-php-plugin</artifactId>
                <extensions>true</extensions>
                <version>1.0</version>              
                <configuration>
                    <ignoreValidate>true</ignoreValidate>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.phpunit</groupId>
            <artifactId>phpunit5</artifactId>
            <version>3.3.9</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
<reporting>
    <plugins>
        <plugin>
            <groupId>org.phpmaven</groupId>
            <artifactId>maven-php-plugin</artifactId>
            <version>1.0</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <version>2.4</version>
            <reportSets>
                <reportSet>
                    <reports>
                        <report>report-only</report>
                    </reports>
                </reportSet>
            </reportSets>
        </plugin>
    </plugins>
</reporting>
</project>

common-module/pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.sample</groupId>
    <artifactId>my-app</artifactId>
    <packaging>php</packaging>
    <name>Client1 module</name>
    <version>1.0-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <groupId>org.phpmaven</groupId>
                <artifactId>maven-php-plugin</artifactId>
                <extensions>true</extensions>
                <version>1.0</version>              
                <configuration>
                    <ignoreValidate>true</ignoreValidate>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.sample</groupId>
            <artifactId>common-module</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.phpunit</groupId>
            <artifactId>phpunit5</artifactId>
            <version>3.3.9</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

common-module/pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.sample</groupId>
    <artifactId>common-module</artifactId>
    <packaging>php</packaging>
    <name>Common module</name>
    <version>1.0-SNAPSHOT</version>

    <build>
        <plugins>
            <plugin>
                <groupId>org.phpmaven</groupId>
                <artifactId>maven-php-plugin</artifactId>
                <extensions>true</extensions>
                <version>1.0</version>              
                <configuration>
                    <ignoreValidate>true</ignoreValidate>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.phpunit</groupId>
            <artifactId>phpunit5</artifactId>
            <version>3.3.9</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
  • 写回答

2条回答 默认 最新

  • dqkyz02602 2010-05-19 09:58
    关注

    It works, you just need to install your dependency module BEFORE trying to build a module that depends on that module. Or else it won't find it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?