Wednesday, August 26, 2015

Sonarqube - How to install and get start

■ Install sonar-runner
■ Make the directory
$ mkdir ~/sonarqube
$ cd ./sonarqube
■ Download the sonarqube-5.1.2.zip
$ wget https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-5.1.2.zip
■ Decompress the sonarqube-5.1.2.zip
$ unzip ./sonarqube-5.1.2.zip
■ Change the folder name
$ mv ./sonarqube-5.1.2 ./sonarqube
■ Install sonar-runner
■ Download the sonar-runner-dist-2.4.zip
$ wget http://repo1.maven.org/maven2/org/codehaus/sonar/runner/sonar-runner-dist/2.4/sonar-runner-dist-2.4.zip
■ Decompress the sonarqube-5.1.2.zip
$ unzip ./sonar-runner-dist-2.4.zip
■ Change the folder name
$ mv ./sonar-runner-2.4 ./sonar-runner
■ Add the following lines into the file /home/njoonk/.profile
export SONAR_RUNNER_HOME=/home/njoonk/sonarqube/sonar-runner
export PATH=$SONAR_RUNNER_HOME/bin:$PATH
■ Execute for applying
$ source ./.profile
■ Start web server
$ ${SONAR_HOME}/sonarqube/bin/macosx-universal-64/sonar.sh start

http://localhost:9000/

■ Add the following lines into build.gradle
apply plugin: 'org.sonarqube'

//./gradlew sonarqube
sonarqube {
    properties {
        property "sonar.projectName", "Java :: Utility Project :: Gradle Utility"
        property "sonar.projectKey", "$project.group:$project.name"
        property "sonar.language", "java"
        property "sonar.sourceEncoding", "UTF-8"
        property "sonar.junit.reportsPath", "${project.buildDir}/test-results"
        property "sonar.jacoco.reportPath", "${project.buildDir}/jacoco/test.exec"
    }
}
buildscript {
    repositories {
        mavenCentral()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
      classpath 'org.ajoberstar:gradle-jacoco:0.1.0'
      classpath 'org.sonarqube.gradle:gradle-sonarqube-plugin:1.0'
    }
}
■ Execute and analyze
$ gradle sonarqube
\Download https://plugins.gradle.org/m2/org/sonarqube/gradle/gradle-sonarqube-plugin/1.0/gradle-sonarqube-plugin-1.0.pom
Download https://repo1.maven.org/maven2/org/codehaus/sonar/runner/sonar-runner-api/2.4/sonar-runner-api-2.4.pom
Download https://repo1.maven.org/maven2/org/codehaus/sonar/runner/sonar-runner/2.4/sonar-runner-2.4.pom
Download https://repo1.maven.org/maven2/com/google/guava/guava/17.0/guava-17.0.pom
Download https://repo1.maven.org/maven2/com/google/guava/guava-parent/17.0/guava-parent-17.0.pom
Download https://plugins.gradle.org/m2/org/sonarqube/gradle/gradle-sonarqube-plugin/1.0/gradle-sonarqube-plugin-1.0.jar
Download https://repo1.maven.org/maven2/org/codehaus/sonar/runner/sonar-runner-api/2.4/sonar-runner-api-2.4.jar
Download https://repo1.maven.org/maven2/com/google/guava/guava/17.0/guava-17.0.jar
:compileJava
warning: [options] bootstrap class path not set in conjunction with -source 1.7
1 warning
:processResources UP-TO-DATE
:classes
:compileTestJava
warning: [options] bootstrap class path not set in conjunction with -source 1.7
1 warning
:processTestResources UP-TO-DATE
:testClasses
:test
:sonarqube
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: /home/njoonk/git/utility/build/sonar
INFO: SonarQube Server 5.1.2
01:11:20.009 INFO  - Load global repositories
01:11:20.213 INFO  - Load global repositories (done) | time=207ms
01:11:20.215 INFO  - Server id: 20150826001338
01:11:20.217 INFO  - User cache: /home/njoonk/.sonar/cache.
.
omission
.
01:11:30.764 INFO  - Analysis reports sent to server in 73ms
01:11:30.765 INFO  - ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/io.utility:utility
01:11:30.765 INFO  - Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report.

BUILD SUCCESSFUL
■ This is a sample.
https://github.com/minziappa/utility/blob/master/build.gradle

■ Reference
http://docs.sonarqube.org/display/SONAR/Analyzing+with+Gradle
https://github.com/SonarSource/sonar-examples/zipball/master

wget - How to install on Mac

■ the wget is not installed on Mac.
■ 1.15 higher version wasn't installed on Mac.
$ cd /usr/local/src
$ sudo curl -O http://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz
$ sudo tar xvf ./wget-1.15.tar.gz
$ sudo ./configure --with-ssl=openssl
$ make && make install

Tuesday, August 11, 2015

Vim - How to remove the ^M Line break?

■ When a script file can not be executed, because of ^M
$ ./startBatchSample.sh 

-bash: ./startBatchSample.sh: /bin/sh^M: bad interpreter: No such file or directory

■■ This is the solution. ■■
■ Change mode into Unix.
:set fileformat=unix


■ Change mode into Dos.(This is extra information.)
:set fileformat=dos

Monday, August 10, 2015

Gradle - [Fatal Error] jsp-* Already seen doctype.


■ When Refresh Dependencies was executed, the following error occurred.
BUILD SUCCESSFUL

Total time: 0.337 secs
[Fatal Error] jsp-api-2.1-6.1.14.pom:2:10: Already seen doctype.
[Fatal Error] jsp-2.1-6.1.14.pom:2:10: Already seen doctype.
[Fatal Error] servlet-api-2.5-6.1.14.pom:2:10: Already seen doctype.
[Fatal Error] jaxb-api-2.1.pom:2:10: Already seen doctype.
[Fatal Error] jasper-compiler-5.5.23.pom:2:10: Already seen doctype.
[Fatal Error] jasper-runtime-5.5.23.pom:2:10: Already seen doctype.
[Fatal Error] jsp-api-2.1-6.1.14.pom:2:10: Already seen doctype.
[Fatal Error] jsp-2.1-6.1.14.pom:2:10: Already seen doctype.
[Fatal Error] servlet-api-2.5-6.1.14.pom:2:10: Already seen doctype.
[Fatal Error] jasper-compiler-5.5.23.pom:2:10: Already seen doctype.
[Fatal Error] jasper-runtime-5.5.23.pom:2:10: Already seen doctype.

■ Before change
repositories {
    mavenLocal()
    mavenCentral()
}

■ After change
repositories {
    mavenCentral()
    mavenLocal()
}

■ Try to execute it again.
BUILD SUCCESSFUL

Total time: 0.653 secs

Wednesday, August 5, 2015

Git - How to resolve conflicts in Git

■ Check a status of conflicts in Git.
$ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 7 and 2 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

You have unmerged paths.
  (fix conflicts and run "git commit")

Unmerged paths:
  (use "git add <file>..." to mark resolution)

 both added:      .project

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

 modified:   .gitignore
 modified:   build.gradle

■ Edit a conflict file
 ○Before (conflicted code in a file)
<<<<<<< HEAD
sample_head
=======
sample_master
>>>>>>> master

 ○After (resolved code in a file)
<<<<<<< HEAD
sample_master
>>>>>>> master

■ Commit (You can resolve this by adding the file fixed)
$ git add .project
$ git commit

■ Check if it was fixed
$ git show | head
commit 2690c5f94cc2e9aaac6b3f17439a098ed537a311
Merge: b1bfeed 1c0394e
Author: kim_joon <kim_joon sample.io="">
Date:   Thu Jul 23 15:21:36 2015 +0900

    Merge branch 'master' of https://github.com/minziappa/neo4j_sample.git

    Conflicts:
     .project