Skip to content

Commit 7041ff1

Browse files
author
wangfeihang
committed
修复版本重复问题
1 parent ad9f3b2 commit 7041ff1

5 files changed

Lines changed: 23 additions & 7 deletions

File tree

localrepo/src/main/kotlin/com/yy/publish/PublishExtensionUtil.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ object PublishExtensionUtil {
2525
username = publishExtension.repoUserName
2626
password = publishExtension.repoPassword
2727
}
28-
if (publishExtension.sdkVersion.contains("SNAPSHOT")) {
28+
if (project.version.toString().contains("SNAPSHOT")) {
2929
setUrl("${publishExtension.snapshotRepo}")
3030
} else {
3131
setUrl("${publishExtension.releaseRepo}")
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.yy.publish.analyzer
2+
3+
/**
4+
* Created by wangfeihang on 2019-08-26.
5+
*/
6+
object DependenciesVersionUtil {
7+
fun getVersion(originVersion: String): String {
8+
return if (!originVersion.endsWith("-SNAPSHOT")) {
9+
"$originVersion-unionlocal-SNAPSHOT"
10+
} else {
11+
originVersion.subSequence(0, originVersion.indexOf("-SNAPSHOT")).toString() + "-unionlocal-SNAPSHOT"
12+
}
13+
}
14+
}

localrepo/src/main/kotlin/com/yy/publish/analyzer/DependencyAnalyzer.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ class DependencyAnalyzer(
7777

7878
val exclusions = dependency.getExclusions()
7979
val sdkVersion =
80-
if (isLocal.call(dependency) && dependency.version?.endsWith("-SNAPSHOT") == false) {
81-
dependency.version + "-SNAPSHOT"
80+
if (isLocal.call(dependency)) {
81+
DependenciesVersionUtil.getVersion(dependency.version ?: "")
8282
} else {
8383
dependency.version
8484
}

localrepo/src/main/kotlin/com/yy/publish/analyzer/PomAnalyzer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class PomAnalyzer(
7070
}
7171

7272
})
73-
val sdkVersion = if (local && !this.version.endsWith("-SNAPSHOT")) this.version + "-SNAPSHOT" else this.version
73+
val sdkVersion = if (local) DependenciesVersionUtil.getVersion(this.version) else this.version
7474
return UnionSdkInfo(
7575
groupId = this.groupId,
7676
artifactId = this.artifactId,

localrepo/src/main/kotlin/com/yy/publish/analyzer/SdkPathUtil.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ object SdkPathUtil {
5050
}
5151

5252
fun getSdkPomPath(project: Project, parentPath: String): String? {
53+
val fileCreateTime: Long = 0
54+
var file: File? = null
5355
project.fileTree(parentPath).forEach {
54-
if (it.name.endsWith(".pom")) {
55-
return it.absolutePath
56+
if (it.name.endsWith(".pom") && it.lastModified() > fileCreateTime) {
57+
file = it
5658
}
5759
}
58-
return null
60+
return file?.absolutePath
5961
}
6062
}

0 commit comments

Comments
 (0)