-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add temporary debug log messages
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
...src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/FakeMavenManifestFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package tech.apter.junit.jupiter.robolectric.internal | ||
|
||
import org.robolectric.annotation.Config | ||
import org.robolectric.internal.ManifestIdentifier | ||
import org.robolectric.internal.MavenManifestFactory | ||
import org.robolectric.res.Fs | ||
import tech.apter.junit.jupiter.robolectric.internal.extensions.createLogger | ||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
|
||
internal class FakeMavenManifestFactory : MavenManifestFactory() { | ||
|
||
private inline val logger get() = createLogger() | ||
|
||
override fun identify(config: Config): ManifestIdentifier { | ||
val manifestPath = config.manifest | ||
if (manifestPath == Config.NONE) { | ||
return ManifestIdentifier(null as String?, null, null, null, null) | ||
} | ||
|
||
// Try to locate the manifest file as a classpath resource; fallback to using the base dir. | ||
val manifestFile: Path | ||
val resourceName = if (manifestPath.startsWith("/")) manifestPath else ("/$manifestPath") | ||
val resourceUrl = javaClass.getResource(resourceName) | ||
if (resourceUrl != null && "file" == resourceUrl.protocol) { | ||
// Construct a path to the manifest file relative to the current working directory. | ||
val workingDirectory = Paths.get(System.getProperty("user.dir")) | ||
val absolutePath = Fs.fromUrl(resourceUrl) | ||
logger.warn { "user.dir=$workingDirectory" } | ||
logger.warn { "resourceUrl=$resourceUrl" } | ||
logger.warn { "absolutePath=$absolutePath" } | ||
|
||
manifestFile = workingDirectory.relativize(absolutePath) | ||
} | ||
return super.identify(config) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters