Reputation: 33
Is there anyway i can pass the argument in the maven profile. Like i want to run the server on specific port if specified otherwise to the default profile. Like when i run mvn clean install -Pdeploy 4322 than the package should deploy to server running on the port 4322 otherwise to 4052.
Upvotes: 3
Views: 6273
Reputation: 1327
You can define default properties to use in your parent pom.xml
<properties>
<crx.userId>admin</crx.userId>
<crx.password>admin</crx.password>
<crx.host>localhost</crx.host>
<crx.port>4502</crx.port>
</properties>
Then later in the parent pom.xml or in a pom.xml of a child project you can use these properties.
Example:
<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>content-package-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<targetURL>http://${crx.host}:${crx.port}/crx/packmgr/service.jsp</targetURL>
<userId>${crx.userId}</userId>
<password>${crx.password}</password>
</configuration>
</plugin>
Then in your maven command use the -D[property name] = [value]
to overwrite the default value.
Upvotes: 2
Reputation: 61558
Yes, you can pass environment variables, like this : mvn ... -Pdeploy -DdeploymentPort=4322
Then access the variable in the profile like this:
...
<port>${deploymentPort}</port>
...
Upvotes: 7