Search code examples
javamavenglassfishmaven-3payara

deploying war directly from maven to appserver


I would like to build and deploy my war file directly to the domain of appserver. The below snippet is working fine for this,

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${version.maven.war.plugin}</version>
<configuration>
<outputDirectory>
C:\Program Files\glassfish\glassfish5\glassfish\domains\domain1\autodeploy
</outputDirectory>
</configuration>
</plugin>

I don't want to hard code the path. So, I set the system variable GLASSFISH_HOME : C:\Program Files\glassfish and used it in the POM file like this:

<outputDirectory>                    
 ${GLASSFISH_HOME}\glassfish5\glassfish\domains\domain1\autodeploy
</outputDirectory>

but its not working. maven is creating a directory in the current path of the project like below:

[INFO] Building war: C:\Workspaces\Workspace- Restful\moviedirectory\${GLASSFISH_HOME}\glassfish5\glassfish\domains\domain1\autodeploy\moviedirectory.war

any suggestions how to avoid hard coding path but deploy the war to appserver while building it with maven?


Solution

  • Have a look at How to refer environment variable in POM.xml?

    So the following should do what you want.

    <outputDirectory>                    
      ${env.GLASSFISH_HOME}\glassfish5\glassfish\domains\domain1\autodeploy
    </outputDirectory>