sudo apt-get install openjdk-8-jre-headless
java入ってません。dart editorに必要なので入れる。

Java for OS X 2014-001から入れてもいいけど、brew cask
にあるのでそっちから。
$ brew cask install java6
jenkinsのlingr-pluginを使おうとして挫折したメモ。ローカルに最小限のjenkinsをセットアップし、echo Hello
するだけのjobを作って試してみました。
lingr appのapp_keyを得る
% irb -rdigest/sha1
>> Digest::SHA1.hexdigest('key' + 'secret')
=> "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Global Lingr SettingsにUserName, Password, AppKey, Roomを設定する。(これRoomにパスワードかかってる場合はどうなるんだろう?)

Build Nowしてみると、

app_keyが無いって言われちゃう。
lingr-pluginをデバッグしてみようと思い、公式reposからcloneしてきてbuildしようと試みる。
% cit clone git://github.com/jenkinsci/lingr-plugin.git
% cd lingr-plugin
% mvn test
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.jenkins-ci.plugins:lingr-plugin:hpi:0.2-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for com.cloudbees:maven-license-plugin is missing. @ org.jenkins-ci.plugins:plugin:1.420, /Users/komagata/.m2/repository/org/jenkins-ci/plugins/plugin/1.420/plugin-1.420.pom, line 191, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building lingr-plugin 0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.yoshiori.lingr:lingr-bot:jar:0.1 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.782s
[INFO] Finished at: Sun Feb 24 20:36:52 JST 2013
[INFO] Final Memory: 9M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project lingr-plugin: Could not resolve dependencies for project org.jenkins-ci.plugins:lingr-plugin:hpi:0.2-SNAPSHOT: Failure to find org.yoshiori.lingr:lingr-bot:jar:0.1 in http://maven.jenkins-ci.org/content/groups/artifacts/ was cached in the local repository, resolution will not be reattempted until the update interval of maven.jenkins-ci.org has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
org.yoshiori.lingrのlingr-botが取れないみたいです。lingr-botの方も自前でbuildして、mvn install:install-fileで入れてみてからbuildしても駄目。(色々足りないエラーが出る)
とりあえずmavenを初めて使った俺のjavaスキルじゃ疲れたので一旦休憩しまーす。
ところでmavenって「めいぶん?」「めいゔぁん?」
のを直してプルリク送った。採用されよ。
phonegap-plugins/Android at master · phonegap/phonegap-plugins · GitHub
javaのpull requestはじめてだ。
cordova1.9.0からそれまではctxって名前だったcontextオブジェクトがcordovaって名前になっててちょっと変わったので変更する必要有り。
masterではLegacyContextって名前でproxy的Contextが入ってるので1.9.1では動くようになるだろうけど、今後contextはcordovaって方向らしいので。
怖話はスマホ向けWebサイトです。今のスマホのHTML5 Audioではサウンドノベル風に音を鳴らすのが難しいのでcordovaでアプリ版を作っています。
しかし、サーバー側で普通のブラウザからのアクセスなのか、cordovaからのアクセスなのか区別がつかない。数ページ程度だったらquery stringにでも何か付けてアクセスするようにすればいいけど、怖話はサイト全体に渡ってどちらからもアクセスされる可能性があるのでcookieが使えないガラケーのようなquery string引き回しなどはやりたくない。
StackOverflow駆け込み寺に問い合わせたところ、10minで答えが来た。
「cordovaのソース弄ってヘッダ追加すれば?」
なるほどですねー!
% git diff
diff --git a/framework/src/org/apache/cordova/DroidGap.java b/framework/src/org/apache/cordova/DroidGap.java
index 5e2586d..dfbdb44 100755
--- a/framework/src/org/apache/cordova/DroidGap.java
+++ b/framework/src/org/apache/cordova/DroidGap.java
@@ -562,7 +562,9 @@ public class DroidGap extends Activity implements CordovaInterface {
};
Thread thread = new Thread(runnable);
thread.start();
- me.appView.loadUrl(url);
+ HashMap headers = new HashMap();
+ headers.put("X-Access-From-Cordova", "true");
+ me.appView.loadUrl(url, headers);
}
});
}
X-Access-From-Cordovaという勝手なヘッダを付けて、以前のエントリー通りcordovaをbuildして自分のプロジェクトに放り込む。
サーバー側(Rails)に下記helperを追加。
# app/helpers/application_helper.rb
module ApplicationHelper
def cordova?
request.headers['X-Access-From-Cordova'] == 'true'
end
end
神様仏様StackOverflow大明神様 <3 <3 <3
README通りで問題無い。
commons codecをdownload
% cd ~/Downloads
% curl -OL http://ftp.meisei-u.ac.jp/mirror/apache/dist//commons/codec/binaries/commons-codec-1.6-bin.tar.gz
% tar zxf commons-codec-1.6-bin.tar.gz
cordova android版をbuild
% git clone https://github.com/apache/incubator-cordova-android.git
% cd incubator-cordova-android/framework
% cp ~/Downloads/commons-codec-1.6/commons-codec-1.6.jar libs/
% android update project -p . -t android-15
% ant jar
% ls cordova*.jar
cordova-1.7.0.jar
やったネ。
;; project.clj
(defproject bar "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.2.1"]]
:main bar.core)
:mainでnamespaceを指定しておくと$ lein run -m bar.core
みたいにイチイチ指定しなくていい。
;; src/bar/core.clj
(ns bar.core
(:gen-class))
(defn -main []
(println "unk"))
スタンドアローンで実行できるjarを作るには:gen-class
の指定と-main関数が必要。
まずそのまま実行してみる。
% lein run
Picked up _JAVA_OPTIONS: -Dfile.encoding=UTF-8
Picked up _JAVA_OPTIONS: -Dfile.encoding=UTF-8
unk
(このJAVAのOPTIONがイチイチ表示されるの何とかならないかな・・・)
% lein uberjar
ドイツ人の@mreinschさんによるとuberとはbeyondとかaboveの意味だそうです。(それでもよく分からないけど)
bar-1.0.0-SNAPSHOT-standalone.jarとbar-1.0.0-SNAPSHOT.jarが出来ていました。jar tvfで中身を見てみると、無印の方はこのプロジェクトのモノだけ。-standaloneの方は依存jar(clojure自身を含む)が全部入ったやつみたいです。
% java -jar bar-1.0.0-SNAPSHOT-standalone.jar
Picked up _JAVA_OPTIONS: -Dfile.encoding=UTF-8
unk
OMG!
Windows XPに持って行って実行してみると・・・
(^q^)