Skip to content

Commit 83c9f3d

Browse files
author
wangfeihang
committed
change log
1 parent ecfc34c commit 83c9f3d

4 files changed

Lines changed: 6 additions & 31 deletions

File tree

app/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
apply plugin: 'com.android.application'
22
apply plugin:'maven'
3+
apply plugin: 'local_repo'
34

45

56
repositories {
@@ -27,6 +28,8 @@ android {
2728
}
2829

2930
dependencies {
31+
// implementation 'com.github.wangfeihang:LocalRepo:1.0.0'
32+
3033
implementation fileTree(dir: 'libs', include: ['*.jar'])
3134
implementation 'com.android.support:appcompat-v7:27.1.1'
3235
implementation 'com.android.support.constraint:constraint-layout:1.1.3'

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ buildscript {
55
repositories {
66
google()
77
jcenter()
8+
maven { url 'https://jitpack.io' }
89
}
910
dependencies {
1011
classpath 'com.android.tools.build:gradle:3.1.3'
1112
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
13+
classpath 'com.github.wangfeihang:LocalRepo:1.0.0'
1214
// NOTE: Do not place your application dependencies here; they belong
1315
// in the individual module build.gradle files
1416
}

localrepo/src/main/groovy/com/yy/localrepo/GenerateRepoImpl.groovy

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,17 @@ public class GenerateRepoImpl implements Plugin<Project> {
3838
project.uploadArchives {
3939
repositories {
4040
mavenDeployer {
41-
println("wang mavenDeployer")
4241
//设置插件的GAV参数
4342
pom.groupId = groupId
44-
println("wang mavenDeployer wrong1")
4543
pom.artifactId = artifactId
46-
println("wang mavenDeployer wrong2")
4744
pom.version = sdkVersion
4845
//文件发布到下面目录
49-
println("wang mavenDeployer wrong3")
5046
repository(url: repoUri)
51-
println("wang mavenDeployer wrong4")
5247
pom.withXml {
53-
println("wang withXml ${asNode()}")
5448
getAllLocalDependency(project)
5549

5650

5751
Node dependenciesNode = asNode().getAt("dependencies")[0]
58-
println("wang withXml dependenciesNode ${dependenciesNode}")
5952
if (dependenciesNode != null) {
6053
dependenciesNode.replaceNode {}
6154
} else {
@@ -74,13 +67,9 @@ public class GenerateRepoImpl implements Plugin<Project> {
7467
def allDependencies = project.configurations[configurationName].allDependencies
7568
allDependencies.each {
7669

77-
println("wang ${it.group} ${it.name}")
78-
7970
def islocal = false
8071
localArtifacts.each { local ->
81-
println("islocal? ${it.group}:${it.name}:${it.version} ${local.moduleVersion}")
8272
if ("${it.group}:${it.name}:${it.version}" == local.moduleVersion.toString()) {
83-
println("islocal? true")
8473
islocal = true
8574
}
8675
}
@@ -106,7 +95,6 @@ public class GenerateRepoImpl implements Plugin<Project> {
10695
}
10796
}
10897

109-
println("wang withXml dependenciesNode 123 ${dependenciesNode}")
11098
repoArtifacts.each { repoArtifact ->
11199
boolean isAdded = false
112100
pomDependency.each {
@@ -115,7 +103,6 @@ public class GenerateRepoImpl implements Plugin<Project> {
115103
}
116104
}
117105
if (!isAdded) {
118-
println("wang add ${repoArtifact.moduleVersion} ")
119106
def dependencyNode = dependenciesNode.appendNode('dependency')
120107
dependencyNode.appendNode('groupId', repoArtifact.moduleVersion.id.group)
121108
dependencyNode.appendNode('artifactId', repoArtifact.moduleVersion.id.name)
@@ -124,21 +111,12 @@ public class GenerateRepoImpl implements Plugin<Project> {
124111

125112
}
126113
asNode().appendNode(dependenciesNode)
127-
println("wang withXml dependenciesNode 123456 ${dependenciesNode}")
128-
println("wang pom finish ${asNode()}")
129114
}
130115
}
131116
}
132117
project.uploadArchives.doLast {
133118
copyDependencyFile(project)
134119
}
135-
136-
137-
Upload uploadArchives = (Upload) project.getTasks().withType(Upload.class).findByName("uploadArchives")
138-
139-
if (uploadArchives != null) {
140-
println("wang get uploadArchives suc")
141-
}
142120
}
143121
}
144122

@@ -148,7 +126,6 @@ public class GenerateRepoImpl implements Plugin<Project> {
148126
if (allDependencies != null && !allDependencies.isEmpty()) {
149127
allDependencies.reverseEach {
150128
artifact ->
151-
println("getAllDependency, artifact:$artifact ${artifact.name}")
152129
if (isLocal(artifact) && !localArtifacts.contains(artifact)) {
153130
localArtifacts.add(artifact)
154131
}
@@ -160,13 +137,11 @@ public class GenerateRepoImpl implements Plugin<Project> {
160137
}
161138

162139
private void copyDependencyFile(Project project) {
163-
println("wang copyDependencyFile,${localArtifacts}")
164140
def libsPath = "$repo/${groupId.replace(".", "/")}/${artifactId}/${sdkVersion}/libs"
165141

166142
// delete "${libsPath}"
167143
localArtifacts.forEach {
168144
artifact ->
169-
println("localArtifacts $artifact ${artifact.file}")
170145
def artifactPath = artifact.file
171146
if (artifact.type == 'aar') {
172147
project.copy {
@@ -205,9 +180,6 @@ public class GenerateRepoImpl implements Plugin<Project> {
205180
}
206181
repoUri = project.uri(repo)
207182

208-
209-
210-
211183
initUpload(project)
212184
}
213185
}

localrepo/src/main/groovy/com/yy/localrepo/PluginImpl.groovy

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ public class PluginImpl implements Plugin<Project> {
1717
def local = project.configurations.localapi
1818

1919
local.dependencies.each { dependency ->
20-
println("wang dependency:$dependency")
2120
local.resolvedConfiguration.resolvedArtifacts.each { artifact ->
22-
println("wang dependency:${dependency.group}:${dependency.name}:${dependency.version}, artifact:${artifact.moduleVersion.toString()}")
2321
if ("${dependency.group}:${dependency.name}:${dependency.version}" == artifact.moduleVersion.toString()) {
2422
def libPath = "${artifact.file.parentFile.path}\\libs"
25-
println("wang truetrue,$libPath")
23+
println("localrepo, add depencies:$libPath")
2624
project.getRepositories().flatDir {
2725
dirs(libPath)
2826
}

0 commit comments

Comments
 (0)