Skip to content

Commit a867d49

Browse files
Merge pull request #2 from TakayukiHoshi1984/modify_aar_github_packages
Codegenから生成したプラグインがaarをGitHub Packagesからダウンロードする様に修正
2 parents 6be6078 + a6fa4bf commit a867d49

23 files changed

Lines changed: 241 additions & 28 deletions

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MANUAL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ DeviceConnect Codegenは、DeviceConnectシステム上で動作するプラグ
3333
|samples/profiles-specs|シェルスクリプトのサンプルに入力するプロファイル定義ファイル群。|
3434

3535
## Get Started
36-
[deviceconnect-codegen-project-1.9.0-dist.zip](https://github.com/TakayukiHoshi1984/DeviceConnect-Experiments/releases/tag/codegen-v1.9.0) をPC上の任意の場所にダウンロードし、解凍してください。
36+
[deviceconnect-codegen-project-1.9.1-dist.zip](https://github.com/DeviceConnect/DeviceConnect-Codegen/releases/tag/codegen-v1.9.1) をPC上の任意の場所にダウンロードし、解凍してください。
3737

3838
解凍後、ターミナルを起動し、以下のコマンドによりをサンプルのスケルトンコードを生成してください。
3939

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# DeviceConnect Codegen
22

3+
## はじめに
4+
DeviceConnect Codegenは、DeviceConnectシステム上で動作するプラグインおよびアプリケーションのスケルトンコードを生成するためのコマンドラインツールです。
5+
6+
37
## 開発環境
48
### 開発ツール
59
- Apache Maven 3.3.9+
@@ -25,18 +29,21 @@ $ mvn package
2529
例: バージョン a.b.c に変更する場合
2630

2731
```
28-
$ cd DeviceConnect-Experiments/DeviceConnectCodegen
32+
$ cd DeviceConnect-Codegen
2933
$ python tools/version.py a.b.c
3034
```
3135

3236
正常に変更された場合は、以下のログが標準出力される。
3337

3438
```
35-
Changed: /(略)/DeviceConnect-Experiments/DeviceConnectCodegen/pom.xml
36-
Changed: /(略)/DeviceConnect-Experiments/DeviceConnectCodegen/modules/deviceconnect-codegen/pom.xml
37-
Changed: /(略)/DeviceConnect-Experiments/DeviceConnectCodegen/README.md
39+
Changed: /(略)/DeviceConnect-Codegen/pom.xml
40+
Changed: /(略)/DeviceConnect-Codegen/modules/deviceconnect-codegen/pom.xml
41+
Changed: /(略)/DeviceConnect-Codegen/README.md
3842
Completed
3943
```
4044

45+
## 使用方法
46+
作成したツールを使い、スケルトンコードを作成する手順は、[こちら](https://github.com/DeviceConnect/DeviceConnect-Codegen/blob/master/MANUAL.md)を参照してください。
47+
4148
## 参考リンク
42-
- [Swagger](http://swagger.io/)
49+
- [Swagger](http://swagger.io/)

deviceconnect-codegen-project.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3-
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
3+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
44
<output url="file://$MODULE_DIR$/target/classes" />
55
<output-test url="file://$MODULE_DIR$/target/test-classes" />
66
<content url="file://$MODULE_DIR$">

modules/deviceconnect-codegen/deviceconnect-codegen.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3-
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
3+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
44
<output url="file://$MODULE_DIR$/target/classes" />
55
<output-test url="file://$MODULE_DIR$/target/test-classes" />
66
<content url="file://$MODULE_DIR$">

modules/deviceconnect-codegen/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.deviceconnect</groupId>
66
<artifactId>deviceconnect-codegen</artifactId>
7-
<version>1.9.0</version>
7+
<version>1.9.1</version>
88

99
<packaging>jar</packaging>
1010

modules/deviceconnect-codegen/src/main/java/org/deviceconnect/codegen/plugin/AndroidPluginCodegenConfig.java

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public enum ConnectionType {
3030
BROADCAST,
3131
BINDER
3232
}
33-
33+
private static final String DEVICE_PLUGIN_SDK_VERSION_NAME = "2.8.4";
3434
private final String pluginModuleFolder = "plugin";
3535
private final String projectFolder = pluginModuleFolder + "/src/main";
3636
private final String sourceFolder = projectFolder + "/java";
@@ -42,17 +42,20 @@ public enum ConnectionType {
4242
private final String modelDocPath = "docs/";
4343

4444
{
45-
putOption("targetSdkVersion", "", "28");
45+
putOption("targetSdkVersion", "", "29");
4646
putOption("minSdkVersion", "", "19");
47-
putOption("compileSdkVersion", "", "28");
48-
putOption("deviceConnectPluginSdkVersion", "", "2.7.2");
49-
putOption("deviceConnectSdkForAndroidVersion", "", "2.3.1");
47+
putOption("compileSdkVersion", "", "29");
48+
putOption("deviceConnectPluginSdkVersion", "", DEVICE_PLUGIN_SDK_VERSION_NAME);
49+
putOption("deviceConnectSdkForAndroidVersion", "", "2.3.2");
50+
putOption("githubAccountName", "", "YOUR_NAME");
51+
putOption("githubAccountKey", "", "YOUR_KEY");
5052
}
5153

5254
private void putOption(final String name, final String description, final String defaultValue) {
5355
CliOption option = CliOption.newString(name, description);
5456
option.setDefault(defaultValue);
5557
this.cliOptions.add(option);
58+
this.additionalProperties.put(name, defaultValue);
5659
}
5760

5861
@Override
@@ -277,7 +280,12 @@ public void processOpts() {
277280
String manifest = getManifestTemplateFile();
278281
supportingFiles.add(new SupportingFile("manifest/" + manifest, getProjectDir(), "AndroidManifest.xml"));
279282
supportingFiles.add(new SupportingFile(getGradleTemplateDir()+ "/root.build.gradle.mustache", "", "build.gradle"));
280-
supportingFiles.add(new SupportingFile(getGradleTemplateDir() + "/plugin.build.gradle.mustache", getPluginModuleDir(), "build.gradle"));
283+
if (getGradleTemplateFile().indexOf(DEVICE_PLUGIN_SDK_VERSION_NAME) != -1) {
284+
supportingFiles.add(new SupportingFile("github.properties.mustache", "", "github.properties"));
285+
supportingFiles.add(new SupportingFile(getGradleTemplateDir() + "/plugin.2.8.4.build.gradle.mustache", getPluginModuleDir(), "build.gradle"));
286+
} else{
287+
supportingFiles.add(new SupportingFile(getGradleTemplateDir() + "/plugin.build.gradle.mustache", getPluginModuleDir(), "build.gradle"));
288+
}
281289
supportingFiles.add(new SupportingFile("gradle.properties.mustache", "", "gradle.properties"));
282290
supportingFiles.add(new SupportingFile("resource/xml/deviceplugin.xml.mustache", getPluginResourceDir() + "/xml", getDevicePluginXmlName() + ".xml"));
283291
supportingFiles.add(new SupportingFile("resource/values/strings.xml.mustache", getPluginResourceDir() + "/values", "strings.xml"));
@@ -316,6 +324,22 @@ protected String getManifestTemplateFile() {
316324
return manifest;
317325
}
318326

327+
protected String getGradleTemplateFile() {
328+
String gradleVersion;
329+
final VersionName ver2_8_4 = VersionName.parse(DEVICE_PLUGIN_SDK_VERSION_NAME);
330+
String versionParam = (String) additionalProperties.get("deviceConnectPluginSdkVersion");
331+
VersionName version = VersionName.parse(versionParam);
332+
if (version == null) {
333+
version = ver2_8_4;
334+
}
335+
if (version.isEqualOrMoreThan(ver2_8_4)) {
336+
gradleVersion = DEVICE_PLUGIN_SDK_VERSION_NAME + ".";
337+
} else {
338+
gradleVersion = "";
339+
}
340+
return gradleVersion;
341+
}
342+
319343
protected String getPluginSourceDir() {
320344
return sourceFolder;
321345
}

modules/deviceconnect-codegen/src/main/resources/deviceConnectAndroidPlugin/README.md.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Android Studio 2.2.1以上
1818

1919

2020
## 関連ページ
21-
- [Device Connect プラグイン開発マニュアル](https://github.com/DeviceConnect/DeviceConnect-Android/wiki/DevicePlugin-Manual-for-Android-Studio-110)
21+
- [Device Connect プラグイン開発マニュアル](https://github.com/DeviceConnect/DeviceConnect-Android/wiki/Plugin-Development-Manual-for-Plugin-SDK-ver-2.4.0)
2222

2323
## テスト
2424
以下は config オプションのテストです。
@@ -28,4 +28,4 @@ testInt: {{testInt}}
2828
testNumber: {{testNumber}}
2929
testBoolean: {{testBoolean}}
3030
testObject: {{#testObject}}{{objKey}}{{/testObject}}
31-
testArray: {{#testArray}}{{.}} {{/testArray}}
31+
testArray: {{#testArray}}{{.}} {{/testArray}}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
gpr.usr={{githubAccountName}}
2+
gpr.key={{githubAccountKey}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
apply plugin: 'com.android.application'
2+
3+
// Create github.properties in root project folder file with
4+
// gpr.usr=GITHUB_USER_ID
5+
// gpr.key=PERSONAL_ACCESS_TOKEN
6+
def githubPropertiesFile = rootProject.file("github.properties")
7+
def githubProperties = new Properties()
8+
if (githubPropertiesFile.exists()) {
9+
githubProperties.load(new FileInputStream(githubPropertiesFile))
10+
}
11+
12+
dependencies {
13+
implementation fileTree(include: '*.jar', dir: 'libs')
14+
implementation 'org.deviceconnect:dconnect-device-plugin-sdk:{{{deviceConnectPluginSdkVersion}}}'
15+
}
16+
17+
android {
18+
19+
compileSdkVersion {{compileSdkVersion}}
20+
21+
defaultConfig {
22+
applicationId "{{invokerPackage}}"
23+
minSdkVersion {{minSdkVersion}}
24+
targetSdkVersion {{targetSdkVersion}}
25+
versionCode 1
26+
versionName '1.0.0'
27+
}
28+
29+
compileOptions {
30+
sourceCompatibility 1.8
31+
targetCompatibility 1.8
32+
}
33+
34+
signingConfigs {
35+
releaseConfig {
36+
storeFile=file(project.properties.storeFile)
37+
storePassword=project.properties.storePassword
38+
keyAlias=project.properties.keyAlias
39+
keyPassword=project.properties.keyPassword
40+
}
41+
}
42+
43+
buildTypes {
44+
release {
45+
minifyEnabled false
46+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
47+
signingConfig signingConfigs.releaseConfig
48+
}
49+
}
50+
51+
packagingOptions {
52+
exclude 'LICENSE.txt'
53+
exclude 'META-INF/DEPENDENCIES'
54+
exclude 'META-INF/LICENSE'
55+
exclude 'META-INF/NOTICE'
56+
}
57+
58+
tasks.withType(JavaCompile) {
59+
options.encoding = 'UTF-8'
60+
}
61+
repositories {
62+
maven {
63+
name = "DeviceConnect-Android"
64+
url = uri("https://maven.pkg.github.com/DeviceConnect/DeviceConnect-Android")
65+
66+
credentials {
67+
username = System.getenv("GPR_USER") ?: githubProperties['gpr.usr']
68+
password = System.getenv("GPR_API_KEY") ?: githubProperties['gpr.key']
69+
}
70+
}
71+
}
72+
}

0 commit comments

Comments
 (0)