Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Working with Maven projects

glechev edited this page Jul 5, 2021 · 2 revisions

Working with Maven Projects

As part of vRealize Automation Content Generator, we provide a Maven archetype definition that allows you to create new projects easily.

Creating new Maven project from archetype

mvn archetype:generate \
  -DarchetypeGroupId=com.vmware.devops \
  -DarchetypeArtifactId=vrealize-automation-content-generator-project \
  -DarchetypeVersion=1.0 \
  -DgroupId=<your.group.id> \
  -DartifactId=<myProject> \
  -Dinstance=https://<vra-instance> \
  -DloginInstance=https://<vra-instance> \
  -Dusername=xxxx \
  -Dpassword=xxxx \
  -DrefreshToken=xxxx \
  -Dinitialize=false

Breaking the command down:

  • -DarchetypeGroupId, -DarchetypeArtifactId and -DarchetypeVersion are Maven options that notify what arhetype you want to generate
  • -DgroupId and -DartifactId are standard Maven properties that describe your project. Refer to Maven documentation for more information.
  • (Optional)-Dinstance and -DloginInstance describe where is the vRealize Automation instance you'll be using
    • For on-prem deployments, both options should point to the vRealize Automation load balancer
    • (Default) For vRA Cloud do not pass these options. It will default to -Dinstance=https://api.mgmt.cloud.vmware.com and -DloginInstance=https://console.cloud.vmware.com
  • -Dusername -Dpassword and the -DrefreshToken are authentication options. You need to specify one of the two:
  • Dinitialize - reverse generate the existing content in the system. Works only when -DrefreshToken is used. For username and password, reverse generation needs to be executed manually after the setup bellow.

After the project is created, if you're using username and password edit the initialized pom.xml file and update the following section as described:

<!-- If you're using username/password, uncommend this section -->
<!--                                <argument>-u</argument>-->
<!--                                <argument>${target.username}</argument>-->
<!--                                <argument>-p</argument>-->
<!--                                <argument>${target.password}</argument>-->
<!-- And remove this -->
                                <argument>-t</argument>
                                <argument>${target.refreshToken}</argument>
<!--END-->

There are 2 sections that need to be updated.

Compiling the groovy code

mvn clean compile will compile all the sources in your project. You can use this to verify there are ano syntax errors when editing.

Unit testing

mvn clean install will run any tests in the projects. See Custom objects.

Reverse generation

mvn clean deploy -PreverseGenerate will reverse generate existing content from the system and import the sources in the project. See [Reverse generation](Generation and reverse generation)

Generation

mvn clean deploy - create or update vRealize Automation content in the system. See Generation