タイガー!タイガー!じれったいぞー!(SE編)

AS400, Java, JavaEE, JSF等の開発、習慣など。日々の気づきをまとめたブログ(備忘録)

【Nexus】アーカイブ・ファイルのアップロード

前回、CentOS7のServerにNexus(OSS版)を無事にインストールできましたので、今回は、実際にJarファイルのアップロードと別プロジェクトから取得する方法を試したいと思います。

まずは、アップロードから。
とりあえず、セキュリティ的な設定は、何もしていない状態でのテストになりますので、実運用では注意が必要です。

WebからのJarファイル・アップロード

まずは、自分たちが開発したファイルを格納すべき「releases」のリポジトリを選択し、Jarファイルをアップロードします。

「Artifact Upload」タブを選択し、下記のような情報を入力。

f:id:no14141:20150608081740j:plain

さらに下へ進めると、Upload用ボタンがあるので、アップロードしたいファイルを選択し、「Add Artifact」ボタンを押すと、「Upload Artifact(s)」ボタンが押せるようになり、アップロードされます。

f:id:no14141:20150608081747j:plain

結果は、「Browse Index」で確認できました!

f:id:no14141:20150608081754j:plain

GradleタスクからのJarファイル・アップロード

今度は、Eclipseのgradleからアップロードしてみます。

下記のような「build.gradle」を準備し、「uploadArchives」を実行しましたら、見事成功!!

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'

sourceCompatibility = 1.8
targetCompatibility = 1.8
jar.baseName = 'test'
archivesBaseName = 'test' 
version = '1.0'
group = 'tigertaizo'

repositories {
  mavenCentral()
}
    
dependencies {
  compile 'com.google.guava:guava:18.0'
  testCompile group: 'junit', name: 'junit', version: '4.+'
}

test {
  systemProperties 'property': 'value'
}

jar {
  manifest {
    attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version
    attributes "Main-Class" : "tigertaizo.Test03"
  }
  from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "http://192.168.1.10:8081/nexus/content/repositories/releases") { 
                authentication(userName: "admin", password: "**********")
            }
        }
    }
}

f:id:no14141:20150608081804j:plain

アップロード結果をWebで確認したところ、複数のファイルがアップロードされていることがわかりました。

f:id:no14141:20150608081815j:plain

いずれにしても、初期設定の状況ですが、簡単に共通ファイルをアップロードできることがわかりました。

次回は、Jarファイル取得方法について書きます。