We are going to use a Flink Maven Archetype for creating our project structure. Please see Java API Quickstart for more details about this. For our purposes, the command to run is this:

    1. mvn archetype:generate \
    2. -DarchetypeGroupId=org.apache.flink \
    3. -DarchetypeArtifactId=flink-quickstart-java \
    4. -DarchetypeVersion=1.9.0 \
    5. -DgroupId=wiki-edits \
    6. -DartifactId=wiki-edits \
    7. -Dversion=0.1 \
    8. -Dpackage=wikiedits \
    9. -DinteractiveMode=false

    You can edit the groupId, artifactId and package if you like. With the above parameters, Maven will create a project structure that looks like this:

    1. $ tree wiki-edits
    2. wiki-edits/
    3. ├── pom.xml
    4. └── src
    5. └── main
    6. ├── java
    7. └── wikiedits
    8. ├── BatchJob.java
    9. └── StreamingJob.java
    10. └── resources
    11. └── log4j.properties

    There is our pom.xml file that already has the Flink dependencies added in the root directory and several example Flink programs in src/main/java. We can delete the example programs, since we are going to start from scratch:

    1. $ rm wiki-edits/src/main/java/wikiedits/*.java

    As a last step we need to add the Flink Wikipedia connector as a dependency so that we can use it in our program. Edit the dependencies section of the pom.xml so that it looks like this:

    1. <dependencies>
    2. <dependency>
    3. <groupId>org.apache.flink</groupId>
    4. <artifactId>flink-java</artifactId>
    5. <version>${flink.version}</version>
    6. </dependency>
    7. <dependency>
    8. <groupId>org.apache.flink</groupId>
    9. <artifactId>flink-streaming-java_2.11</artifactId>
    10. <version>${flink.version}</version>
    11. </dependency>
    12. <dependency>
    13. <groupId>org.apache.flink</groupId>
    14. <artifactId>flink-clients_2.11</artifactId>
    15. <version>${flink.version}</version>
    16. </dependency>
    17. <dependency>
    18. <groupId>org.apache.flink</groupId>
    19. <artifactId>flink-connector-wikiedits_2.11</artifactId>
    20. <version>${flink.version}</version>
    21. </dependency>
    22. </dependencies>

    Notice the flink-connector-wikiedits_2.11 dependency that was added. (This example and the Wikipedia connector were inspired by the Hello Samza example of Apache Samza.)