Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maven-php-dependency include behavior #19

Open
marcinant opened this issue Feb 8, 2013 · 1 comment
Open

Maven-php-dependency include behavior #19

marcinant opened this issue Feb 8, 2013 · 1 comment

Comments

@marcinant
Copy link

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
Copy link

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' 👍

<?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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants