Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7979207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:42:59+00:00 2026-06-04T09:42:59+00:00

I am using maven 2.2.1 version as a build tool for my Java Application

  • 0

I am using maven 2.2.1 version as a build tool for my Java Application .

With this Maven tool , i am building the war file in some directory and copying it to server (Tomcat )

This works by these below lines

<copy file="D:/MyProject/target/Test.war"
tofile="C:/Softwares/apache-tomcat-6.0.33/webapps/Test.war" />

All this works fine .

Here my question is that instead of hard coding directory the directory path , can i specifiy somewhere else ??

I have seen these project.build.directory for the src directory and project.build.outputDirectory for the target directory , can we specify this property name in the file ??

Please guide me , thanks in advance .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:43:00+00:00Added an answer on June 4, 2026 at 9:43 am

    For the war path, you can use built in Maven properties:

    ${project.build.directory}/${project.build.finalName}.${project.packaging}
    

    You want to set the deployment path as a custom Maven property. There are a few ways to do this. One is setting it directly in the pom, like this:

    <properties>
      <deploy.path>C:/Softwares/apache-tomcat-6.0.33/webapps/Test.war</deploy.path>
    </properties>
    

    However, this is still hard coding the path in the pom, just in a variable.

    Another way is to use the properties-maven-plugin to read in a properties file. This keeps user specific settings out of the pom, and you can keep your properties file out of source control. However, this is not the preferred Maven way of doing things, and this plugin may no longer be supported in future versions.

    The Maven way to do this is to store your deploy path in your ~/.m2/settings.xml file. This property would go in a profile, which can be active by default. See this page for an explanation.

    Once you have your deploy.path variable set, change your copy statement to look like this:

    <copy file="${project.build.directory}/${project.build.finalName}.${project.packaging}"
        tofile="${deploy.path}" />
    

    Edit:

    On a minimal example project, the following properties are all set for me:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.7</version>
        <executions>
          <execution>
            <id>compile</id>
            <phase>compile</phase>
            <configuration>
              <target>
                <echo message="project.build.directory: ${project.build.directory}"/>
                <echo message="project.build.finalName: ${project.build.finalName}"/>
                <echo message="project.packaging: ${project.packaging}"/>           
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    

    If those properties aren’t set for you, can you post your pom.xml?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Maven in the context of another build-tool (leiningen for Clojure, but this
We are using Maven(3.0.3) as build tool and we need to have different version
I am trying to build a Java EE application using Maven. I have the
I am using Maven as the build file , this is my below settings
I am using Maven 3 for build Dashboard project After building my web application
Im using maven to build a multi module project. But some projects are in
I'm using maven for deploying a web application in my Weblogic 10.3 server remotely.
We build software using Hudson and Maven. We have C#, java and last, but
I have to build an application using Maven for PHP that has multiple modules.
Unit test is in Java, using Maven to build & run. I can use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.