Skip to content

Commit 02c40cd

Browse files
committed
feat: add version name in config file and enhanced errors from plugin
1 parent 0bf4c1e commit 02c40cd

4 files changed

Lines changed: 24 additions & 4 deletions

File tree

plugin/src/main/java/com/icst/plugin/builder/BlockIdleSdkExtension.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public abstract class BlockIdleSdkExtension {
3232

3333
public abstract Property<String> getAppPluginClass();
3434

35+
public abstract Property<String> getVersionName();
36+
3537
@Inject
3638
public BlockIdleSdkExtension(ObjectFactory objects) {
3739
}

plugin/src/main/java/com/icst/plugin/builder/BuildPluginTask.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public abstract class BuildPluginTask extends DefaultTask {
6161
@Input
6262
public abstract Property<String> getVariantName();
6363

64+
@Input
65+
public abstract Property<String> getVersionName();
66+
6467
@Input
6568
public abstract Property<String> getBuildType();
6669

@@ -102,6 +105,7 @@ public void execute() {
102105
root.put("pluginName", ext.getPluginName().get());
103106
root.put("appPluginClass", ext.getAppPluginClass().get());
104107
root.put("applicationId", getApplicationId().get());
108+
root.put("versionName", getVersionName());
105109

106110
Gson gson = new Gson();
107111
@SuppressWarnings("unchecked")
@@ -129,7 +133,6 @@ public void execute() {
129133

130134
Map<String, Object> apk = new LinkedHashMap<>();
131135
apk.put("apkPath", targetApk.getName()); // RELATIVE PATH ✔
132-
apk.put("versionName", artifact.getVersionName());
133136
apk.put("filters", artifact.getFilters());
134137

135138
outputs.add(apk);

plugin/src/main/java/com/icst/plugin/builder/PluginExtensionConfigurator.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,29 @@ public static void configure(Project project) {
3535
sdkCfg.setCanBeConsumed(false);
3636

3737
project.afterEvaluate(t -> {
38+
StringBuilder error = new StringBuilder("We got following error in your plugin:\n");
39+
boolean containsError = false;
3840
if (!ext.getPluginName().isPresent()) {
39-
throw new GradleException("Please provide a plugin name");
41+
containsError = true;
42+
error.append("> Please provide a plugin name\n");
4043
}
4144
if (!ext.getSdkVersion().isPresent()) {
42-
throw new GradleException("Please provide sdk version for building plugin for BlockIDLE");
45+
containsError = true;
46+
error.append("> Please provide sdk version for building plugin for BlockIDLE\n");
4347
}
4448

4549
if (!ext.getAppPluginClass().isPresent()) {
46-
throw new GradleException("Please provide appPluginClass as entry point of plugin for BlockIDLE");
50+
containsError = true;
51+
error.append("> Please provide appPluginClass as entry point of plugin for BlockIDLE\n");
52+
}
53+
54+
if (!ext.getVersionName().isPresent()) {
55+
containsError = true;
56+
error.append("> Please provide versionName of plugin as entry point of plugin for BlockIDLE\n");
57+
}
58+
59+
if (containsError) {
60+
throw new GradleException(error.toString());
4761
}
4862

4963
validateFqcn(ext.getAppPluginClass().get(), "appPluginClass");

plugin/src/main/java/com/icst/plugin/builder/PluginVariantTaskFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ private static void registerBuildTaskForVariant(Project project, Variant variant
7070

7171
// Variant metadata
7272
task.getVariantName().set(variant.getName());
73+
task.getVersionName().set(ext.getVersionName());
7374
task.getBuildType().set(variant.getBuildType());
7475

7576
Map<String, String> flavors = new HashMap<>();

0 commit comments

Comments
 (0)