0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GradleでNexus Repository Managerに作ったリポジトリをアップロードする

Last updated at Posted at 2019-02-16
apply plugin: 'maven-publish'

でプラグインを追加して

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
            artifact sourceJar {
                classifier 'sources'
            }
        }
    }
    repositories {
        def properties = new Properties()
        file('secret.properties').withInputStream { properties.load(it) }
        maven {
            url properties.getProperty 'url'
            credentials {
                username = properties.getProperty 'username' 
                password = properties.getProperty 'password' 
            }
        }
    }
}

これをbuild.gradleに追加します
こうすると、secret.propertiesからユーザー名・パスワード・URLを読み込んでpublishできるようになります

username=ユーザー名
password=パスワード
url=URL

URLに関してですが、
設定からリポジトリを選択して、URLが書かれてると思うのでそれをコピペしてください。
Screenshot_20190216_212304.png
上の画像のURL(黒く塗りつぶされてるのがあるやつです)

gradle publish

でエラーが出なかったら成功です。
Gitとかでやってるときはくれぐれもsecret.propertiesをアップロードしないように、.gitignoreに加えておいてください。
環境変数とかから読み込むようにするのも良いかと思います

0
2
0

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
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?