diff --git a/skippy-gradle-sandbox/build.gradle b/skippy-gradle-sandbox/build.gradle index 12ce9ff..6aa10ae 100644 --- a/skippy-gradle-sandbox/build.gradle +++ b/skippy-gradle-sandbox/build.gradle @@ -16,6 +16,9 @@ repositories { } dependencies { + implementation 'org.apache.logging.log4j:log4j-api:2.20.0' + implementation 'org.apache.logging.log4j:log4j-core:2.20.0' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2' implementation project(':skippy-junit5') diff --git a/skippy-gradle-sandbox/src/main/resources/log4j2.properties b/skippy-gradle-sandbox/src/main/resources/log4j2.properties new file mode 100644 index 0000000..b60b190 --- /dev/null +++ b/skippy-gradle-sandbox/src/main/resources/log4j2.properties @@ -0,0 +1,14 @@ +status = warn +name = PropertiesConfig + +appender.console.type = Console +appender.console.name = ConsoleAppender +appender.console.layout.type = PatternLayout +appender.console.layout.pattern = %-5level %logger{1.} - %msg%n + +rootLogger.level = warn +rootLogger.appenderRefs = console +rootLogger.appenderRef.console.ref = ConsoleAppender + +logger.com_example.name = io.skippy +logger.com_example.level = debug \ No newline at end of file diff --git a/skippy-gradle/src/main/java/io/skippy/gradle/core/AnalyzedFile.java b/skippy-gradle/src/main/java/io/skippy/gradle/core/AnalyzedFile.java index 67178bc..0430926 100644 --- a/skippy-gradle/src/main/java/io/skippy/gradle/core/AnalyzedFile.java +++ b/skippy-gradle/src/main/java/io/skippy/gradle/core/AnalyzedFile.java @@ -16,6 +16,7 @@ package io.skippy.gradle.core; +import org.gradle.api.Project; import org.gradle.api.logging.Logger; import java.io.IOException; @@ -101,21 +102,26 @@ public String getFullyQualifiedClassName() { } /** - * Returns the fully-qualified filename of the source file (e.g., /user/johndoe/repos/demo/src/main/java/com/example/Foo.java). + * Returns the filename of the source file relative to the {@param projectDirectory}, + * (e.g., src/main/java/com/example/Foo.java) * - * @return the fully-qualified filename of the source file (e.g., /user/johndoe/repos/demo/src/main/java/com/example/Foo.java) + * @return the filename of the source file relative to the {@param projectDirectory}, + * (e.g., src/main/java/com/example/Foo.java) */ - public String getSourceFileName() { - return sourceFile.toString(); + public String getSourceFileName(Path projectDir) { + return projectDir.relativize(sourceFile).toString(); } /** - * Returns the fully-qualified filename of the class file (e.g., /user/johndoe/repos/demo/build/classes/java/main/com/example/Foo.class). + * Returns the filename of the class file relative to the {@param projectDirectory}, + * (e.g., src/main/java/com/example/Foo.java) * - * @return the fully-qualified filename of the class file (e.g., /user/johndoe/repos/demo/build/classes/java/main/com/example/Foo.class) + * @return the filename of the class file relative to the {@param projectDirectory}, + * (e.g., src/main/java/com/example/Foo.java) */ - public String getClassFileName() { - return classFile.toString(); + + public String getClassFileName(Path projectDir) { + return projectDir.relativize(classFile).toString(); } /** diff --git a/skippy-gradle/src/main/java/io/skippy/gradle/tasks/AnalyzeTask.java b/skippy-gradle/src/main/java/io/skippy/gradle/tasks/AnalyzeTask.java index e514754..a4ee2eb 100644 --- a/skippy-gradle/src/main/java/io/skippy/gradle/tasks/AnalyzeTask.java +++ b/skippy-gradle/src/main/java/io/skippy/gradle/tasks/AnalyzeTask.java @@ -70,8 +70,8 @@ private void createSkippyAnalysisFile(Project project) { writeString(skippyAnalysisFile, sourceFiles.stream() .map(sourceFile -> "%s:%s:%s:%s:%s".formatted( sourceFile.getFullyQualifiedClassName(), - sourceFile.getSourceFileName(), - sourceFile.getClassFileName(), + sourceFile.getSourceFileName(getProject().getProjectDir().toPath()), + sourceFile.getClassFileName(getProject().getProjectDir().toPath()), sourceFile.getSourceFileHash(project.getLogger()), sourceFile.getClassFileHash(project.getLogger()) ))