2015年9月6日日曜日

Android Studio 移行

Eclipse ADT から Android Studio へプロジェクトを移行する。

Android Studio インストール

Android Studio for Windows をダウンロード。
https://developer.android.com/sdk/index.html

エクスプローラでダウンロードした exe ファイルを実行してインストール。

プロジェクト設定

「File」「New」「New Project」
Application name: sampleApp
Company Domain: s6131.jp
Phone and Tablet Minimum SDK API 19: Android 4.4 (KitKat)
Brank Activity
Activity Name その他デフォルト
として「Finish」して新規プロジェクト作成。

「c:\pleiades.old\workspace\sampleApp」から必要ファイルをエクスプローラでコピー。
ウィザードで作成された、同ディレクトリの不要ファイルは削除する。
AndroidMainifest.xml
jp/s6131/sampleApp/*.java
res/*

Android SDK 設定

「Tools」「Android」「SDK Manager」
Android 5.1 (Lolipop) API Level 22 にチェック、OK 押下してインストール。

Gradle 設定

build.gradle (Module: app) を編集する。
apply plugin: 'com.android.application'
android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
    defaultConfig {
        applicationId "jp.s6131.sampleApp"
        minSdkVersion 19
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:22.2.1'
        compile group: 'com.google.android', name: 'android', version: '4.1.1.4'
        compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.5'
        compile group: 'org.springframework.android', name: 'spring-android-core', version: '2.0.0.M1'
        compile(group: 'org.springframework.android', name: 'spring-android-rest-template', version: '2.0.0.M1') {
            exclude(module: 'spring-core')
        }
        compile(group: 'org.springframework.android', name: 'spring-android-auth', version: '2.0.0.M1') {
            exclude(module: 'spring-core')
        }
        compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.2.3'
    }
}

Android AVD 設定

「Tools」「Android」「AVD Manager」「Create Virtual Device...」
Nexus 6、Lollipop を選択して Finish。
Launch ボタンを押下して起動する。

hosts ファイルを準備。
127.0.0.1  localhost
10.0.2.2   www.s6131.jp

コマンドプロンプト(管理者)で以下を実行して hosts 転送。
AVD 起動毎に必要。
cd C:\Users\ユーザ名\AppData\Local\Android\sdk\platform-tools
adb remount
adb push hosts /system/etc/

「run」「Debug 'app'」でアプリ起動する。

2015年8月22日土曜日

Pleiades Mars 64bit Java 移行 (Gradle 移行)

Luna から Mars へプロジェクトを移行する。

Pleiades Mars インストール

c:\pleiades を c:\pleiades.old にリネーム

Pleiades Mars 64bit Java Full Edition をダウンロード。
http://mergedoc.sourceforge.jp/index.html#/pleiades.html

エクスプローラでダウンロードした zip ファイルを選択し、中にある pleiades ディレクトリを c:\ へD&Dして解凍。

STS インストール

「ヘルプ」「Eclipse マーケットプレース」
「検索」で「STS」を検索
「Spring Tool Suite (STS) for Eclipse 3.7.0.RELEASE」をインストール

Jacoco プラグインインストール

http://s6131.blogspot.jp/2014/03/java-jacoco.html

Gradle インストール

gradle-2.6-all.zip をダウンロード
https://gradle.org/
エクスプローラでダウンロードした zip ファイルを選択し、中にある gradle-2.6 ディレクトリを c:\ へD&Dして解凍。

コントロールパネル→システム→システムの詳細設定→環境変数→システム環境変数
Path の先頭に c:\gradle-2.6\bin; を追加

Gradle プロジェクト設定

「ファイル」「新規」「その他」「Gradle」「Gradle プロジェクト」
プロジェクト名 sample として「完了」

sample プロジェクトを選択している状態で、「ファイル」「インポート」

「一般」「ファイル・システム」「参照」で「c:\pleiades.old\workspace\sample」を指定
「src」ディレクトリのみを選択してインポートを実行する。

sample プロジェクト右クリック、「プロパティ」
「Java のビルド・パス」「ソース」タブで「フォルダの追加」
src/main/resources
src/test/resources

build.gradle を編集
// Apply the java plugin to add support for Java
def defaultEncoding = 'UTF-8'
apply plugin: 'war'
apply plugin: 'eclipse'
apply plugin: 'eclipse-wtp'
group = 'jp.s6131'
version = '1.0.0-BUILD-SNAPSHOT'
description = """sample"""
sourceCompatibility = 1.8
targetCompatibility = 1.8
// In this section you declare where to find the dependencies of your project
repositories {
    // Use 'jcenter' for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}
// In this section you declare the dependencies for your production and test code
dependencies {
    compile(group: 'org.springframework', name: 'spring-context', version:'4.0.5.RELEASE') {
        exclude(module: 'commons-logging')
    }
    compile group: 'org.springframework', name: 'spring-context-support', version:'4.0.5.RELEASE'
    compile group: 'org.springframework', name: 'spring-webmvc', version:'4.0.5.RELEASE'
    compile group: 'org.springframework', name: 'spring-jdbc', version:'4.0.5.RELEASE'
    compile group: 'org.springframework', name: 'spring-test', version:'4.0.5.RELEASE'
    compile group: 'org.springframework.security', name: 'spring-security-web', version:'3.2.3.RELEASE'
    compile group: 'org.springframework.security', name: 'spring-security-config', version:'3.2.3.RELEASE'
    compile group: 'org.springframework.batch', name: 'spring-batch-core', version:'2.2.5.RELEASE'
    compile group: 'commons-dbcp', name: 'commons-dbcp', version:'1.2.2'
    compile group: 'c3p0', name: 'c3p0', version:'0.9.1.2'
    compile group: 'org.apache.velocity', name: 'velocity', version:'1.7'
    compile group: 'org.aspectj', name: 'aspectjrt', version:'1.8.0'
    compile group: 'org.mybatis', name: 'mybatis', version:'3.2.4'
    compile group: 'org.mybatis', name: 'mybatis-spring', version:'1.2.2'
    compile group: 'mysql', name: 'mysql-connector-java', version:'5.1.29'
    compile group: 'org.codehaus.jackson', name: 'jackson-core-asl', version:'1.9.13'
    compile group: 'org.codehaus.jackson', name: 'jackson-mapper-asl', version:'1.9.13'
    compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.7'
    compile group: 'javax.inject', name: 'javax.inject', version:'1'
    compile group: 'javax.servlet', name: 'jstl', version:'1.2'
    compile group: 'org.apache.poi', name: 'poi', version:'3.10-FINAL'
    compile group: 'org.dbunit', name: 'dbunit', version:'2.4.9'
    runtime group: 'org.slf4j', name: 'jcl-over-slf4j', version:'1.7.7'
    runtime group: 'org.slf4j', name: 'slf4j-log4j12', version:'1.7.7'
    runtime(group: 'log4j', name: 'log4j', version:'1.2.15') {
        exclude(module: 'mail')
        exclude(module: 'jms')
        exclude(module: 'jmxtools')
        exclude(module: 'jmxri')
    }
    testCompile group: 'junit', name: 'junit', version:'4.7'
    providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
    providedCompile 'javax.servlet.jsp:jsp-api:2.2'
}

コマンドプロンプトを実行、gradle を実行する。
cd \pleiades\workspace\sample
gradle eclipse

「ウィンドウ」「ビューの表示」「その他」「サーバー」で「サーバー」表示、
Tomcat8 サーバーを作成、sample プロジェクトを追加する。

Tomcat サーバーを起動し、Luna 時と同動作をする事を確認。