简体   繁体   中英

maven ant task variable issue

I have a maven antrun task specified in my pom file, and its job is to copy some files from one place to another on compile phase. However ant does not recognized eclipse.home variable ?.. i tried with other variables and i am just running blank? What variables does maven-antrun-plugin have??

my plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.7</version>
    <executions>
        <execution>
            <phase>compile</phase>
            <configuration>
                <target>
                    <copy
                        todir="${eclipse.home}/workspace/location/src/main/webapp/realtime">
                        <fileset
                            dir="${eclipse.home}/workspace/location/src/main/webapp/realtime" />
                    </copy>
                    <copy
                        todir="${eclipse.home}/workspace/location/src/main/webapp/reports">
                        <fileset
                            dir="${eclipse.home}/workspace/location/src/main/webapp/reports" />
                    </copy>
                </target>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Thanks

Eclipse can recognize this property while editing your file because it is set in the Properties tab when you go to Window -> Preferences -> Ant -> Runtime.

If you are running the Maven build from the command line or in Eclipse but using an alternate JRE in the JRE tab of the Run Configuration, Ant will not recognize the property. If you try to run the Maven build using the workspace JRE, however, it may recognize it because the property is defined in the Eclipse workspace configuration.

The best solution is to always define your property in your POM so that the antrun plugin always recognizes it even if you run the Maven build from command line. You can define properties in the pom.xml as follows:

<properties>
    <property.name>propertyValue</property.name>
</properties>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM