LoginSignup
2
1

More than 3 years have passed since last update.

maven repogitory をgitlabのpagesで作成する。

Posted at

そもそもmavenリポジトリとは?

ビルド済みjarファイルのライブラリを配布するハブ空港みたいなもの。

今回はmavenセンターやjcenterなどの国際線空港を使わずに、gitlab pagesを使って自宅にヘリポートを作る試みです。

サーバーが自由に使えるならnexusなどを立ち上げればいいので、色々事情があって、gitlabプロジェクト単体でサポートしたい試みです。

mavenリポジトリの仕様はただの静的なwebページであることが最大のポイントです。実際にmaven deployせずに手動でnexusに登録することもできます。この仕組を再現する。つまり、mavenに頼らず、全てCIで管理する。

作ったもの

https://gitlab.com/akihirof0005/hello
で自動生成するリポジトリの
https://akihirof0005.gitlab.io/hello/
のURLです。

 やっていること

## 
dir=`pwd`
mkdir -p ./public/org

## latest version
sed -i -e 's/<version>.*replace-->$/<version>latest<\/version>/' pom.xml
mvn -Dmaven.repo.local=./repo/ clean install
mv ./repo/org/sample ./public/org

## javadoc
mvn javadoc:javadoc
mv ./target/site/apidocs ./public/

## releases version
json=`curl "https://gitlab.com/api/v4/projects/17557723/releases?private_token=$CI_DEPLOY_PASSWORD"`
len=$(echo $json | jq length)
for i in $( seq 0 $(($len - 1)) ); do
  version=$(echo $json | jq -r .[$i].name)
  link=$(echo $json | jq -r .[$i].assets.links)
  len2=$(echo $link | jq length)
  mkdir "$dir/public/org/sample/hello/$version"
  cd "$dir/public/org/sample/hello/$version"
  for k in $( seq 0 $(($len2 - 1)) ); do
    curl $(echo $link | jq -r .[$k].url) -o  $(echo $link | jq -r .[$k].name)
  done
done

## create index.html
cd "$dir/public"
curl "https://gist.githubusercontent.com/andyferra/2554919/raw/10ce87fe71b23216e3075d5648b8b9e56f7758e1/github.css" -o ./github.css
pandoc -s ../README.md -t html5 -c github.css -o ./index.html
echo "<html><body><h1>Directory listing:</h1>" >> ./index.html
find ./org/sample/hello/ -exec echo "<a href='{}'>{}</a><br/>" \; >> ./index.html
echo "</body></html>" >> ./index.html

 使ってみる

こちらから、gradleで検証した。

お願い

mavenリポジトリの仕様に詳しい方などいらしたら詳しいツッコミをお待ちしています。

2
1
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1