mirror of
https://github.com/TonyJiangWJ/Auto.js.git
synced 2026-06-21 21:01:43 +08:00
修复每次打包都会增加project.json的assets条目
This commit is contained in:
parent
5251028b0b
commit
6e481a3841
Binary file not shown.
@ -1,6 +1,7 @@
|
||||
package org.autojs.autojs.autojs.build;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.autojs.apkbuilder.ApkBuilder;
|
||||
@ -8,6 +9,7 @@ import com.stardust.autojs.apkbuilder.ManifestEditor;
|
||||
import com.stardust.autojs.apkbuilder.util.StreamUtils;
|
||||
import com.stardust.autojs.project.ProjectConfig;
|
||||
import com.stardust.pio.PFiles;
|
||||
|
||||
import org.autojs.autojs.App;
|
||||
|
||||
import java.io.File;
|
||||
@ -156,8 +158,10 @@ public class AutoJsApkBuilder extends ApkBuilder {
|
||||
projectConfig.setName(config.appName)
|
||||
.setPackageName(config.packageName)
|
||||
.setVersionCode(config.versionCode)
|
||||
.setVersionName(config.versionName)
|
||||
.setMainScriptFile("main.js");
|
||||
.setVersionName(config.versionName);
|
||||
if (TextUtils.isEmpty(projectConfig.getMainScriptFile())) {
|
||||
projectConfig.setMainScriptFile("main.js");
|
||||
}
|
||||
updateProjectConfigAssets(projectConfig, config.jsPath, config.jsPath);
|
||||
PFiles.write(ProjectConfig.configFileOfDir(config.jsPath), projectConfig.toJson());
|
||||
}
|
||||
@ -173,7 +177,7 @@ public class AutoJsApkBuilder extends ApkBuilder {
|
||||
continue;
|
||||
}
|
||||
String relative = new File(projectDir).toURI().relativize(file.toURI()).getPath();
|
||||
config.getAssets().add(relative);
|
||||
config.addAsset(relative);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.stardust.pio.PFiles;
|
||||
import com.stardust.pio.UncheckedIOException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -80,7 +81,6 @@ public class ProjectConfig {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
@ -128,11 +128,24 @@ public class ProjectConfig {
|
||||
|
||||
public List<String> getAssets() {
|
||||
if (mAssets == null) {
|
||||
mAssets = new ArrayList<>();
|
||||
mAssets = Collections.emptyList();
|
||||
}
|
||||
return mAssets;
|
||||
}
|
||||
|
||||
public boolean addAsset(String assetRelativePath) {
|
||||
if (mAssets == null) {
|
||||
mAssets = new ArrayList<>();
|
||||
}
|
||||
for (String asset : mAssets) {
|
||||
if (new File(asset).equals(new File(assetRelativePath))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
mAssets.add(assetRelativePath);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setAssets(List<String> assets) {
|
||||
mAssets = assets;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user