Skip to content

Commit

Permalink
Add support for Windows. See alexzaitsev#60 for an explanation. Fixed…
Browse files Browse the repository at this point in the history
… unit test.
  • Loading branch information
LaurieScheepers committed Sep 6, 2020
1 parent 6d0e75e commit d42740d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
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

0 comments on commit d42740d

Please sign in to comment.