Skip to content

Maven Plugin Example 01

Thomas Deutsch edited this page Mar 28, 2018 · 2 revisions

[MavenPlugin] Usage Example 01

Description

  • We want to extract country codes from a real URL
  • We use a CSS selector to point to the table we want
  • And we want to extract the data from colum 2 to be used as our enum constant names.

pom.xml

<build>
    <plugins>
        <plugin>
            <groupId>com.tcmj.plugins</groupId>
            <artifactId>pug-enum-maven-plugin</artifactId>
            <version>LATEST_VERSION</version>
            <configuration>
                <className>com.tcmj.html.test.MyCountriesEnum1</className>
                <sourceDirectory>target/generated-test-sources/project-to-test</sourceDirectory>
                <url>http://www.nationsonline.org/oneworld/country_code_list.htm</url>
                <tableCssSelector>table#codelist</tableCssSelector>
                <constantColumn>2</constantColumn>
            </configuration>
        </plugin>
    </plugins>
</build>

Output :

package com.tcmj.html.test;

/**
 * <div>Data has been fetched from
 * 'http://www.nationsonline.org/oneworld/country_code_list.htm'.</div>
 */
public enum MyCountriesEnum1 {
   AFGHANISTAN,
   ALAND_ISLANDS,
   ALBANIA,
   ALGERIA,
   AMERICAN_SAMOA,
   ANDORRA,
   ANGOLA,
   ...
   ZAMBIA,
   ZIMBABWE
}

Testcases can be found at: