Maven, SVN, Jars, Interfaces - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Maven, SVN, Jars, Interfaces

Description:

Has nothing to do with an SVN repository. ... Tortoise SVN putty (win) Cygwin (svn through win) svn checkout. svn add. svn commit ... – PowerPoint PPT presentation

Number of Views:228
Avg rating:3.0/5.0
Slides: 21
Provided by: hans95
Category:

less

Transcript and Presenter's Notes

Title: Maven, SVN, Jars, Interfaces


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)
  • ltprojectgt
  • ltmodelVersiongt4.0.0lt/modelVersiongt
  • ltgroupIdgtno.uio.inf5750lt/groupIdgt
  • ltartifactIdgtexample1lt/artifactIdgt
  • ltversiongt1.0-SNAPSHOTlt/versiongt
  • ltpackaginggtjarlt/packaginggt
  • ltnamegtINF5750 Example 1lt/namegt
  • ltdependenciesgt
  • ltdependencygt
  • ltgroupIdgtcommons-logginglt/groupIdgt
  • ltartifactIdgtcommons-logginglt/artifactIdgt
  • ltversiongt1.0.3lt/versiongt
  • lt/dependencygt
  • ltdependencygt
  • ltgroupIdgtspringframeworklt/groupIdgt
  • ltartifactIdgtspringlt/artifactIdgt

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 eclipseeclipse
  • Creating IDEA project files
  • m2 ideaidea
  • Clean project
  • m2 cleanclean
  • 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 ships 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 ltsome filesgt
  • 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 ltfilegt)
  • 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 svnignore F ltfile-with-listgt -R
    ltPATHgt

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
  • Javas ActionListener concept
  • A class can listen to a button if it implements
    the ActionListener interface and the method
  • public void actionPerformed(ActionEvent e)
  • Javas 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
  • ltbeansgt
  • ltbean idrentABike
  • classno.uio.inf5750.hanssto.bike.Mem
    oryRentABike/gt
  • ltbean idBikeApplication
  • classno.uio.inf5750.hanssto.bike.Bik
    eApplicationgt
  • ltproperty namerentABikegt
  • ltref idrentABike/gt
  • lt/propertygt
  • lt/beangt
  • lt/beansgt
Write a Comment
User Comments (0)
About PowerShow.com