1 / 20

Maven, SVN, Jars, Interfaces

Maven, SVN, Jars, Interfaces. Maven. Why: Dependency managment Build tool (classpath managment) Useful in large projects and in complex projects. Project Object model: pom.xml. (Copied from the lecture notes) <project> <modelVersion>4.0.0</modelVersion>

brilliant
Télécharger la présentation

Maven, SVN, Jars, Interfaces

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Maven, SVN, Jars, Interfaces

  2. Maven • Why: • Dependency managment • Build tool (classpath managment) • Useful in large projects and in complex projects.

  3. Project Object model: pom.xml (Copied from the lecture notes) <project> <modelVersion>4.0.0</modelVersion> <groupId>no.uio.inf5750</groupId> <artifactId>example1</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>INF5750 Example 1</name> <dependencies> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.0.3</version> </dependency> <dependency> <groupId>springframework</groupId> <artifactId>spring</artifactId> <version>1.1.3</version> </dependency> <dependencies> </project>

  4. Groups and artifacts no.uio.inf5750 assignment2 xml-formatter assignment1

  5. Example uses of Maven (Copied from the lecture notes) • Package the source code into an archive $ m2 package • Run the projects unit tests $ m2 test • Creating Eclipse project files $ m2 eclipse:eclipse • Creating IDEA project files $ m2 idea:idea • Clean project $ m2 clean:clean • Install the package into the local repository $ m2 install

  6. Maven repository • Has nothing to do with an SVN repository. • Central repo (maven.apache.org, ibiblio.org, download jars from here) • Local repo (downloaded/installed jars) • Look in ~/.m2/repository

  7. JAR • A zip file for Java code • Bundle lots of files together in a foo.jar file. • May contain a manifest (like a ship’s manifest) • Can be run, if a class is specified in the manifest: java –jar foo.jar • The assignment1 example! • Create archive: jar –cvzf foo.jar <some files> • Extract contents of archive: jar –xvzf foo.jar

  8. Subversion (SVN) • Why SVN? • Multiple people coding on the same project. • Version control: Increment changes, rollback unwanted changes. • CVS is the same type of program, only older.

  9. SVN: Working cycle • Create repository (svnadmin create) • Check out local copy ( svn checkout URL) • Create local files • Add files to version control (svn add <file>) • Commit changes (svn commit) • … • Check status of local copy (svn status) • Check out/Update local copy (svn update) • Change files • Commit changes (svn commit)

  10. SVN: Overview • SVN client • - Local copy • svn CLI (linux/win) • Tortoise SVN + putty (win) • Cygwin (svn through win) • svn checkout • svn add • svn commit • SVN server • Central repo • svnadmin create

  11. SVN: General cycle Client 1 Checkout Commit Central repo Checkout Client 2 Commit

  12. SVN: Conflict! Client 1 Checkout Commit Central repo Checkout Client 2 Commit

  13. SVN: Healthy cycle Client 1 Checkout Commit Central repo Checkout Update Client 2 Commit

  14. SVN: Adding to version control? • What to check in: • Source code • Tests • Resources • What not to check in: • Compiled code • Eclipse files (.project, .whatnot) • Other files specific for the local system • Make SVN ignore files • svn propset svn:ignore –F <file-with-list> -R <PATH>

  15. Java interfaces • Perhaps the most advanced concept in Java? • Code: • A ”class” with only methods, methods which have no body. • Concept: • A contract: If you implement the interface, you must implement the methods defined by it. • Reward: Other classes can treat you as if you are an instance of the interface. • Interface: What. Implementation: How.

  16. Interfaces: Overview Implementation 1 Application Interface Implementation 2

  17. Interfaces: Java examples • Java’s ActionListener concept: • A class can listen to a button if it implements the ActionListener interface and the method public void actionPerformed(ActionEvent e) {…} • Java’s collections framework (e.g. List, Set, etc): • Interface: List. • Implementations: ArrayList, Vector, LinkedList.

  18. Example: RentABike Implementations MemoryRentABike (class) BikeApplication (class) RentABike (interface) DatabaseRentABike (class) FileRentABike (class)

  19. Where to choose the implementation? • Hard code it into the application (highly coupled) • Let a controlling class choose the implementation for the application. (Better, but still coupled) • Decide at run time, depending on situation. Need a registry. • Let Swing inject the implementation into the application (even better… ).

  20. Spring: beans.xml <beans> <bean id=”rentABike” class=”no.uio.inf5750.hanssto.bike.MemoryRentABike”/> <bean id=”BikeApplication” class=”no.uio.inf5750.hanssto.bike.BikeApplication”> <property name=”rentABike”> <ref id=”rentABike”/> </property> </bean> </beans>

More Related