Grdle版本的不同导致的一些差异

文章讲述了在升级Gradle版本从6.3到7.3.3后,对项目中的Kotlin配置和上传Maven方式产生的影响。对于Kotlin,不再需要在app的build.gradle中显式依赖kotlin-stdlib-jdk8,但在低版本kotlin插件中可能需要手动导入。对于Maven上传,旧的maven插件已替换为maven-publish,并更新了发布配置的语法结构。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

gradle版本是不断迭代升级的,升级后对有些配置是有影响的,比如对kotlin配置、上传maven的方式,特此记录一下

对kotlin配置的影响

我们主项目的gradle版本是6.3,对项目进行koltin配置的语法了,官方文档教程是一样的
在这里插入图片描述
新建的项目gradle版本号是7.3.3

在这里插入图片描述
在这里插入图片描述
首先语法结构进行了调整,这个关系不大。最大的地方是,app的build.gradle中不用再依赖
implementation ‘org.jetbrains.kotlin:kotlin-stdlib-jdk8:x.x.xx’
因为会自动依赖的
但是,打成aar包为了兼容别的项目需要kotlin插件版本改成1.3.72,结果一build就报错
在这里插入图片描述
可能是低版本的koltin插件不会自动导入kotlin-stdlib包吧,需要自己手动导入一下
implementation ‘org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72’
再build就正常了。

参考

将 Kotlin 添加到现有应用

对上传maven的方式的影响

之前的方式是

apply plugin: 'maven'

boolean isRelease = false

uploadArchives {
    repositories {
        mavenDeployer {
            if (isRelease) {
                repository(url: 'http://10.xx.xx.60:8081/repository/maven-releases/') {
                    authentication(userName: 'admin', password: 'xxxx')
                }

                pom.project {
                    version gradle.ext.versionName
                    artifactId 'sohuPush'
                    groupId 'com.sohu.sohuPush'
                    packaging 'aar'
                    description 'SohuVideo com.sohu.sohuPush'
                }
            } else {
                snapshotRepository(url: 'http://10.xx.xxx.60:8081/repository/maven-snapshots/') {
                    authentication(userName: 'deployment', password: 'xxxx')
                }

                pom.project {
                    version gradle.ext.versionName + "-SNAPSHOT"
                    artifactId 'sohuPush'
                    groupId 'com.sohu.sohuPush'
                    packaging 'aar'
                    description 'SohuVideo com.sohu.sohuPush'
                }
            }

        }
    }
}

现在语法变了

apply plugin: 'maven-publish'

boolean isRelease = false

afterEvaluate {
    publishing {
        publications {
            maven(MavenPublication) {
                groupId = 'com.sohu.clipImage'
                artifactId = 'clipImage'
                if (isRelease) {
                    version = gradle.ext.versionName
                    from components.release
                } else {
                    version = gradle.ext.versionName + "-SNAPSHOT"
                    from components.debug
                }
                description 'SohuVideo com.sohu.clipImage'
            }
        }
        repositories {
            maven {
                if (isRelease) {
                    allowInsecureProtocol = true
                    url = 'http://10.xx.xxx.60:8081/repository/maven-releases/'
                    credentials {
                        it.username = 'admin'
                        it.password = 'xxxxx'
                    }
                } else {
                    allowInsecureProtocol = true
                    url = 'http://10.xx.xxx.60:8081/repository/maven-snapshots/'
                    credentials {
                        it.username = 'deployment'
                        it.password = 'xxxxxx'
                    }
                }

            }
        }
    }
}

参考

Plugin with id ‘maven’ not found.
maven-publish插件的使用
Plugin with id ‘maven’ not found
Plugin with id ‘maven‘ not found或者Plugin [id: ‘maven‘] was not found in any of the following sources
Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven…

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值