php-maven / maven-php-plugin

A maven plugin for dependency management and quality assurance for PHP projects.
http://www.php-maven.org/
Apache License 2.0
37 stars 29 forks source link

Maven-php-dependency include behavior #19

Open marcinant opened 11 years ago

marcinant commented 11 years ago

I would like to create project with following structure:

/lib/somelibrary-1.phar /lib/somelibrary-2.phar ... index.php somepage.php

I created 3 projects.

  1. somelibrary-1 using php-library archetype
  2. somelibrary-2 -"-
  3. website using php-webapp archetype.

In website/pom.xml I added somelibrary-1 and somelibrary-2 as dependencies.

As result they are unpacked to target/php-deps

This is not what I want. So, following this tutorial:

http://www.php-maven.org/tags/2.0.2/tut-dependencymanagement.html Which states: "The include action tells maven to not extract the phar file but instead put it on php include path." I added to website/pom.xml

    <groupId>org.phpmaven</groupId>
    <artifactId>maven-php-dependency</artifactId>
    <configuration>
        <dependencies>
            <dependency>
                <groupId>org.test</groupId>
                <artifactId>somelibrary-1</artifactId>
                <actions>
                    <include/>
                </actions>
            </dependency>
        </dependencies>
    </configuration>
</plugin>

Unfortunately it doesn't work as I expected. As result dependency is not visible in target/php-deps and is not available anwyhere in target dir! Info says that "will be added on include path". But what does it mean? Is there any way to bundle unextracted phar with webapplication?

marcoooo commented 11 years ago

Hi, you should use for your purpose the maven-assembly plugin to build a tar.gz (for exemple) from tous source, and inject dependencies in your tar.gz (do not put extract action for your .phar deps, it will fail otherwise).

For our project, here is our 'webappassembly descriptor' :+1:

<?xml version="1.0" encoding="UTF-8"?>
<assembly
    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
    <id>webapp-bo</id>
    <formats>
        <format>tar.gz</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <includeSiteDirectory>false</includeSiteDirectory>
    <fileSets>
        <fileSet>
            <directory>src/main/resources</directory>
            <outputDirectory>${webapp.root}</outputDirectory>
            <filtered>true</filtered>
        </fileSet>
        <fileSet>
            <directory>src/main/php</directory>
            <outputDirectory>${webapp.root}</outputDirectory>
            <filtered>false</filtered>
        </fileSet>
    </fileSets>
    <dependencySets>
        <dependencySet>
            <useTransitiveDependencies>true</useTransitiveDependencies>
            <useProjectArtifact>true</useProjectArtifact>
            <outputDirectory>${webapp.root}</outputDirectory>
            <outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
            <includes>
                <include>com.nim.webapp:*:*:*</include>
            </includes>         
        </dependencySet>
        <dependencySet>
            <useTransitiveDependencies>true</useTransitiveDependencies>
            <useProjectArtifact>false</useProjectArtifact>
            <outputDirectory>${webapp.root}/libs/</outputDirectory>
            <outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
            <includes>
                <include>com.nim:*:*:*</include>
                <include>com.nim.plugins:*:*:*</include>                
            </includes>         
        </dependencySet>
        <dependencySet>
            <useTransitiveDependencies>true</useTransitiveDependencies>
            <useProjectArtifact>false</useProjectArtifact>
            <outputDirectory>${webapp.root}/php-libs/</outputDirectory>
            <outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
            <excludes>
                <exclude>com.nim:*:*:*</exclude>
                <exclude>com.nim.plugins:*:*:*</exclude>
            </excludes>
        </dependencySet>        
    </dependencySets>
</assembly>