SWT Lab 1


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • http://creativecommons.org/licenses/by-sa/3.0/You are free:to Share — to copy, distribute and transmit the workto Remix — to adapt the workto make commercial use of the workUnder the following conditions:Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).Share Alike — If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.With the understanding that:Waiver — Any of the above conditions can be waived if you get permission from the copyright holder.Public Domain — Where the work or any of its elements is in the public domain under applicable law, that status is in no way affected by the license.Other Rights — In no way are any of the following rights affected by the license:Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations;The author's moral rights;Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights.Notice — For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.
  • SWT Lab 1

    1. 1. + Jena and Maven Lab 1
    2. 2. + Disclaimer License This work is licensed under the Creative Commons Attribution-Share Alike 3.0 License http://creativecommons.org/licenses/by-sa/3.0/
    3. 3. + Quick intro to Maven  Maven’s goal is to simplify the development cycle and to allow the developer to comprehend the complete state of the development in the shortest time. Maven deals with:  Making the build process easy  Providing a uniform build system  Providing quality project information  Providing guidelines for best practices development  Allowing transparent migration to new features
    4. 4. + Installing maven First, download Maven and follow the installation instructions. http://maven.apache.org/download.html#Installation After that, type the following in a terminal or in a command prompt: do mvn –version if it works, Maven is ready
    5. 5. + Creating a project  mvn archetype:generate -DgroupId=com.mycompany.app DartifactId=my-app -DarchetypeArtifactId=maven-archetypequickstart -DinteractiveMode=false my-app |-- pom.xml `-- src |-- main | `-- java | `-- com | `-- mycompany | `-- app | `-- App.java `-- test `-- java `-- com `-- mycompany `-- app `-- AppTest.java
    6. 6. + The POM <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany.app</groupId> <artifactId>my-app</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>Maven Quick Start Archetype</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> <scope>test</scope> </dependency> </dependencies> </project>
    7. 7. + Building a package with embedded dependencies <build> <plugins> Add this to your pom <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>fully.qualified.MainClass</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </plugin> </plugins> </build>
    8. 8. + Build and Run mvn assembly:single use this instead of “package” ... [INFO] -----------------------------------------------------------------------[INFO] BUILD SUCCESSFUL [INFO] -----------------------------------------------------------------------[INFO] Total time: 2 seconds [INFO] Finished at: Thu Jul 07 21:34:52 CEST 2011 [INFO] Final Memory: 3M/6M [INFO] -----------------------------------------------------------------------java -cp target/my-app-1.0-SNAPSHOT-jar-with-dependencies.jar com.mycompany.app.App Hello World! Make sure to use the full name of the JAR with all the dependencies (should be several megabytes in size)
    9. 9. + Jena and Maven  To develop with Jena simply add the following to your POM’s <dependencies> section <dependency> <groupId>org.apache.jena</groupId> <artifactId>jena-arq</artifactId> <version>2.9.3</version> </dependency>
    10. 10. + Lab assignment 1  Make a small program that generates a Jena model for the Books graph (slide 38) and writes the graph into    A RDF/XML file A turtle file The program must  Be done using maven  Include a runnable script to execute it