上传到bintray时如何更改maven-metadata.xml的默认artifactId
How to change the default artifactId of maven-metadata.xml when uploading to bintray
在我的项目中,我为 maven POM 设置了自定义 artifactId:
install {
repositories.mavenInstaller {
pom {
project {
artifactId = moduleProperties.getProperty("module.artifactId")
...
}
}
}
}
其中 moduleProperties 是加载 属性 文件的属性 class。
使用此设置,POM 文件在 bintray 上具有 correct artifactId ("core"). However, the generated maven-metadata.xml 继续使用 Android-Studio 模块名称作为 artifactId ("transition")。所以问题是如何更改 maven-metadata.xml?
中的 artifactId
这是用于将工件推送到 bintray 的 gradle 代码:
/**
* JCenter publishing logic courtesy of https://www.virag.si/2015/01/publishing-gradle-android-library-to-jcenter/
*/
def siteUrl = 'https://github.com/kaichunlin/android-transition' // Homepage URL of the library
def gitUrl = 'https://github.com/kaichunlin/android-transition.git' // Git repository URL
group = "com.github.kaichunlin.transition" // Maven Group ID for the artifact
Properties moduleProperties = new Properties()
moduleProperties.load(project.file('module.properties').newDataInputStream())
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
// Add your description here
name moduleProperties.getProperty("module.pom_name")
artifactId = moduleProperties.getProperty("module.artifactId")
description moduleProperties.getProperty("module.desc")
url siteUrl
// Set your license
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'kaichunlin'
name 'Kai-Chun Lin'
email 'kaichun.lin@gmail.com'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def test = false
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
dryRun = test //Whether to run this as dry-run, without deploying
publish = !test //If version should be auto published after an upload
pkg {
repo = "maven"
name = moduleProperties.getProperty("module.bintray")
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = !test
version {
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
// passphrase = properties.getProperty("bintray.gpg.password") //Optional. The passphrase for GPG signing'
}
}
}
}
文件命名不正确。你有 transition-0.8.0.aar
,所以 artifactId
不可能是 core
。如果你想让一切都core
,你需要重命名项目,改变pom是不够的。
在我的项目中,我为 maven POM 设置了自定义 artifactId:
install {
repositories.mavenInstaller {
pom {
project {
artifactId = moduleProperties.getProperty("module.artifactId")
...
}
}
}
}
其中 moduleProperties 是加载 属性 文件的属性 class。
使用此设置,POM 文件在 bintray 上具有 correct artifactId ("core"). However, the generated maven-metadata.xml 继续使用 Android-Studio 模块名称作为 artifactId ("transition")。所以问题是如何更改 maven-metadata.xml?
中的 artifactId这是用于将工件推送到 bintray 的 gradle 代码:
/**
* JCenter publishing logic courtesy of https://www.virag.si/2015/01/publishing-gradle-android-library-to-jcenter/
*/
def siteUrl = 'https://github.com/kaichunlin/android-transition' // Homepage URL of the library
def gitUrl = 'https://github.com/kaichunlin/android-transition.git' // Git repository URL
group = "com.github.kaichunlin.transition" // Maven Group ID for the artifact
Properties moduleProperties = new Properties()
moduleProperties.load(project.file('module.properties').newDataInputStream())
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
// Add your description here
name moduleProperties.getProperty("module.pom_name")
artifactId = moduleProperties.getProperty("module.artifactId")
description moduleProperties.getProperty("module.desc")
url siteUrl
// Set your license
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'kaichunlin'
name 'Kai-Chun Lin'
email 'kaichun.lin@gmail.com'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def test = false
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
dryRun = test //Whether to run this as dry-run, without deploying
publish = !test //If version should be auto published after an upload
pkg {
repo = "maven"
name = moduleProperties.getProperty("module.bintray")
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = !test
version {
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
// passphrase = properties.getProperty("bintray.gpg.password") //Optional. The passphrase for GPG signing'
}
}
}
}
文件命名不正确。你有 transition-0.8.0.aar
,所以 artifactId
不可能是 core
。如果你想让一切都core
,你需要重命名项目,改变pom是不够的。