

Gradle 6.X 上传 aar 到 Nexus 私服
source link: https://xiaozhuanlan.com/topic/1892435067
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

昨天把 gradle 升级到 6.0 以后,发现这傻逼的 google 又直接干 API,以前上报的全部脚本都没法用了。我们原先上报一个 aar,是直接引入
apply plugin: 'maven'
结果新版本直接这个插件都被干掉了,看了官网文档以后才知道,换成了
apply plugin: 'maven-publish'
然后里面的API也全换掉了。
解决 sourcesJar Task 过时
然后 sourcesJar
的 task
也报了个警告,说classifier
已经过时了,以前代码是这样写的:
task sourcesJar(type: Jar) {
classifier = 'sources'
这个好解决,看一眼源码,要用 archiveClassifier
去替代:
* Sets the classifier.
* @deprecated Use {@link #getArchiveClassifier()}
@Deprecated
public void setClassifier(@Nullable String classifier) {
// This is used by the Kotlin plugin, we should upstream a fix to avoid this API first.
// DeprecationLogger.deprecateProperty(AbstractArchiveTask.class, "classifier").replaceWith("archiveClassifier").withDslReference().nagUser();
archiveClassifier.convention(classifier);
archiveClassifier.set(classifier);
内部就是做了个代理,改成了新API,就解决了。
task sourcesJar(type: Jar) {
archiveClassifier.convention('sources')
archiveClassifier.set('sources')
解决 maven plugin 过时
然后是上传的Task,以前的代码是这样写的
uploadArchives {
def object
repositories {
mavenDeployer {
pom.groupId = project.group
pom.artifactId = project.description
pom.version = LIB_VERSION
现在改成了可以用自定义 Task 来替代,例如:
publishing {
publications {
kymjs(MavenPublication) {
name = 'kymjs'
description = 'A concise description of my library'
url = 'http://www.kymjs.com/library'
properties = [
myProp: "value",
"prop.with.dots": "anotherValue"
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
developers {
developer {
id = 'johnd'
name = 'John Doe'
email = '[email protected]'
connection = 'scm:git:git://example.com/my-library.git'
developerConnection = 'scm:git:ssh://example.com/my-library.git'
url = 'http://kymjs.com/my-library/'
在之后就是查代码了,查看MavenPublication
类声明,原来就是以前的pom
对象做了个封装。
```
@HasInternalProtocol
public interface MavenPublication extends Publication {
/**
* The POM that will be published.
*
* @return The POM that will be published.
*/
MavenPom getPom();
* Configures the POM that will be published.
* The supplied action will be executed against the {@link #getPom()} result. This method also accepts a closure argument, by type coercion.
* @param configure The configuration action.
void pom(Action<? super MavenPom> configure);
* Provides the software component that should be published.
* <ul>
* <li>Any artifacts declared by the component will be included in the publication.</li>
* <li>The dependencies declared by the component will be included in the published meta-data.</li>
* </ul>
* Currently 3 types of component are supported: 'components.java' (added by the JavaPlugin), 'components.web' (added by the WarPlugin)
* and `components.javaPlatform` (added by the JavaPlatformPlugin).
* For any individual MavenPublication, only a single component can be provided in this way.
* The following example demonstrates how to publish the 'java' component to a Maven repository.
* <pre class='autoTested'>
* plugins {
* id 'java'
* id 'maven-publish'
* publishing {
* publications {
* maven(MavenPublication) {
* from components.java
* </pre>
* @param component The software component to publish.
void from(SoftwareComponent component);
Recommend
-
11
Flutter混合开发之打包aar并上传到nexus 今天我必须得写篇博客来记录下这“历史性”的时刻,耗时3天终于算是搞出来了。此时此刻只有一张图能形容我现在的状态。
-
7
Android Studio 打包及引用 aar – Android开发中文站你的位置:Android开发中文站 > Android开发 >
-
6
更新于 2021/08/8 | 创建于 2021/08/8 如何在flutter插件中使用本地aar库 当你使用Golang语言编写一个android安卓的库,并且编译为android的arr格式库时,你需要...
-
12
关于yum仓库往nexus私服传包等实践 如何配置一个yum私服,这个问题很早之前就已经研究过,博客也发表过此文章:使用nexus3配置yum私有仓库 (opens new window),只...
-
5
Create an Android Library (AAR)Steps to create an Android library, blockers while creating it and how to resolve themPhoto by
-
12
Sign in to GitHub · GitHub
-
24
-
8
通过Sonetype的nexus创建Maven私服 Nexus Repository 3.42.0 nexus/bin/excus.exe /install
-
8
Nexus-搭建软件包私服 - 麦奇
-
6
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK