Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Windows. #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ clean {
delete = ['build']
}
dependencies {
implementation 'org.smali:baksmali:2.2.5' // runtime dependency
testImplementation 'org.hamcrest:hamcrest:2.1' // test dependency
testImplementation 'junit:junit:4.12' // test dependency
implementation 'org.smali:baksmali:2.2.5' // runtime dependency
testImplementation 'org.hamcrest:hamcrest:2.1' // test dependency
testImplementation 'junit:junit:4.12' // test dependency
implementation 'org.apache.commons:commons-lang3:3.11' // used to determine OS
}
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Sun Sep 06 11:58:44 CAT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
18 changes: 8 additions & 10 deletions src/main/java/com/alex_zaitsev/adg/FilterProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.alex_zaitsev.adg.io.*;
import com.alex_zaitsev.adg.filter.*;

import org.apache.commons.lang3.SystemUtils;

import java.io.File;
import java.util.regex.Matcher;

Expand All @@ -17,21 +19,17 @@ public FilterProvider(Filters inputFilters) {
public Filter<String> makePathFilter() {
String replacement = Matcher.quoteReplacement(File.separator);
replacement = Matcher.quoteReplacement(replacement);
String packageNameAsPath = inputFilters.getPackageName().replaceAll("\\.", replacement);

// see https://github.com/alexzaitsev/apk-dependency-graph/issues/60
String packageNameAsPath = inputFilters.getPackageName().replaceAll(SystemUtils.IS_OS_WINDOWS ? "/" : "\\.", replacement);
String packageNameRegex = ".*" + packageNameAsPath + ".*";
RegexFilter filter = new RegexFilter(packageNameRegex);

return filter;

return new RegexFilter(packageNameRegex);
}

public Filter<String> makeClassFilter() {
String[] ignoredClasses = inputFilters.getIgnoredClasses();
if (ignoredClasses == null) {
return null;
}

InverseRegexFilter ignoredClassesFilter = new InverseRegexFilter(ignoredClasses);

return ignoredClassesFilter;
return ignoredClasses == null ? null : new InverseRegexFilter(ignoredClasses);
}
}
2 changes: 1 addition & 1 deletion src/test/java/FilterProviderTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void makePathFilterReturnsExpectedFilter() {
assertThat(filter, notNullValue());
String filterStringRepr = File.separatorChar == '/' ?
"RegexFilter{.*com/example/package.*}" : // for Unix
"RegexFilter{.*com\\\\example\\\\package.*}"; // for Windows
"RegexFilter{.*com.example.package.*}"; // for Windows
assertThat(filter.toString(), equalTo(filterStringRepr));
}

Expand Down