Maven: How to activate profile based on whether child module contains a file?

I’m using Maven 3.1.1 on Mac 10.9.1. I want to activate a profile based on whether certain child modules contain a file. I have tried the following

    <profile>
        <id>deploy-war-to-jboss</id>
        <activation>
            <file>
                <exists>${session.executionRootDirectory}/src/main/webapp/WEB-INF/web.xml</exists>
            </file>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.jboss.as.plugins</groupId>
                    <artifactId>jboss-as-maven-plugin</artifactId>
                    <version>${jboss.maven.plugin.version}</version>
                    <configuration>
                        <hostname>${jboss.remote.hostname}</hostname>
                        <port>${jboss.remote.port}</port>
                    </configuration>
                    <executions>
                        <execution>
                            <id>deploy-to-jboss</id>
                            <phase>install</phase>
                            <goals>
                                <goal>deploy</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>

but this profile doesn’t get activated when running “mvm clean install” despite the fact I’ve verified that the child modules in question contain the file. I also tried ${project.basedir} without luck. Any ideas how I make this happen?

Answers


Since you define the profile in the parent POM (I guess) you should try this

${basedir}/name-of-your-child-module//src/main/webapp/WEB-INF/web.xml

Furthermore, you should try running Maven in debug mode to get more information at runtime:

mvm -X clean install

Need Your Help

How to enter information in one cell based on text in another cell

excel excel-formula conditional-statements

I would like to enter information in a cell based on the text contained in a different cell. Specifically, if a cell in column A contains text that includes "insurance," "retirement," or "401K," th...

Huge dictionary Python not working

python dictionary process large-data

I have a really big dictionary in Python . . . it isn't compiling in CodeRunner or in Xcode