Skip to content

Commit c66ed46

Browse files
Merge branch 'master' into modify_prefer_inclusive_language
# Conflicts: # dConnectDevicePlugin/dConnectDevicePluginSDK/dconnect-device-plugin-sdk/build.gradle
2 parents 3224cda + 6713238 commit c66ed46

4 files changed

Lines changed: 855 additions & 536 deletions

File tree

dConnectDevicePlugin/dConnectDevicePluginSDK/dconnect-device-plugin-sdk/build.gradle

Lines changed: 57 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
apply plugin: 'com.android.library'
22
apply plugin: 'maven-publish'
3+
apply plugin: 'de.undercouch.download'
4+
buildscript {
5+
repositories {
6+
jcenter()
7+
}
8+
dependencies {
9+
classpath 'de.undercouch:gradle-download-task:4.1.0'
10+
}
11+
}
312

413
def githubPropertiesFile = rootProject.file("github.properties")
514
def githubProperties = new Properties()
@@ -59,6 +68,12 @@ android {
5968
}
6069
}
6170
}
71+
testOptions {
72+
unitTests {
73+
includeAndroidResources = true
74+
returnDefaultValues = true
75+
}
76+
}
6277
}
6378

6479

@@ -105,8 +120,8 @@ dependencies {
105120
implementation 'org.bouncycastle:bcprov-jdk15on:1.46'
106121

107122
testImplementation 'junit:junit:4.12'
108-
testImplementation 'org.mockito:mockito-core:2.10.0'
109-
testImplementation 'org.robolectric:robolectric:3.7.1'
123+
testImplementation 'org.mockito:mockito-core:2.25.0'
124+
testImplementation 'org.robolectric:robolectric:4.3.1'
110125
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
111126
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
112127
}
@@ -127,74 +142,49 @@ def specOutputDir = file("${projectDir}/src/main/assets/")
127142
def specZipFile = ''
128143
def apiDir = new File(specOutputDir, 'api')
129144

130-
task downloadZip(type: SpecDownload) {
131-
sourceUrl = 'https://github.com/DeviceConnect/DeviceConnect-Spec/archive/master.zip'
132-
target = file("${projectDir}/master.zip")
133-
specZipFile = target
134-
}
135-
136-
task unzip(type: Copy) {
137-
from zipTree(specZipFile)
138-
into specOutputDir
139-
exclude '**/README.md'
140-
exclude '**/LICENSE'
141-
exclude '**/.DS_Store'
142-
}
143-
144-
task downloadDeviceConnectSpec {
145-
doLast {
146-
// zipをダウンロード
147-
tasks.downloadZip.execute()
148-
149-
if (!specZipFile.exists()) {
150-
println 'Failed to download a zip file.'
151-
} else {
152-
// assets/api以下を削除
153-
if (apiDir.exists()) {
154-
delete(apiDir)
155-
}
156-
157-
// zipを解凍
158-
tasks.unzip.execute()
159-
160-
// zipを行うと不要なフォルダが作成されてしまうので、削除
161-
def specRootDir = specOutputDir.listFiles(new FilenameFilter() {
162-
boolean accept(File dir, String name) {
163-
return name.startsWith("DeviceConnect-Spec") && new File(dir, name).isDirectory()
164-
}
165-
})[0]
166-
def apiRootDir = specRootDir.listFiles(new FilenameFilter() {
167-
boolean accept(File dir, String name) {
168-
return "api" == name && new File(dir, name).isDirectory()
169-
}
170-
})[0]
171-
apiRootDir.renameTo(apiDir)
172-
173-
// 不要になったzipやフォルダを削除
174-
specRootDir.delete()
175-
specZipFile.delete()
176-
}
145+
// apiフォルダが存在しない場合にはDeviceConnect-Specをダウンロード
146+
if (!apiDir.exists()) {
147+
specZipFile = file("${projectDir}/master.zip")
148+
download {
149+
src 'https://github.com/DeviceConnect/DeviceConnect-Spec/archive/master.zip'
150+
dest specZipFile
151+
overwrite true
177152
}
178-
}
179-
180-
class SpecDownload extends DefaultTask {
181-
@Input
182-
String sourceUrl
183-
184-
@OutputFile
185-
File target
153+
if (!specZipFile.exists()) {
154+
println 'Failed to download a zip file.'
155+
} else {
156+
// assets/api以下を削除
157+
if (apiDir.exists()) {
158+
delete(apiDir)
159+
}
160+
// zipを解凍
161+
copy {
162+
from zipTree("${projectDir}/master.zip")
163+
into specOutputDir
164+
exclude '**/README.md'
165+
exclude '**/LICENSE'
166+
exclude '**/.DS_Store'
167+
exclude '**/yaml/**'
168+
}
169+
// zipを行うと不要なフォルダが作成されてしまうので、削除
170+
def specRootDir = specOutputDir.listFiles(new FilenameFilter() {
171+
boolean accept(File dir, String name) {
172+
return name.startsWith("DeviceConnect-Spec") && new File(dir, name).isDirectory()
173+
}
174+
})[0]
175+
def apiRootDir = specRootDir.listFiles(new FilenameFilter() {
176+
boolean accept(File dir, String name) {
177+
return "api" == name && new File(dir, name).isDirectory()
178+
}
179+
})[0]
180+
apiRootDir.renameTo(apiDir)
186181

187-
@TaskAction
188-
void download() {
189-
ant.get(src: sourceUrl, dest: target)
182+
// 不要になったzipやフォルダを削除
183+
specRootDir.delete()
184+
specZipFile.delete()
190185
}
191186
}
192187

193-
// apiフォルダが存在しない場合にはDeviceConnect-Specをダウンロード
194-
if (!apiDir.exists()) {
195-
tasks.downloadDeviceConnectSpec.execute()
196-
}
197-
198188

199189
if (JavaVersion.current().isJava8Compatible()) {
200190
allprojects {
@@ -208,7 +198,7 @@ if (JavaVersion.current().isJava8Compatible()) {
208198
publishing {
209199
publications {
210200
bar(MavenPublication) {
211-
groupId 'org.deviceconnect'
201+
groupId 'io.gclue.deviceconnect.android'
212202
artifactId getArtificatId()
213203
version getVersionName()
214204
artifact("$buildDir/outputs/aar/${getArtificatId()}-release.aar")
@@ -247,7 +237,7 @@ publishing {
247237
/** Configure path of your package repository on Github
248238
* Replace GITHUB_USERID with your/organisation Github userID and REPOSITORY with the repository name on GitHub
249239
*/
250-
url = uri("https://maven.pkg.github.com/DeviceConnect/DeviceConnect-Android")
240+
url = uri("https://maven.pkg.github.com/TakayukiHoshi1984/DeviceConnect-AndroidSandbox")
251241

252242
credentials {
253243
/**Create github.properties in root project folder file with gpr.usr=GITHUB_USER_ID & gpr.key=PERSONAL_ACCESS_TOKEN**/

0 commit comments

Comments
 (0)