-
Notifications
You must be signed in to change notification settings - Fork 3
Setting up the Maven project
If you haven't got Eclipse IDE for Java EE Developers - or for whatever reasons Maven is not part of your Eclipse installation - you should download and install the M2E-Web Tool Project plugin for Eclipse from the Eclipse Marketplace.
In the Project Explorer, create a new Maven Project. Make sure only "Use default workspace location" is checked and press Next. Wait for the windows to download all the archetypes, then select maven-archetype-webapp. In the next screen you'll have to fill in some details, such as the group Id (e.g. ggd), archetype id (e.g. RTwUP). Then you can press "Finish" and the project will be created.
It may depends on how your buildpath is configured, but if Eclipse highlights a problem with the Java version set in your buildpath, go fixing the issue.
You can integrate the latest Twitter4J build easily by just including the following lines in your pom.xml (We are using Twitter Stream API).
<dependencies>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-stream</artifactId>
<version>[4.0,)</version>
</dependency>
...
</dependencies>
If you use Eclipse to open and modify pom.xml, hit the Dependencies tab and click Add (on the left), then fill in the fields with the details given above in the XML format.
You should also integrate Storm in your Maven project. The first thing to do is to add a dependency in your pom.xml (before the <dependencies>
tag) like this:
<repositories>
<repository>
<id>clojars.org</id>
<url>http://clojars.org/repo </url>
</repository>
</repositories>
Then, like what you did before with the Twitter4J dependency, add the Storm dependency:
<dependencies>
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-core</artifactId>
<version>2.3.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Refresh your project if required.
By default, Maven sets JRE to version 6.
If you want to configure JRE with a more recent version, you have to change pom.xml adding the following code:
<build>
...
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
...
</plugins>
</build>
By default, if the project packaging is jar, command
mvn clean package
will create a jar file without including the dependencies.
If you want to include dependencies in jar file, you have to change pom.xml adding this code:
<build>
...
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>storm.RtwupTopology</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
Note that to include Storm dependency files you need to set its scope to 'compile'.