Skip to content

Commit b609401

Browse files
committed
check style
1 parent 3ce0fbe commit b609401

File tree

7 files changed

+290
-73
lines changed

7 files changed

+290
-73
lines changed

.github/workflows/superlinter.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/upload.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
name: Android CI
3+
4+
on:
5+
push:
6+
pull_request:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Set up JDK 1.8
15+
uses: actions/setup-java@v1
16+
with:
17+
java-version: '1.8'
18+
- name: Publish to Sonatype
19+
env:
20+
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
21+
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
22+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master'}}
23+
run: ./gradlew clean build uploadArchives -PNEXUS_USERNAME="${NEXUS_USERNAME}" -PNEXUS_PASSWORD="${NEXUS_PASSWORD}"

gradle.properties

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,21 @@
1717
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1818
# org.gradle.parallel=true
1919
android.enableJetifier=true
20-
android.useAndroidX=true
20+
android.useAndroidX=true
21+
22+
23+
VERSION_NAME=2.3.1
24+
VERSION_CODE=11
25+
GROUP=io.github.cpacm
26+
27+
POM_DESCRIPTION=A simple slider allows you to easily use.
28+
POM_DEVELOPER_EMAIL=shenliming@gmail.com
29+
POM_URL=https://github.com/cpacm/SimpleSlider
30+
POM_SCM_URL=https://github.com/cpacm/SimpleSlider
31+
POM_SCM_CONNECTION=scm:git@github.com:cpacm/SimpleSlider.git
32+
POM_SCM_DEV_CONNECTION=scm:git@github.com:cpacm/SimpleSlider.git
33+
POM_LICENCE_NAME=The Apache Software License, Version 2.0
34+
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
35+
POM_LICENCE_DIST=repo
36+
POM_DEVELOPER_ID=cpacm
37+
POM_DEVELOPER_NAME=cpacm

library/build.gradle

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
apply plugin: 'com.android.library'
22

3-
version = '2.3.1'
4-
53
android {
64
compileSdkVersion 30
75

@@ -26,48 +24,5 @@ dependencies {
2624
}
2725

2826

29-
30-
//group = 'com.cpacm.simpleslider'
31-
//install {
32-
// repositories.mavenInstaller {
33-
// pom.project {
34-
// packaging 'aar'
35-
// groupId 'com.cpacm.simpleslider' //自己定义的组名
36-
// artifactId 'library'
37-
//
38-
// name 'simpleslider'
39-
// description 'A simple slider allows you to easily use.'
40-
// url 'https://github.com/cpacm/SimpleSlider'
41-
// inceptionYear '2017'
42-
//
43-
// licenses {
44-
// license {
45-
// name 'The Apache Software License, Version 2.0'
46-
// url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
47-
// distribution 'repo'
48-
// }
49-
// }
50-
// scm {
51-
// connection 'https://github.com/cpacm/SimpleSlider.git'
52-
// url 'https://github.com/cpacm/SimpleSlider'
53-
//
54-
// }
55-
// developers {
56-
// developer {
57-
// name 'cpacm'
58-
// email 'shenliming1013@gmail.com'
59-
// }
60-
// }
61-
// }
62-
//
63-
// }
64-
//}
65-
66-
// Bintray
67-
68-
//获取local.propertes的信息
69-
//Properties properties = new Properties()
70-
//properties.load(project.rootProject.file('local.properties').newDataInputStream())
71-
72-
27+
apply from: "${rootProject.projectDir}/script/upload.gradle"
7328

library/gradle.properties

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
POM_NAME=SimpleSlider
2+
POM_ARTIFACT_ID=simpleslider
3+
POM_PACKAGING=aar
4+
5+
# Prefix and postfix for source and javadoc jars.
6+
JAR_PREFIX=
7+
JAR_POSTFIX=

library/src/main/java/com/cpacm/library/infinite/InfinitePagerAdapter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
/**
1212
* A PagerAdapter that wraps around another PagerAdapter to handle paging wrap-around.
13-
* <p/>
1413
*/
1514
public class InfinitePagerAdapter extends PagerAdapter {
1615

script/upload.gradle

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
/*
2+
* Copyright 2013 Chris Banes
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*
17+
* Based on: https://github.com/mcxiaoke/gradle-mvn-push/blob/master/gradle-mvn-push.gradle.
18+
*
19+
* To install in a local maven repo:
20+
* 1. In the project you want to test (not Glide), add mavenLocal() to the repositories list.
21+
* 2. In Glide, run: ./gradlew uploadArchives -PLOCAL
22+
*
23+
* For faster runs add: -x check when building Glide.
24+
*/
25+
26+
apply plugin: 'maven'
27+
apply plugin: 'signing'
28+
29+
version = VERSION_NAME
30+
group = GROUP
31+
32+
static def localMavenRepo() {
33+
'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath
34+
}
35+
36+
@SuppressWarnings("GrMethodMayBeStatic")
37+
def isReleaseBuild() {
38+
return !VERSION_NAME.contains("SNAPSHOT")
39+
}
40+
41+
def getReleaseRepositoryUrl() {
42+
return hasProperty('LOCAL') ? localMavenRepo()
43+
: hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
44+
//: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
45+
: 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
46+
}
47+
48+
def getSnapshotRepositoryUrl() {
49+
return hasProperty('LOCAL') ? localMavenRepo()
50+
: hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
51+
//: 'https://oss.sonatype.org/content/repositories/snapshots/'
52+
: 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
53+
}
54+
55+
def getRepositoryUsername() {
56+
return hasProperty('USERNAME') ? USERNAME : (hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : '')
57+
}
58+
59+
def getRepositoryPassword() {
60+
return hasProperty('PASSWORD') ? PASSWORD : (hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : '')
61+
}
62+
63+
afterEvaluate { project ->
64+
def isAndroidProject = project.plugins.hasPlugin('com.android.application') || project.plugins.hasPlugin('com.android.library')
65+
// To avoid uploading the default empty jar artifact in the project root directory, we use a custom
66+
// configuration to specify which artifacts we want to upload.
67+
uploadArchives {
68+
repositories {
69+
mavenDeployer {
70+
// allow uploading through FTP protocol with the following command:
71+
// gradle uploadArchives -PSNAPSHOT_REPOSITORY_URL=ftp://host/repo/path -PUSERNAME=uname -PPASSWORD=passwd
72+
configuration = configurations.create('deployerJars')
73+
configuration.dependencies.add dependencies.create('org.apache.maven.wagon:wagon-ftp:2.2')
74+
75+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
76+
77+
pom.groupId = GROUP
78+
pom.artifactId = POM_ARTIFACT_ID
79+
pom.version = VERSION_NAME
80+
81+
repository(url: getReleaseRepositoryUrl()) {
82+
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
83+
}
84+
snapshotRepository(url: getSnapshotRepositoryUrl()) {
85+
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
86+
}
87+
88+
pom.whenConfigured { pom ->
89+
pom.packaging = POM_PACKAGING
90+
}
91+
92+
// Dependencies are only automatically included by the release plugin if the release
93+
// variant is built. Since we've disabled the release variant to improve build
94+
// times, we need to add the dependencies to the pom file explicitly.
95+
if (isAndroidProject) {
96+
pom.withXml {
97+
def dependenciesNode = asNode().appendNode('dependencies')
98+
99+
project.configurations.implementation.allDependencies.each {
100+
def groupId = it.group
101+
def artifactId = it.name
102+
// If we specify an artifact id that differs from the project name, it won't
103+
// match. To avoid that, we look up the artifact id (and group) by property
104+
// for any project dependencies.
105+
// TODO: there must be a neater way to do this.
106+
if (it instanceof ProjectDependency) {
107+
def properties = it.getDependencyProject().getProperties()
108+
groupId = properties.get("GROUP")
109+
artifactId = properties.get("POM_ARTIFACT_ID")
110+
}
111+
def dependencyNode = dependenciesNode.appendNode('dependency')
112+
dependencyNode.appendNode('groupId', groupId)
113+
dependencyNode.appendNode('artifactId', artifactId)
114+
dependencyNode.appendNode('version', it.version)
115+
dependencyNode.appendNode('scope', 'compile')
116+
}
117+
}
118+
}
119+
120+
pom.project {
121+
name = POM_NAME
122+
description = POM_DESCRIPTION
123+
url = POM_URL
124+
125+
scm {
126+
url POM_SCM_URL
127+
connection POM_SCM_CONNECTION
128+
developerConnection POM_SCM_DEV_CONNECTION
129+
}
130+
131+
licenses {
132+
license {
133+
name = 'Simplified BSD License'
134+
url = 'http://www.opensource.org/licenses/bsd-license'
135+
distribution = 'repo'
136+
}
137+
license {
138+
name = 'The Apache Software License, Version 2.0'
139+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
140+
distribution = 'repo'
141+
}
142+
}
143+
144+
developers {
145+
developer {
146+
id = POM_DEVELOPER_ID
147+
name = POM_DEVELOPER_NAME
148+
email = POM_DEVELOPER_EMAIL
149+
}
150+
}
151+
}
152+
}
153+
}
154+
}
155+
156+
signing {
157+
required { isReleaseBuild() && gradle.taskGraph.hasTask('uploadArchives') }
158+
sign configurations.archives
159+
}
160+
161+
162+
if (isAndroidProject) {
163+
def variants = project.android.libraryVariants.findAll {
164+
it.buildType.name.equalsIgnoreCase('debug')
165+
}
166+
167+
def getAndroidSdkDirectory = project.android.sdkDirectory
168+
169+
def getAndroidJar = "${getAndroidSdkDirectory}/platforms/${project.android.compileSdkVersion}/android.jar"
170+
171+
task androidJavadocs(type: Javadoc, dependsOn: assembleDebug) {
172+
source = variants.collect { it.getJavaCompileProvider().get().source }
173+
classpath = files(
174+
getAndroidJar,
175+
project.file("build/intermediates/classes/debug")
176+
)
177+
doFirst {
178+
classpath += files(variants.collect { it.javaCompile.classpath.files })
179+
}
180+
options {
181+
links("http://docs.oracle.com/javase/7/docs/api/")
182+
linksOffline("http://d.android.com/reference",
183+
"${getAndroidSdkDirectory}/docs/reference")
184+
}
185+
186+
exclude '**/R.java'
187+
}
188+
189+
def cleanJavadocTask = task("cleanJavadocTask", type: Delete) {
190+
delete androidJavadocs.destinationDir
191+
} as Task
192+
project.clean.dependsOn(cleanJavadocTask)
193+
194+
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
195+
classifier = 'javadoc'
196+
from androidJavadocs.destinationDir
197+
baseName "${JAR_PREFIX}${project.name}${JAR_POSTFIX}"
198+
}
199+
200+
task androidSourcesJar(type: Jar) {
201+
classifier = 'sources'
202+
from project.android.sourceSets.main.java.source
203+
baseName "${JAR_PREFIX}${project.name}${JAR_POSTFIX}"
204+
}
205+
206+
task androidLibraryJar(type: Jar, dependsOn: compileDebugJavaWithJavac /* == variant.javaCompile */) {
207+
from compileDebugJavaWithJavac.destinationDir
208+
exclude '**/R.class'
209+
exclude '**/R$*.class'
210+
baseName "${JAR_PREFIX}${project.name}${JAR_POSTFIX}"
211+
}
212+
213+
artifacts {
214+
archives androidLibraryJar
215+
archives androidSourcesJar
216+
archives androidJavadocsJar
217+
// This is unnecessary with a release variant because by default the release variant
218+
// includes the release aar in archives. Since we've disabled our release variants and
219+
// want to include an aar, we need to manually specify the task that produces the aar
220+
// here.
221+
archives project.tasks.bundleDebugAar
222+
}
223+
} else if (project.plugins.hasPlugin('java')) {
224+
task sourcesJar(type: Jar, dependsOn: classes) {
225+
classifier = 'sources'
226+
from sourceSets.main.allSource
227+
}
228+
229+
task javadocsJar(type: Jar, dependsOn: javadoc) {
230+
classifier = 'javadoc'
231+
from javadoc.destinationDir
232+
}
233+
234+
artifacts {
235+
archives sourcesJar
236+
archives javadocsJar
237+
}
238+
}
239+
logger.info("Published artifacts in ${configurations.archives}:")
240+
configurations.archives.artifacts.files.files.each { logger.info("\t$it") }
241+
}

0 commit comments

Comments
 (0)