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

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…

猜你喜欢

转载自blog.csdn.net/lizhongyisailang/article/details/131302568