Total Pageviews

Showing posts with label SCM. Show all posts
Showing posts with label SCM. Show all posts

2018/01/09

[GitLab] How to build jar file automatically

Problem
If I hope GitLab can build a jar file when I commit source code, how to do it?
I am using Maven 3.3.3 and JDK 7 in eclipse, and using mvn clean install -Dmaven.test.skip=true to build WAR file in eclipse.

How-To

Step 1. Add .gitlab-ci.yml to the root directory of my project, the content looks like:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
image: maven:3.3.3-jdk-7
    
build:
  stage: build
  script:
   - "mvn clean install -Dmaven.test.skip=true"
  artifacts:
    expire_in: 1 week
    when: on_success
    paths:
    - target/*.jar

Step 2. Add, commit and push .gitlab-ci.yml to GitLab
Step 3. Seeing the status of your pipeline and jobs 


Reference

[1] https://docs.gitlab.com/ce/ci/quick_start/README.html

2018/01/08

[GitLab] How to build WAR file automatically

Problem
If I hope GitLab can build a WAR file when I commit source code, how to do it?
I am using Maven 3 and JDK 7 in eclipse, and using mvn clean package -U to build WAR file in eclipse.

How-To

Step 1. Add .gitlab-ci.yml to the root directory of my project, the content looks like: 
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
image: maven:3-jdk-7

build:
  stage: build
  script: "mvn clean package -U"
  artifacts:
    expire_in: 1 week
    when: always
    paths:
    - target/*.war

Step 2. Add, commit and Push .gitlab-ci.yml to GitLab
Step 3. Seeing the status of your pipeline and jobs 

Reference

[1] https://docs.gitlab.com/ce/ci/quick_start/README.html
[2] https://hub.docker.com/r/library/maven/tags/

2017/12/09

[Maven] How to assign WAR file name in pom.xml

Problem
When I utilize maven to build WAR file, the WAR file name always suffix by version which define in pom.xml (i.e. StockQry-1.0.war).
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<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>StockQry</groupId>
    <artifactId>StockQry</artifactId>
    <version>1.0</version>
    <packaging>war</packaging>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <resources>
            <resource>
                <directory>src</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <!-- ignore plugins -->
        </plugins>
    </build>

    <dependencies>
        <!-- ignore dependencies -->
    </dependencies>

</project>
If I would like to have StockQry.war instead of StockQry-1.0.war, how to do it?


How-To
Add finalName in build tag, the updated pom.xml are the following:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<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>StockQry</groupId>
    <artifactId>StockQry</artifactId>
    <version>1.0</version>
    <packaging>war</packaging>
    <build>
        <finalName>StockQry</finalName>
        <sourceDirectory>src</sourceDirectory>
        <resources>
            <resource>
                <directory>src</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <!-- ignore plugins -->
        </plugins>
    </build>

    <dependencies>
        <!-- ignore dependencies -->
    </dependencies>

</project>


2015/03/27

[Git Tool] SourceTree

Requirement
目前專案採用 Git 作為程式碼管理工具,外包廠商的程式交付流程如下

由上圖可以看到,每次開發功能都要 create 一個 branch,完成後 commit上Git,並在GitLab create merge request。經過 review 後,此 branch 才可以 Merge 到 master。

如果我想要看到每次交付的branch,異動到的程式清單,以及每隻程式的異動內容的話,有什麼工具可以輔助達成此需求


Solution
SourceTree 是 Git 的 GUI 工具,讓你不需要用 command line,讓你可以將時間專注於程式開發上。

假設你在電腦中已經有一個 git folder,打開已經安裝好的SourceTree

1. File => Open


2. 指向 folder


3. Click OK


完成以上動作後,在左手邊可以看到現有的branch,假設我點選master,中間的地方就是commit的歷史紀錄



例如目前專案有不同廠商開發,點選某廠商最近commit的branch,中間就是此branch所增加、減少、修改的程式清單,點選某隻程式,右手邊就是該程式所修改的內容。藉此工具可以了解廠商本次commit的branch改了那些程式,動到哪些地方



Reference
[1] http://kenlai.logdown.com/posts/52372--git-dropbox-sourcetree-source-code-management
[2] http://www.sourcetreeapp.com/
[3] http://blog.lyhdev.com/2011/10/sourcetree-git-mercurial-gui-for-mac-os.html
[4] http://www.takobear.tw/201702608526356260322804024687/bear-git-flow-sourcetreegit-flow

2014/12/19

How to delete a branch in EGit?

Question
Assume I created a branch, DBM_CommonService_getPaymentData, to implement a new function. 

After I finished this function and commit & push to GitLab,  and GitLab project owner merged this branch into master. 

If I had switch to master and would like to delete DBM_CommonService_getPaymentData branch, how to delete it?


Answer

Step1. right click => Team => Advanced => Delete branch

Step2. Selected the branch name you want to delete => Click "OK"

See..as you right click => Team => Switch to, you won't see DBM_CommonService_getPaymentData branch anymore.

Reference

2014/12/11

Checkout remote Git branch

Owing to our software development had been outsourced, here is the delivery process as function completion: 



As outsourced programmer completed his/her own function, he/she need to go to Gitlab to create a merge request to remind us:



Then we need to checkout his/her branch which he/she pushed to do code review.


Assume our initial branch is master, then there is the process to check out remote Git branch:



  • 1. Team => Remote => Fetch From...


  • 2. Click "Next"
  • 3. You can find out the branch name in merge request no matter in Gitlab or email. Hence, configure the source and destination ref. And click "Finish" button.

  •  4. Click OK


  • 5. Team => Switch To => Other..


  • 6. Remote Tracking => select specific branch name => Checkout.


  • 7. Checkout


  • 8. Click "Finish"


  • 9. We had changed from master to "DBM915R_new_function"







2014/11/21

2014/11/12

What's the difference between 'commit' and 'commit and push' in Git?

When I want to commit changes into git repository, I see two options to commit. One is "Commit", another one is "Commit and Push".

Here has a clear picture
If you do git commit, it means you only commit changes into your local repository.
If you do git push, it means you will commit changes to remote repository.


Demo
If I click Commit

Remote repository does not know what happened.



 If I click "Commit and Push"

Remote repository received these changes.

Reference
[1] http://stackoverflow.com/questions/2745076/what-are-the-differences-between-git-commit-and-git-push

2014/11/11

How to create project in GitLab and import project into Eclipse

Go to GitLab to create my project
1. Click New Project
 2. Fill in your project name, namespace => Create project


Open Git Bash
1. Change directory to my specific dirctory => make dbm directory => Initialized empty Git repository
1:  albert@ALBERT-PC ~  
2:  $ cd d:  
3:  albert@ALBERT-PC /d  
4:  $ cd git  
5:  albert@ALBERT-PC /d/git  
6:  $ mkdir dbm  
7:  albert@ALBERT-PC /d/git  
8:  $ cd dbm  
9:  albert@ALBERT-PC /d/git/dbm  
10:  $ git init  
11:  Initialized empty Git repository in d:/git/dbm/.git/  

2. create README file => add README to track => commit
1:  albert@ALBERT-PC /d/git/dbm (master)  
2:  $ touch README  
3:  albert@ALBERT-PC /d/git/dbm (master)  
4:  $ git add README  
5:  albert@ALBERT-PC /d/git/dbm (master)  
6:  $ git commit -m "first commit"  
7:  [master (root-commit) b45a8a4] first commit  
8:   1 file changed, 0 insertions(+), 0 deletions(-)  
9:   create mode 100644 README  

3. add git remote repository => push to remote
1:  albert@ALBERT-PC /d/git/dbm (master)  
2:  $ git remote add origin http://192.168.31.166/ifmis/dbm.git  
3:  albert@ALBERT-PC /d/git/dbm (master)  
4:  $ git push -u origin master  
5:  Username for 'http://192.168.31.166': albert_kuo  
6:  Password for 'http://albert_kuo@192.168.31.166':  
7:  Counting objects: 3, done.  
8:  Writing objects: 100% (3/3), 206 bytes | 0 bytes/s, done.  
9:  Total 3 (delta 0), reused 0 (delta 0)  
10:  To http://192.168.31.166/ifmis/dbm.git  
11:   * [new branch]   master -> master  
12:  Branch master set up to track remote branch master from origin.  

README file had been commit into git

Assume I create my project skeleton into my git folder

Add all files into track => commit => push to remote
1:  albert@ALBERT-PC /d/git/dbm (master)  
2:  $ git add .  
3:  warning: LF will be replaced by CRLF in dbm-webapp/src/main/jasperreports/README.md.  
4:  The file will have its original line endings in your working directory.  
5:  warning: LF will be replaced by CRLF in dbm-webapp/src/main/webapp/WEB-INF/templates/README.md.  
6:  The file will have its original line endings in your working directory.  
7:  warning: LF will be replaced by CRLF in dbm-webapp/src/main/webapp/scripts/README.md.  
8:  The file will have its original line endings in your working directory.  
9:  warning: LF will be replaced by CRLF in dbm-webapp/src/main/webapp/styles/README.md.  
10:  The file will have its original line endings in your working directory.  
11:  warning: LF will be replaced by CRLF in dbm-webapp/src/test/database/README.md.  
12:  The file will have its original line endings in your working directory.  
13:  warning: LF will be replaced by CRLF in dbm-webapp/src/test/database/test-datasource.xml.template-or  
14:  acle.  
15:  The file will have its original line endings in your working directory.  
16:  warning: LF will be replaced by CRLF in dbm-webapp/src/test/database/test-datasource.xml.template-sq  
17:  lserver.  
18:  The file will have its original line endings in your working directory.  
19:  warning: LF will be replaced by CRLF in pom.xml.  
20:  The file will have its original line endings in your working directory.  
21:  albert@ALBERT-PC /d/git/dbm (master)  
22:  $ git commit -m "create project skeleton"  
23:  [master 4abf50e] create project skeleton  
24:  warning: LF will be replaced by CRLF in dbm-webapp/src/main/jasperreports/README.md.  
25:  The file will have its original line endings in your working directory.  
26:  warning: LF will be replaced by CRLF in dbm-webapp/src/main/webapp/WEB-INF/templates/README.md.  
27:  The file will have its original line endings in your working directory.  
28:  warning: LF will be replaced by CRLF in dbm-webapp/src/main/webapp/scripts/README.md.  
29:  The file will have its original line endings in your working directory.  
30:  warning: LF will be replaced by CRLF in dbm-webapp/src/main/webapp/styles/README.md.  
31:  The file will have its original line endings in your working directory.  
32:  warning: LF will be replaced by CRLF in dbm-webapp/src/test/database/README.md.  
33:  The file will have its original line endings in your working directory.  
34:  warning: LF will be replaced by CRLF in dbm-webapp/src/test/database/test-datasource.xml.template-or  
35:  acle.  
36:  The file will have its original line endings in your working directory.  
37:  warning: LF will be replaced by CRLF in dbm-webapp/src/test/database/test-datasource.xml.template-sq  
38:  lserver.  
39:  The file will have its original line endings in your working directory.  
40:  warning: LF will be replaced by CRLF in pom.xml.  
41:  The file will have its original line endings in your working directory.  
42:   22 files changed, 498 insertions(+)  
43:   create mode 100644 README.md  
44:   create mode 100644 dbm-entity/pom.xml  
45:   create mode 100644 dbm-entity/src/main/java/gov/nta/entity/package-info.java  
46:   create mode 100644 dbm-service/pom.xml  
47:   create mode 100644 dbm-service/src/main/java/gov/nta/dbm/repository/package-info.java  
48:   create mode 100644 dbm-service/src/main/java/gov/nta/dbm/service/package-info.java  
49:   create mode 100644 dbm-webapp/pom.xml  
50:   create mode 100644 dbm-webapp/src/main/jasperreports/README.md  
51:   create mode 100644 dbm-webapp/src/main/java/gov/nta/dbm/web/controller/package-info.java  
52:   create mode 100644 dbm-webapp/src/main/java/gov/nta/dbm/web/dto/package-info.java  
53:   create mode 100644 dbm-webapp/src/main/java/gov/nta/dbm/web/rest/package-info.java  
54:   create mode 100644 dbm-webapp/src/main/resources/gov/nta/dbm/Messages.properties  
55:   create mode 100644 dbm-webapp/src/main/webapp/WEB-INF/jboss-deployment-structure.xml  
56:   create mode 100644 dbm-webapp/src/main/webapp/WEB-INF/jboss-web.xml  
57:   create mode 100644 dbm-webapp/src/main/webapp/WEB-INF/templates/README.md  
58:   create mode 100644 dbm-webapp/src/main/webapp/WEB-INF/web.xml  
59:   create mode 100644 dbm-webapp/src/main/webapp/scripts/README.md  
60:   create mode 100644 dbm-webapp/src/main/webapp/styles/README.md  
61:   create mode 100644 dbm-webapp/src/test/database/README.md  
62:   create mode 100644 dbm-webapp/src/test/database/test-datasource.xml.template-oracle  
63:   create mode 100644 dbm-webapp/src/test/database/test-datasource.xml.template-sqlserver  
64:   create mode 100644 pom.xml  
65:  albert@ALBERT-PC /d/git/dbm (master)  
66:  $ git push -u origin master  
67:  Username for 'http://192.168.31.166': albert_kuo  
68:  Password for 'http://albert_kuo@192.168.31.166':  
69:  Counting objects: 64, done.  
70:  Delta compression using up to 4 threads.  
71:  Compressing objects: 100% (34/34), done.  
72:  Writing objects: 100% (63/63), 10.12 KiB | 0 bytes/s, done.  
73:  Total 63 (delta 2), reused 0 (delta 0)  
74:  To http://192.168.31.166/ifmis/dbm.git  
75:    b45a8a4..4abf50e master -> master  
76:  Branch master set up to track remote branch master from origin.

See..my project skeleton had been commit

Import Git project into Eclipse
1. Copy url

2. File => Import => choose SCM type to "git" => paste url => Finish

3. Well done.




Do not have git connector when I want to Checkout Maven project from SCM

Problem
I would like to import Maven project from Git
File => import

Check out Maven Projects from SCM => Next

I do not have "git" option to select !

Solution
Install git connector

Window => Preferences

Maven => Discovery => Open Catalog

Check "m2e-egit" => Finish

After installation, click Yes to restart eclipse

File => import => Check out Maven Projects from SCM => Next
We have "git" option now!




2014/10/16

How to display Tradition Chinese Character in Git Bash

Problem
Why I cannot display Tradition Chinese Character in Git Bash correctly?

Solution
You need to edit three files under git\etc

1. edit gitconfig file and append configuration as following:
1:  [gui]  
2:  encoding = utf-8   
3:  #log编码  
4:  [i18n]  
5:  commitencoding = utf-8   
6:  #支持中文路径  
7:  [svn]  
8:  pathnameencoding = utf-8   

2. edit git-completion.bash file and append configuration  as following:
1:  #正常顯示中文  
2:  alias ls='ls --show-control-chars --color=auto'  

3. edit inputrc file and append configuration  as following:
1:  #bash中可以正常输入中文  
2:  set output-meta on   
3:  set convert-meta off  

Check Result

2014/04/02

SVN error on Eclipse: org.tigris.subversion.javahl.ClientException: Attempted to lock an already-locked dir

Problem
As I commit my source code to SVN in eclipse, but Eclipse shut down unexpectedly. After I launch Eclipse again, and try to commit again, it show this error message:




 org.apache.subversion.javahl.ClientException: Attempted to lock an already-locked dir  
 svn: Commit failed (details follow):  
 svn: Working copy 'D:\workspace\fms\fms-webapp\src\main\java\gov\nta\fms\web\controller' locked.  
 svn: 'D:\workspace\fms\fms-webapp\src\main\java\gov\nta\fms\web\controller' is already locked. 

Solution
Right click on the offending project, click Team and then select Refresh/Cleanup. SVN gets the offending .lock files and deletes them. 

cleanup D:/workspace/fms/fms-webapp/src/main/java  

After Refresh/Cleanup, I can commit source code successfully
commit -m "add 4 spaces for rptInfo parameter" D:/workspace/fms/fms-webapp/src/main/java/gov/nta/fms/web/controller/Fms406rReportController.java  
   Sending    D:/workspace/fms/fms-webapp/src/main/java/gov/nta/fms/web/controller/Fms406rReportController.java  
   Transmitting file data ...  
   Committed revision 1264.  

Reference

2010/10/12

Subversive Plug-in Installation




Install Subversive plug-in

1. open eclipse, Help-->Install New Software


2. Download Subversive from http://download.eclipse.org/technology/subversive/0.7/update-site/ . Choose required option to install.


3. Click Finish button.

4. Download in progress.

5. Restart eclipse


Install Subversive Connector

1. Choose SVN Kit

2. Click Next

3. Click Next

4. Select "I Accept....", click Next

5. Download in progress

6. Restart eclipse


Create Dynamic Web Project From SVN

1. File --> New --> Other

2. Select "Project From SVN", click Next

3. Choose "Create a new repository location", click Next

4. fill in SVN url, user name, and password

5. Click Finish


6. Click Finish

7. Choose Dynamic Web Project, Click Next

8. Assign project name and configuration

9. Click Next


10. Click Next

11. Click Next

12. WELL DONE!