fix: remove class filtering on export (#1847)

This commit is contained in:
Skylot 2023-04-25 15:39:29 +01:00
parent ddefead764
commit 5e8f9b900f
No known key found for this signature in database
GPG Key ID: 1E23F5B52567AA39

View File

@ -3,23 +3,16 @@ package jadx.core.export;
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import javax.xml.parsers.DocumentBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import jadx.api.ResourceFile;
import jadx.core.dex.attributes.AFlag;
import jadx.core.dex.nodes.ClassNode;
import jadx.core.dex.nodes.RootNode;
import jadx.core.utils.exceptions.JadxRuntimeException;
import jadx.core.utils.files.FileUtils;
@ -27,15 +20,8 @@ import jadx.core.xmlgen.ResContainer;
import jadx.core.xmlgen.XmlSecurity;
public class ExportGradleProject {
private static final Logger LOG = LoggerFactory.getLogger(ExportGradleProject.class);
private static final Pattern ILLEGAL_GRADLE_CHARS = Pattern.compile("[/\\\\:>\"?*|]");
private static final Set<String> IGNORE_CLS_NAMES = new HashSet<>(Arrays.asList(
"R",
"BuildConfig"));
private final RootNode root;
private final File projectDir;
private final File appDir;
@ -61,7 +47,6 @@ public class ExportGradleProject {
saveProjectBuildGradle();
saveApplicationBuildGradle();
saveSettingsGradle();
skipGeneratedClasses();
} catch (Exception e) {
throw new JadxRuntimeException("Gradle export failed", e);
}
@ -95,16 +80,6 @@ public class ExportGradleProject {
tmpl.save(new File(appDir, "build.gradle"));
}
private void skipGeneratedClasses() {
for (ClassNode cls : root.getClasses()) {
String shortName = cls.getClassInfo().getShortName();
if (IGNORE_CLS_NAMES.contains(shortName)) {
cls.add(AFlag.DONT_GENERATE);
LOG.debug("Skip class: {}", cls);
}
}
}
private ApplicationParams getApplicationParams(Document androidManifest, Document appStrings) {
Element manifest = (Element) androidManifest.getElementsByTagName("manifest").item(0);
Element usesSdk = (Element) androidManifest.getElementsByTagName("uses-sdk").item(0);