1

I get the following error. Is it because the install_path wasn't set? If so, does it mean that when using a profile, the default plugins aren't being executed (the one that sets the install_path)?

Execution:

mvn clean install site -Pfull

Error:

Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (clean-deploy-folder) on project bo-full: Missing base directory for file set: null (included: [], excluded: [])

Parent:

<project>
    <plugins>
        <plugin>
            <!-- Workaround maven not being able to set a property conditionally based on environment variable -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.8</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <exportAntProperties>true</exportAntProperties>
                        <target>
                            <property environment="env"/>
                            <condition property="install.path" value="${env.SERVER_HOME}" else="C:\MY_SERVER">
                                <isset property="env.SERVER_HOME" />
                            </condition>
                            <echo message="${install.path}"/>
                        </target>
                    </configuration>
                </execution>
            </executions>
        </plugin>
...

Child:

<project>
    <profiles>
        <profile>
            <id>full</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-clean-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>clean-deploy-folder</id>
                                <phase>pre-site</phase>
                                <goals>
                                    <goal>clean</goal>
                                </goals>
                                <configuration>
                                    <excludeDefaultDirectories>true</excludeDefaultDirectories>
                                    <filesets>
                                        <fileset>
                                            <directory>${install.path}</directory>
                                        </fileset>
                                    </filesets>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
...
AlikElzin-kilaka
  • 34,335
  • 35
  • 194
  • 277

1 Answers1

0

1) Default plugins should be executed even when using profile. Please verify this is happening by following build log - every plugin execution is logged by maven, even if the plugin itself doesn't log anything.

2) You should keep cleanup execution in the same Maven project/module as the execution that creates the property. One reason is that your child module can then be built separately (it'll use parent pom.xml from local/remote repository, if available). It's also possible that property isn't properly propagated within reactor build for whatever reason.

3) If the problem is indeed property propagation and antrun plugin is at fault, you can replace your antrun execution with a Maven profile. It should go something like this:

<properties>
  <!-- default value goes here: -->
  <install.path>C:\MY_SERVER</install.path>
</properties>

<profiles>
  <profile>
    <id>env</id>
    <activation>
      <property>
        <!-- activate this profile when property is specified: -->
        <name>env.SERVER_HOME</name>
      </property>
    </activation>
    <properties>
      <!-- override default property value: -->
      <install.path>${env.SERVER_HOME}</install.path>
    </properties>
  </profile>
</profiles>
Anton Koscejev
  • 4,603
  • 1
  • 21
  • 26