Skip to content

Commit

Permalink
Use consequent naming for excludeLog4jSlf4jImpl and make both log4j
Browse files Browse the repository at this point in the history
excludes configurable via CLI
  • Loading branch information
DaGeRe committed Apr 25, 2022
1 parent fd14c86 commit d5431fc
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,12 @@ public void setUseAlternativeBuildfile(final boolean useAlternativeBuildfile) {
this.useAlternativeBuildfile = useAlternativeBuildfile;
}

public boolean isExcludeLog4j() {
public boolean isExcludeLog4jSlf4jImpl() {
return excludeLog4jSlf4jImpl;
}

public void setExcludeLog4j(final boolean excludeLog4j) {
this.excludeLog4jSlf4jImpl = excludeLog4j;
public void setExcludeLog4jSlf4jImpl(boolean excludeLog4jSlf4jImpl) {
this.excludeLog4jSlf4jImpl = excludeLog4jSlf4jImpl;
}

public boolean isExcludeLog4jToSlf4j() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ public class ExecutionConfigMixin {
@Option(names = { "-testClassFolder", "--testClassFolder" }, description = "Folder that contains test classes")
protected String testClazzFolder;

@Option(names = { "-excludeLog4j", "--excludeLog4j" }, description = "Exclude log4j (required, if other logging implementation should be used)")
protected boolean excludeLog4j = false;
@Option(names = { "-excludeLog4jToSlf4j", "--excludeLog4jToSlf4j" }, description = "Exclude log4j-to-slf4j (required, if other logging implementation should be used)")
protected boolean excludeLog4jToSlf4j = false;

@Option(names = { "-excludeLog4jSlf4jImpl", "--excludeLog4jSlf4jImpl" }, description = "Exclude log4j-slf4j-impl (required, if other logging implementation should be used)")
protected boolean excludeLog4jSlf4jImpl = false;

@Option(names = { "-dontRedirectToNull",
"--dontRedirectToNull" }, description = "Activates showing the standard output of the testcase (by default, it is redirected to null)")
Expand Down Expand Up @@ -267,13 +270,21 @@ public String getTestClazzFolder() {
public void setTestClazzFolder(final String testClazzFolder) {
this.testClazzFolder = testClazzFolder;
}

public boolean isExcludeLog4j() {
return excludeLog4j;
public boolean isExcludeLog4jSlf4jImpl() {
return excludeLog4jSlf4jImpl;
}

public void setExcludeLog4j(final boolean excludeLog4j) {
this.excludeLog4j = excludeLog4j;

public void setExcludeLog4jSlf4jImpl(boolean excludeLog4jSlf4jImpl) {
this.excludeLog4jSlf4jImpl = excludeLog4jSlf4jImpl;
}

public boolean isExcludeLog4jToSlf4j() {
return excludeLog4jToSlf4j;
}

public void setExcludeLog4jToSlf4j(boolean excludeLog4jToSlf4j) {
this.excludeLog4jToSlf4j = excludeLog4jToSlf4j;
}

public boolean isDontRedirectToNull() {
Expand Down Expand Up @@ -353,7 +364,8 @@ public ExecutionConfig getExecutionConfig() {
config.setTestClazzFolders(testClazzFolders);
}

config.setExcludeLog4j(excludeLog4j);
config.setExcludeLog4jSlf4jImpl(excludeLog4jSlf4jImpl);
config.setExcludeLog4jToSlf4j(excludeLog4jToSlf4j);
config.setRedirectToNull(!dontRedirectToNull);
config.setOnlyMeasureWorkload(onlyMeasureWorkload);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private void editGradlefileContents(final File tempFolder, final GradleBuildfile

private void addDependencies(final GradleBuildfileVisitor visitor) {
boolean isAddJunit3 = testTransformer.isJUnit3();
boolean isExcludeLog4j = testTransformer.getConfig().getExecutionConfig().isExcludeLog4j();
boolean isExcludeLog4j = testTransformer.getConfig().getExecutionConfig().isExcludeLog4jSlf4jImpl();
if (visitor.getDependencyLine() != -1) {
for (RequiredDependency dependency : RequiredDependency.getAll(isAddJunit3)) {
final String dependencyGradle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void editOneBuildfile(final boolean update, final File pomFile) {
if (model.getDependencies() == null) {
model.setDependencies(new LinkedList<Dependency>());
}
MavenPomUtil.extendDependencies(model, testTransformer.isJUnit3(), testTransformer.getConfig().getExecutionConfig().isExcludeLog4j());
MavenPomUtil.extendDependencies(model, testTransformer.isJUnit3(), testTransformer.getConfig().getExecutionConfig().isExcludeLog4jSlf4jImpl());

try (FileWriter fileWriter = new FileWriter(pomFile)) {
final MavenXpp3Writer writer = new MavenXpp3Writer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void testLog4jSlf4jImplExclusion() throws IOException {
final File gradleFile = new File(TestBuildGradle.GRADLE_BUILDFILE_FOLDER, "build.gradle");

final File destFile = TestBuildGradle.copyGradlefile(gradleFile);
mockedTransformer.getConfig().getExecutionConfig().setExcludeLog4j(true);
mockedTransformer.getConfig().getExecutionConfig().setExcludeLog4jSlf4jImpl(true);

GradleBuildfileEditor editor = new GradleBuildfileEditor(mockedTransformer, destFile, new ProjectModules(TestBuildGradle.CURRENT));
editor.addDependencies(new File("xyz"));
Expand All @@ -51,7 +51,7 @@ public void testLog4jSlf4jImplExclusionWithConstraints() throws IOException {
final File gradleFile = new File(TestBuildGradle.GRADLE_BUILDFILE_FOLDER, "buildConstraints.gradle");

final File destFile = TestBuildGradle.copyGradlefile(gradleFile);
mockedTransformer.getConfig().getExecutionConfig().setExcludeLog4j(true);
mockedTransformer.getConfig().getExecutionConfig().setExcludeLog4jSlf4jImpl(true);

GradleBuildfileEditor editor = new GradleBuildfileEditor(mockedTransformer, destFile, new ProjectModules(TestBuildGradle.CURRENT));
editor.addDependencies(new File("xyz"));
Expand Down

0 comments on commit d5431fc

Please sign in to comment.