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

issue/4: Make paths in analyzedFiles.txt relative #19

Merged
merged 1 commit into from
Nov 28, 2023
Merged
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
3 changes: 3 additions & 0 deletions skippy-gradle-sandbox/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
14 changes: 14 additions & 0 deletions skippy-gradle-sandbox/src/main/resources/log4j2.properties
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.skippy.gradle.core;

import org.gradle.api.Project;
import org.gradle.api.logging.Logger;

import java.io.IOException;
Expand Down Expand Up @@ -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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
))
Expand Down