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.
9. 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
10. 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
11. 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
12. Git hands-on
n Find an ASF project using GIT
n Play with the basic GIT commands
Open Source Workshop 12
14. 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
19. 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
21. 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
22. 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
23. 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
25. 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
26. 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