Skip to content

Commit

Permalink
version 1.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
syslogic committed Mar 25, 2024
1 parent 614bd2d commit cc15dd5
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 60 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:8.3.1'
classpath 'com.huawei.agconnect:agcp:1.9.1.303'
classpath 'io.syslogic:agconnect-publishing-gradle-plugin:1.3.3'
classpath 'io.syslogic:agconnect-publishing-gradle-plugin:1.3.4'
}
}
````

Or in the version-catalog `gradle/libs.versions.toml`:
````toml
[versions]
agconnect_publishing_plugin = '1.3.3'
agconnect_publishing_plugin = '1.3.4'

[plugins]
agconnect_publishing = { id = "io.syslogic.agconnect.publishing", version.ref = "agconnect_publishing_plugin" }
Expand Down Expand Up @@ -93,12 +93,12 @@ These properties are all optional, while:

### Example Log Output

The log output for task `:mobile:publishReleaseAab` explains what it does.<br/>
The log output for task `:mobile:uploadReleaseAab` explains what it does.<br/>
To be precise, it only uploads APK/ABB packages, but does not release them.

````
> Task :mobile:bundleRelease
> Task :mobile:publishReleaseAab
> Task :mobile:uploadReleaseAab
> POST /api/oauth2/v1/token HTTP/1.1
> HTTP/1.1 200 OK
> GET /api/publish/v2/upload-url?appId=000000000&releaseType=1&suffix=aab HTTP/1.1
Expand All @@ -116,11 +116,11 @@ AAB file someapp_1.0.0-huawei-release.aab has been uploaded.

Note: After this, some app-information still needs to be manually completed.

The log output for task `:mobile:submitReleaseAab` explains what it does.<br/>
The log output for task `:mobile:publishReleaseAab` explains what it does.<br/>
To be precise, it submits an <u>already uploaded</u> APK/ABB package for review.

````
> Task :mobile:submitReleaseAab
> Task :mobile:publishReleaseAab
> POST /api/oauth2/v1/token HTTP/1.1
> HTTP/1.1 200 OK
> POST /api/publish/v2/app-submit?appId=000000000&releaseType=1 HTTP/1.1
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
plugin_version = '1.3.3'
plugin_version = '1.3.4'
gradle_api = '8.3.1'
gradle_publish = '1.2.1'
gson = '2.10.1'
Expand Down
51 changes: 29 additions & 22 deletions src/main/java/io/syslogic/agconnect/PublishingPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import io.syslogic.agconnect.task.AppInfoBasicTask;
import io.syslogic.agconnect.task.AppInfoTask;
import io.syslogic.agconnect.task.HelpTask;
import io.syslogic.agconnect.task.PublishingTask;
import io.syslogic.agconnect.task.SubmitReleaseTask;
import io.syslogic.agconnect.task.UploadPackageTask;
import io.syslogic.agconnect.task.PublishReleaseTask;
import io.syslogic.agconnect.util.StringUtils;

/**
Expand Down Expand Up @@ -107,21 +107,21 @@ public void apply(@NotNull Project project) {
}
}

/* Register Task: Publish. */
/* Task :publishDebugAab always fails, because the AAB is not signed with the upload key. */
taskName = "publish" + StringUtils.capitalize(artifactType);
/* Register Task: Upload Package */
/* Task :uploadDebugAab always fails, because the AAB is not signed with the upload key. */
taskName = "upload" + StringUtils.capitalize(artifactType);
if (!artifactType.equals(ArtifactType.AAB) || !buildType.equals("debug")) {
if (verbose) {System.out.println("> " + buildType + " " + artifactType.toUpperCase(Locale.ROOT) + " :" + taskName);}
registerPublishingTask(project, taskName, appConfigFile, artifactType, buildType, null, null, releaseType);
registerUploadPackageTask(project, taskName, appConfigFile, artifactType, buildType, null, null, releaseType);
} else if(verbose) {
System.out.println("> " + buildType + " " + artifactType.toUpperCase(Locale.ROOT) + " :" + taskName + " skipped");
}

/* Register Task: Submit Release */
taskName = "submit" + StringUtils.capitalize(artifactType);
/* Register Task: Publish Release */
taskName = "publish" + StringUtils.capitalize(artifactType);
if (! buildType.equals("debug")) {
if (verbose) {System.out.println("> " + buildType + " " + artifactType.toUpperCase(Locale.ROOT) + " :" + taskName);}
registerSubmitReleaseTask(project, taskName, appConfigFile, artifactType, buildType, null, null, releaseType);
registerPublishReleaseTask(project, taskName, appConfigFile, artifactType, buildType, null, null, releaseType);
} else if(verbose) {
System.out.println("> " + buildType + " " + artifactType.toUpperCase(Locale.ROOT) + " :" + taskName + " skipped");
}
Expand All @@ -135,7 +135,7 @@ public void apply(@NotNull Project project) {
registerAppIdTask(project, taskName, appConfigFile, buildType, releaseType);

} else if (verbose) {
System.out.println("> " + buildType + " " + artifactType.toUpperCase(Locale.ROOT) + " · agc-apiclient.json not found");
System.out.println("> " + buildType + " " + artifactType.toUpperCase(Locale.ROOT) + " · agconnect_apiclient.json not found");
}
}
}
Expand Down Expand Up @@ -180,22 +180,21 @@ public void apply(@NotNull Project project) {
}
}

/* Task :publishDebugAab will fail, because the AAB is signed with the upload key. */
taskName = "publish" + StringUtils.capitalize(buildVariant) + StringUtils.capitalize(artifactType);
/* Register Task: Upload Package */
taskName = "upload" + StringUtils.capitalize(buildVariant) + StringUtils.capitalize(artifactType);
/* Task :uploadDebugAab will fail, because the AAB is signed with the upload key. */
if (! artifactType.equals(ArtifactType.AAB) || !buildType.equals("debug")) {
/* Register Tasks: Publish. */
if (verbose) {System.out.println("> " + buildVariant + " " + artifactType.toUpperCase(Locale.ROOT) + " · :" + taskName);}
registerPublishingTask(project, taskName, appConfigFile, artifactType, buildType, buildVariant, productFlavor, releaseType);
registerUploadPackageTask(project, taskName, appConfigFile, artifactType, buildType, buildVariant, productFlavor, releaseType);
} else if (verbose) {
System.out.println("> " + buildVariant + " " + artifactType.toUpperCase(Locale.ROOT) + " · :" + taskName + " skipped");
}

/* Register Task: Submit Release */
taskName = "submit" + StringUtils.capitalize(buildVariant) + StringUtils.capitalize(artifactType);
/* Register Task: Publish Release */
taskName = "publish" + StringUtils.capitalize(buildVariant) + StringUtils.capitalize(artifactType);
if (! buildType.equals("debug")) {
/* Register Tasks: Submit Release. */
if (verbose) {System.out.println("> " + buildVariant + " " + artifactType.toUpperCase(Locale.ROOT) + " · :" + taskName);}
registerSubmitReleaseTask(project, taskName, appConfigFile, artifactType, buildType, buildVariant, productFlavor, releaseType);
registerPublishReleaseTask(project, taskName, appConfigFile, artifactType, buildType, buildVariant, productFlavor, releaseType);
} else if (verbose) {
System.out.println("> " + buildVariant + " " + artifactType.toUpperCase(Locale.ROOT) + " · :" + taskName + " skipped");
}
Expand Down Expand Up @@ -227,13 +226,15 @@ public void apply(@NotNull Project project) {
});
}

/** Register {@link HelpTask}. */
@SuppressWarnings("SameParameterValue")
void registerHelpTask(@NotNull Project project, @NotNull String taskName) {
if (project.getTasks().findByName(taskName) == null) {
project.getTasks().register(taskName, HelpTask.class, task -> task.setGroup(taskGroup));
}
}

/** Register {@link AppIdTask}. */
void registerAppIdTask(
@NotNull Project project, @NotNull String taskName,
@NotNull String appConfigFile, @NotNull String buildType,
Expand All @@ -253,6 +254,7 @@ void registerAppIdTask(
}
}

/** Register {@link AppInfoTask}. */
void registerAppInfoTask(
@NotNull Project project, @NotNull String taskName,
@NotNull String appConfigFile, @NotNull String buildType,
Expand All @@ -272,6 +274,7 @@ void registerAppInfoTask(
}
}

/** Register {@link AppInfoBasicTask}. */
void registerAppInfoBasicTask(
@NotNull Project project, @NotNull String taskName,
@NotNull String appConfigFile, @NotNull String buildType,
Expand All @@ -290,6 +293,7 @@ void registerAppInfoBasicTask(
}
}

/** Register {@link AppInfoLocalizationTask}. */
void registerAppInfoLocalizationTask(
@NotNull Project project, @NotNull String taskName,
@NotNull String appConfigFile, @NotNull String buildType,
Expand All @@ -308,15 +312,16 @@ void registerAppInfoLocalizationTask(
}
}

void registerPublishingTask(
/** Register {@link UploadPackageTask}. */
void registerUploadPackageTask(
@NotNull Project project, @NotNull String taskName, @NotNull String appConfigFile,
@NotNull String artifactType, @NotNull String buildType,
@Nullable String buildVariant, @Nullable String productFlavor,
@Nullable Integer releaseType
) {
if (project.getTasks().findByName(taskName) == null) {
String apiConfigFile = configFile;
project.getTasks().register(taskName, PublishingTask.class, task -> {
project.getTasks().register(taskName, UploadPackageTask.class, task -> {
task.setGroup(taskGroup);
task.getReleaseType().set(releaseType);
task.getApiConfigFile().set(apiConfigFile);
Expand All @@ -335,15 +340,16 @@ void registerPublishingTask(
}
}

void registerSubmitReleaseTask(
/** Register {@link PublishReleaseTask}. */
void registerPublishReleaseTask(
@NotNull Project project, @NotNull String taskName, @NotNull String appConfigFile,
@NotNull String artifactType, @NotNull String buildType,
@Nullable String buildVariant, @Nullable String productFlavor,
@Nullable Integer releaseType
) {
if (project.getTasks().findByName(taskName) == null) {
String apiConfigFile = configFile;
project.getTasks().register(taskName, SubmitReleaseTask.class, task -> {
project.getTasks().register(taskName, PublishReleaseTask.class, task -> {
task.setGroup(taskGroup);
task.getReleaseType().set(releaseType);
task.getApiConfigFile().set(apiConfigFile);
Expand Down Expand Up @@ -374,6 +380,7 @@ String[] getBuildTypes(@NotNull Project project) {
return buildTypes.toArray(new String[0]);
}

/** Apply the {@link ApkSigningConfig} from build-type "release" to "debug". */
private void setDebugSigningConfig(@NotNull Project project) {
ApplicationExtension android = (ApplicationExtension) project.getExtensions().getByName("android");
NamedDomainObjectContainer<? extends ApplicationBuildType> buildTypes = android.getBuildTypes();
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/io/syslogic/agconnect/constants/ConsoleUrl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.syslogic.agconnect.constants;

/**
* AppGallery Connect Console URL
*
* @author Martin Zeitler
*/
public class ConsoleUrl {

/** Link to AppGallery Connect Console */
public static final String PACKAGE_INFO = "https://developer.huawei.com/consumer/en/service/josp/agc/index.html#/myApp/{appId}/v{packageId}";

/** Link to AppGallery Connect Console */
public static final String CERTIFICATES = "https://developer.huawei.com/consumer/en/service/josp/agc/index.html#/myApp/{appId}/9249519184596012000";

/** Link to AppGallery Connect Console */
public static final String APP_INFO = "https://developer.huawei.com/consumer/en/service/josp/agc/index.html#/myApp/{appId}/97458334310914199";

/** Link to AppGallery Connect Console */
public static final String INTEGRATION = "https://developer.huawei.com/consumer/en/service/josp/agc/index.html#/myProject/99536292102543196/97458334310914194?appId={appId}";

/** Link to AppGallery Connect Console */
public static final String MAPPING_FILES = "https://developer.huawei.com/consumer/en/service/josp/agc/index.html#/myProject/99536292102543196/9249519184596033624?appId={appId}";

/** Link to AppGallery Connect Console */
public static final String API_CLIENT_CREDENTIALS = "https://developer.huawei.com/consumer/en/service/josp/agc/index.html#/ups/9249519184595983326";
}
18 changes: 0 additions & 18 deletions src/main/java/io/syslogic/agconnect/constants/EndpointUrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,4 @@ public class EndpointUrl {
public static final String PUBLISH_ON_SHELF_TIME = "https://connect-api.cloud.huawei.com/api/publish/v2/on-shelf-time";
/** Endpoint URL */
public static final String PUBLISH_COMPILE_STATUS = "https://connect-api.cloud.huawei.com/api/publish/v2/package/compile/status";

/** Link to AppGallery Connect Console */
public static final String AG_CONNECT_PACKAGE_INFO = "https://developer.huawei.com/consumer/en/service/josp/agc/index.html#/myApp/{appId}/v{packageId}";

/** Link to AppGallery Connect Console */
public static final String AG_CONNECT_CERTIFICATES = "https://developer.huawei.com/consumer/en/service/josp/agc/index.html#/myApp/{appId}/9249519184596012000";

/** Link to AppGallery Connect Console */
public static final String AG_CONNECT_APP_INFO = "https://developer.huawei.com/consumer/en/service/josp/agc/index.html#/myApp/{appId}/97458334310914199";

/** Link to AppGallery Connect Console */
public static final String AG_CONNECT_INTEGRATION = "https://developer.huawei.com/consumer/en/service/josp/agc/index.html#/myProject/99536292102543196/97458334310914194?appId={appId}";

/** Link to AppGallery Connect Console */
public static final String AG_CONNECT_MAPPING_FILES ="https://developer.huawei.com/consumer/en/service/josp/agc/index.html#/myProject/99536292102543196/9249519184596033624?appId={appId}";

/** Link to AppGallery Connect Console */
public static final String AG_CONNECT_API_CLIENT = "https://developer.huawei.com/consumer/en/service/josp/agc/index.html#/ups/9249519184595983326";
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package io.syslogic.agconnect.constants;

/**
* Error Message
* @author Martin Zeitler
*/
public class ErrorMessage {

/** Error Message Payload. */
public static final String APP_SIGNING_NOT_ENABLED = "[cds]add apk failed, additional msg is [app bundle must do app signature.]";

/** Error Message Payload. */
public static final String ONGOING_INTEGRATION_CHECK = "[cds]update service failed, additional msg is [The new service has can't be edited service,which can't be updated!]";
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ public class ResultCode {

/** API result code. */
public static final int OBTAIN_UPLOAD_AUTH_CODE = 204144645;
/** API result code. */

/** API result code. */
public static final int FAILED_TO_UPLOAD_PACKAGE = 204144646;

/** API result code (apparently undocumented). */
public static final int FAILED_TO_UPDATE_PACKAGE = 204144647;

/** API result code. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import java.nio.charset.StandardCharsets;

import io.syslogic.agconnect.constants.ConsoleUrl;
import io.syslogic.agconnect.constants.EndpointUrl;
import io.syslogic.agconnect.model.AppInfo;

Expand Down Expand Up @@ -60,7 +61,7 @@ public void updateAppInfoBasic() {
if (statusCode == HttpStatus.SC_OK) {
// AppInfoResponse appInfo = new Gson().fromJson(result, AppInfoResponse.class);
if (getVerbose().get()) { /* Logging the URL to the "App information" page. */
this.stdOut(EndpointUrl.AG_CONNECT_APP_INFO.replace("{appId}", String.valueOf(this.appId)));
this.stdOut(ConsoleUrl.APP_INFO.replace("{appId}", String.valueOf(this.appId)));
} else {
this.stdOut("> AppInfo updated");
this.stdOut("> " + result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import java.nio.charset.StandardCharsets;

import io.syslogic.agconnect.constants.ConsoleUrl;
import io.syslogic.agconnect.constants.EndpointUrl;
import io.syslogic.agconnect.model.AppInfoLocalization;

Expand Down Expand Up @@ -58,7 +59,7 @@ public void updateAppInfoLocalization() {
if (statusCode == HttpStatus.SC_OK) {
// AppInfoResponse appInfo = new Gson().fromJson(result, AppInfoResponse.class);
if (getVerbose().get()) { /* Logging the URL to the "App information" page. */
this.stdOut(EndpointUrl.AG_CONNECT_APP_INFO.replace("{appId}", String.valueOf(this.appId)));
this.stdOut(ConsoleUrl.APP_INFO.replace("{appId}", String.valueOf(this.appId)));
} else {
this.stdOut("> AppInfo localization updated");
this.stdOut("> " + result);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/syslogic/agconnect/task/AppInfoTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import org.gradle.api.tasks.TaskAction;

import io.syslogic.agconnect.constants.ConsoleUrl;
import io.syslogic.agconnect.constants.EndpointUrl;
import io.syslogic.agconnect.model.AppInfoResponse;

Expand Down Expand Up @@ -70,7 +71,7 @@ public void getAppInfo() {

/* Logging the URL to the "App information" page. */
if (getVerbose().get()) {
this.stdOut(EndpointUrl.AG_CONNECT_APP_INFO.replace("{appId}", String.valueOf(this.appId)));
this.stdOut(ConsoleUrl.APP_INFO.replace("{appId}", String.valueOf(this.appId)));
}
} else {
this.stdErr("HTTP " + statusCode + " " + response.getStatusLine().getReasonPhrase());
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/io/syslogic/agconnect/task/BaseTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.nio.charset.StandardCharsets;
import java.util.Locale;

import io.syslogic.agconnect.constants.ConsoleUrl;
import io.syslogic.agconnect.constants.EndpointUrl;
import io.syslogic.agconnect.model.ApiConfigFile;
import io.syslogic.agconnect.model.AppConfigFile;
Expand Down Expand Up @@ -103,13 +104,13 @@ boolean configure(@NotNull Project project, String appConfig, String apiConfig,
this.clientId = config.getClientId();
} else {
this.stdErr("API client credentials must have role \"App administrator\"; provided: \"Administrator\"");
this.stdOut(EndpointUrl.AG_CONNECT_API_CLIENT);
this.stdOut(ConsoleUrl.API_CLIENT_CREDENTIALS);
return false;
}
} else {
this.stdErr("API client credentials not found:");
this.stdOut(file.getAbsolutePath());
this.stdOut(EndpointUrl.AG_CONNECT_API_CLIENT);
this.stdOut(ConsoleUrl.API_CLIENT_CREDENTIALS);
return false;
}

Expand Down
Loading

0 comments on commit cc15dd5

Please sign in to comment.