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

Wednesday, July 22, 2015

Install - How to install ossec-hids-2.8

OSSEC is an Open Source Host-based Intrusion Detection System that performs log analysis, file integrity checking, policy monitoring, rootkit detection, real-time alerting and active response.
$ cd /usr/local/src/ossec-hids-2.8
$ ./install.sh

which: no host in (/sbin:/bin:/usr/sbin:/usr/bin)

  ** Para instalação em português, escolha [br].
  ** 要使用中文进行安装, 请选择 [cn].
  ** Fur eine deutsche Installation wohlen Sie [de].
  ** Για εγκατάσταση στα Ελληνικά, επιλέξτε [el].
  ** For installation in English, choose [en].
  ** Para instalar en Español , eliga [es].
  ** Pour une installation en français, choisissez [fr]
  ** A Magyar nyelvű telepítéshez válassza [hu].
  ** Per l'installazione in Italiano, scegli [it].
  ** 日本語でインストールします.選択して下さい.[jp].
  ** Voor installatie in het Nederlands, kies [nl].
  ** Aby instalować w języku Polskim, wybierz [pl].
  ** Для инструкций по установке на русском ,введите [ru].
  ** Za instalaciju na srpskom, izaberi [sr].
  ** Türkçe kurulum için seçin [tr].
  (en/br/cn/de/el/es/fr/hu/it/jp/nl/pl/ru/sr/tr) [en]:
-> enter

 You are about to start the installation process of the OSSEC HIDS.
 You must have a C compiler pre-installed in your system.
 If you have any questions or comments, please send an e-mail
 to dcid@ossec.net (or daniel.cid@gmail.com).

  - System: Linux hostname 2.6.32-431.23.3.el6.x86_64
  - User: root
  - Host: hostname


  -- Press ENTER to continue or Ctrl-C to abort. --
-> enter

What kind of installation do you want (server, agent, local, hybrid or help)
-> local

$ cd /var/ossec/bin
$ ./ossec-control start

Setting up ossec ui...

Username:
-> Input your id and password


Friday, July 3, 2015

Cordova - A error is ANDROID_HOME is not set

■ To deploy the application to the emulator from the command line:
■ There is a error like the following.
$ cordova emulate android
Running command: /Users/kim_woongjoon/git/hello/platforms/android/cordova/run --emulator
ERROR: Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.
Error: /Users/njoonk/git/hello/platforms/android/cordova/run: Command failed with exit code 2
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:755:16)
    at Process.ChildProcess._handle.onexit (child_process.js:822:5)


--------------------------SOLUTION----------------------------
■ Install Android Studio on your computer.
■ Add the following phrase to .profile on your mac.
$ vim ./.profile
## Android SDK
export ANDROID_HOME=/Users/njoonk/android-sdks
export PATH=$ANDROID_HOME/bin:$PATH


-----------------------------OUT---------------------------------
Built the following apk(s):
    /Users/njoonk/git/hello/platforms/android/build/outputs/apk/android-debug.apk
Installing app on emulator...
Using apk: /Users/njoonk/git/hello/platforms/android/build/outputs/apk/android-debug.apk
Launching application...
LAUNCH SUCCESS