The following step-by-step guide can be used for installing the TweetyProject libraries via Maven on the command line. This works for all Linux derivatives/Max OS X (the guide is given for Ubuntu Linux but works similarly for other systems).
- Install Maven
$ sudo apt-get install maven
- Create empty Maven project
$ mvn archetype:generate
-DgroupId=mytweety.mytweetyapp
-DartifactId=mytweetyapp
-DarchetypeArtifactId=maven-archetype-quickstart
-DinteractiveMode=false
- Add TweetyProject as dependency
$ cd mytweetyapp
$ nano pom.xml
<project ...>
...
<dependencies>
...
<dependency>
<groupId>org.tweetyproject</groupId>
<artifactId>tweety-full</artifactId>
<version>1.27</version>
</dependency>
...
</dependencies>
</project>
- Configure Maven for automatic dependency inclusion (recommended for beginners)
<project ...>
...
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
- Write code
$ nano src/main/java/mytweety/mytweetyapp/App.java
package mytweety.mytweetyapp;
import org.tweetyproject.logics.pl.syntax.*;
public class App{
public static void main( String[] args ) {
PlFormula helloWorld = new Proposition("HelloWorld");
System.out.println(helloWorld); }
}
- Compile and run
$ mvn package
$ java -cp target/mytweetyapp -1.0-SNAPSHOT-jar-with-dependencies.jar
mytweety.mytweetyapp.App HelloWorld