open source tools overview

Post on 13-May-2015

2.113 Views

Category:

Technology

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

Are you planning to start working with open source and are overwhelmed by all the new tools you have to learn ? Here you can find a quick overview about Subversion, Git and Maven.

TRANSCRIPT

1

The Apache Software Foundation Community Development Open Source Tools Overview

Luciano Resende (lresende@apache.org)

Open Source Workshop 2

Topics

n  Install development environment tools q  Subversion q  Git q  Maven

n  Source Control Repositories q  Subversion q  Git

n  Build and Dependency Management q  Maven

Installing development environment tools

n  Subversion q  http://subversion.apache.org/packages.html

n  Git q  http://git-scm.com/downloads

n  Maven q  http://maven.apache.org/download.cgi

n  Eclipse q  http://www.eclipse.org/downloads/

Open Source Workshop 3

Also available at: http://10.0.0.3/icfoss

Wi-Fi :

ICFOSS-ROBOTICS ICFOSS606

SUBVERSION (SVN) 101

Open Source Workshop 4

Subversion

n  Centralized source control repository

n  Regular project structure q  Trunk – current development q  Branches – parallel development q  Tags – snapshots (e.g. release tags)

Open Source Workshop 5

Subversion useful commands

•  Checkout source code q  svn co http://www.company.com/repo/project/trunk

n  Ex. Svn co http://svn.apache.org/repos/asf/wink/trunk/ wink-svn

•  Update current checkout q  svn update

•  Check status of current checkout q  svn status

n  Check differences q  svn diff q  svn diff >> changes.patch (create a patch with the current diff)

n  Rollback changes q  svn revert file q  svn revert *

•  Add new file q  svn add file/directory

•  Commit files q  svn ci –m”Describe the contents of your commit”

Open Source Workshop 6

Subversion hands-on

n  Find an ASF project using subversion n  Play with the basic subversion commands

Open Source Workshop 7

GIT 101

Open Source Workshop 8

Git

n  Distributed source control repository

n  Regular project structure q  Trunk – current development q  Branches – parallel development q  Tags – snapshots (e.g. release tags)

Open Source Workshop 9

Git useful commands

•  Checkout source code q  git clone http://www.company.com/repo/project/trunk

n  E.g : git clone git://git.apache.org/wink.git •  Update current checkout

q  git pull --rebase •  Check status of current checkout

q  git status n  Check differences

q  git diff q  git format-patch >> changes.patch (create a patch with the current diff)

n  Rollback changes q  git reset –soft / --hard q  git checkout file

•  Add new file q  git add file/directory

•  Commit files q  git add file // git commit –a –m”Describe the contents of your commit” q  git commit –a –m”Describe the contents of your commit” q  git push q  git svn dcommit for git-svn bridge

Open Source Workshop 10

Git branch workflow

n  Clone the repository for the first time git clone git://git.apache.org/wink.git n  Update the repository git pull –rebase git svn rebase for git-svn bridge n  Workflow git checkout –b JIRA-101 creates a new branch git commit –a –m”JIRA-101 – My updates” commit all files changed git commit –a –amend updated commit with new changes git rebase master get changes from master git push push changes to remote repo git svn dcommit push changes in case of git-svn bridge git checkout master goes back to master branch n  Updating a branch with changes from master git rebase master

Open Source Workshop 11

Git hands-on

n  Find an ASF project using GIT n  Play with the basic GIT commands

Open Source Workshop 12

MAVEN 101

Open Source Workshop 13

What is Maven

n  A Java project management and integration build tool n  Based on the concept of XML Project Object Model (POM) n  Favors convention over configuration

q  Project Structure q  Repository Layout q  Etc

n  Modular build platform q  Extensible via plugins (a.k.a MOJO’s)

Open Source Workshop 14

Maven Build Lifecycle (Phases)

Phases n  Validate n  Compile n  Test n  Package n  Install n  Site n  Deploy

Plugins + Goals n  Maven-java-plugin:compile n  Maven-test-plugin:test n  Maven-jar-plugin:jar

n  <project> … <packaging>jar</packaging> …

n  </project>

Open Source Workshop 15

Maven Repository

n  Repositories n  No more libs in source code n  Public repositories

q  Central, etc

n  Internal repository (Nexus, Artifactory, etc) q  Proxy repository

n  Local repositories n  <project>

… <repositories> <repository> <id>central</id> <url>http://repo.internal.company.com:8081/releases</url> </repository> </repositories> … </project>

Open Source Workshop 16

Artifactory Internal Repo

Public Maven Repos

/m2 /repository

/org /apache

/com /google

Internet

Maven Dependency Management

<project> … <dependencies> <dependency> <groupId>org.apache.tuscany.sca</groupId> <artifactId>tuscany-binding-rest-runtime</artifactId> <version>2.0-M5</version> <packaging>jar</packaging> </dependency> </dependencies> … </project>

http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/tuscany/sca/tuscany-binding-rest-runtime/2.0-M5/tuscany-binding-rest-runtime-2.0-M5.jar

Open Source Workshop 17

Maven Project Structure

n  Project (jar) q  src

n  main……………………..Project source code q  Java………………...Java Artifacts q  Resources…………Resources (e.g xsd, composites, etc)

n  test................................Test codes (not added to final jar) q  java.........................Test Java Artifacts q  resources………….Test Resources

n  Project (webapp) q  src

n  main …………………….Project source code q  java ………………..Java Artifacts q  resources ………....Resources (e.g xsd, composites, etc) q  webapp ……………Web related resources (e.g html, jsp, css, etc)

§  META-INF §  WEB-INF

§  web.xml §  Web resources

Open Source Workshop 18

Maven Project Configuration

n  Configuration is entered in XML format in a Project Object Model or POM

n  Projects are structured in a hierarchy and project configuration is inherited by sub-projects q  If no parent is specified, parent is called “Super” or “Parent POM”

Open Source Workshop 19

Maven Project Configuration

<project> <parent> <groupId>com.company.application</groupId> <artifactId>parentProject</artifactId> <version>1.0.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> <groupId>com.parent.application</groupId> <artifactId>artifactName</artifactId> <packaging>pom</packaging> <name>artifactName</name> <modules> <module>…</module> <module>…</module> </modules> </project>

Modules must map to directory structure

Open Source Workshop 20

Maven useful commands

n  Build q  mvn clean install

n  Build in offline mode q  mvn clean install -o

n  Build and force updating/downloading dependencies q  mvn -U clean install

n  Build without executing unit tests q  mvn clean install -Dmaven.test.skip=true

n  Build and report errors only at the end (fail at end) q  mvn -fae clean install

n  Build and don’t report errors (fail never) q  mvn -fn clean install

n  Execute only one test case q  mvn -Dtest=ComponentServiceReferenceTestCase

Clean is optional, but omitting it might cause unexpected issues.

Open Source Workshop 21

Maven useful commands

•  Put maven in debug mode q  mvnDebug

•  Identify 3rd party dependencies with maven dependency plugin q  mvn dependency:analyze q  mvn dependency:copy-dependencies q  mvn dependency:tree

Open Source Workshop 22

Maven with Eclipse

Maven Eclipse plugins q  The goal of the Eclipse m2eclipse project is to provide Apache Maven support in

the Eclipse IDE, making it easier to edit Maven's pom.xml, run a build from the IDE and much more. For Java developers, the very tight integration with JDT greatly simplifies the consumption of Java artifacts.

q  http://download.eclipse.org/technology/m2e/releases

Open Source Workshop 23

SUGGESTED HOMEWORK

Open Source Workshop 24

Github Project

n  Create a github java project q  Create new repository q  Create a maven java project q  Add some business logic q  Add tests to verify your business logic q  Build

n  With tests n  Without tests

Open Source Workshop 25

Github collaboration

n  Provide a patch for your colleague project q  Do a simple change on your colleague project q  Submit a pull request q  Add a bit more change (simulating a update based on feedback) q  Submit a pull request

n  Owner should accept pull request and merge changes q  If you can’t find an owner, I will create a simple project and you can use that

n  My github account : lresende

Open Source Workshop 26

top related