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

Plugin doesn't work on Windows #124

Open
tprochazka opened this issue Jul 20, 2023 · 3 comments
Open

Plugin doesn't work on Windows #124

tprochazka opened this issue Jul 20, 2023 · 3 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@tprochazka
Copy link

The problem is described here
https://issuetracker.google.com/issues/287505134

The issue is that class
build/intermediates/keeper/externalStaging/classes.jar
Is created by using \ in the path instead of /

I found a possible source of this issue, it is here
https://github.com/slackhq/keeper/blob/main/keeper-gradle-plugin/src/main/java/com/slack/keeper/ZipFlingerExt.kt#L33
It uses absolutePath to generate full qualified class name which is then used for adding files to the output jar

On Windows it produces

\com\slack\keeper\example\c\TestOnlyCClass.class
\com\slack\keeper\sample\ApplicationUsedClass.class

which is not correct.

I tried to fix it in the most simple way by using replace("\\", "/")

internal fun File.classesSequence(): Sequence<Pair<String, File>> {
  val prefix = absolutePath
  return walkTopDown()
    .filter { it.extension == "class" }
    .filterNot { "META-INF" in it.name }
    .sortedBy { it.invariantSeparatorsPath }
    .map { it.absolutePath.removePrefix(prefix).replace("\\", "/").removePrefix("/") to it }
}

It now generates a different exception
Caused by: com.android.tools.r8.utils.AbortException: Type com.slack.keeper.sample.KeeperSampleTest is defined multiple times: C:\PJazyky\_Projekty_net\keeper\sample\build\intermediates\keeper\externalStagingAndroidTest\classes.jar:\com\slack\keeper\sample\KeeperSampleTest.class, C:\PJazyky\_Projekty_net\keeper\sample\build\intermediates\keeper\externalStagingAndroidTest\classes.jar:com/slack/keeper/sample/KeeperSampleTest.class
So there is still a somewhere else similar problem. I will try to find it.

@tprochazka tprochazka added the bug Something isn't working label Jul 20, 2023
@ZacSweers ZacSweers added the help wanted Extra attention is needed label Jul 20, 2023
@ZacSweers
Copy link
Collaborator

As mentioned in the issue, PRs welcome. We don't use or support windows in any projects we work on.

@tprochazka
Copy link
Author

You just probably know better where is used file path, which can contain \ as a java classpath where must be /.
So far I found nothing else than File.classesSequence().

@ZacSweers
Copy link
Collaborator

I'm not planning to work on this, would need to be a community-contributed PR if it's going to happen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants