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
text resource from classpath #8472
Comments
Are you trying to get it from the classpath of the plugin on the buildscript? Have you tried something like:
|
Ah, hm, somehow didn't think about Here some findings as run on Windows, configurations { spotbugsStylesheets { transitive false } }
dependencies { spotbugsStylesheets 'com.github.spotbugs:spotbugs:3.1.11' }
/* BOM */ /* ? */ println resources.text.fromArchiveEntry(configurations.spotbugsStylesheets, 'fancy.xsl').asReader().readLine()
/* ? */ /* ? */ println resources.text.fromArchiveEntry(configurations.spotbugsStylesheets, 'fancy.xsl', 'UTF-8').asReader().readLine()
/* ? */ /* ? */ println resources.text.fromUri(getClass().classLoader.getResource('fancy.xsl')).asReader().readLine()
/* OK */ /* OK */ println resources.text.fromArchiveEntry(configurations.spotbugsStylesheets, 'fancy.xsl').asFile().readLines().first()
/* ? */ /* OK */ println resources.text.fromArchiveEntry(configurations.spotbugsStylesheets, 'fancy.xsl', 'UTF-8').asFile().readLines().first()
/* ? */ /* OK */ println resources.text.fromUri(getClass().classLoader.getResource('fancy.xsl')).asFile().readLines().first()
/* BOM */ /* OK */ println resources.text.fromArchiveEntry(configurations.spotbugsStylesheets, 'fancy.xsl').asFile('UTF-8').readLines().first()
/* OK */ /* OK */ println resources.text.fromArchiveEntry(configurations.spotbugsStylesheets, 'fancy.xsl', 'UTF-8').asFile('UTF-8').readLines().first()
/* OK */ /* OK */ println resources.text.fromUri(getClass().classLoader.getResource('fancy.xsl')).asFile('UTF-8').readLines().first()
/* ? */ /* ? */ println resources.text.fromArchiveEntry(configurations.spotbugsStylesheets, 'fancy.xsl').asFile().readLines('UTF-8').first()
/* ? */ /* ? */ println resources.text.fromArchiveEntry(configurations.spotbugsStylesheets, 'fancy.xsl', 'UTF-8').asFile().readLines('UTF-8').first()
/* ? */ /* ? */ println resources.text.fromUri(getClass().classLoader.getResource('fancy.xsl')).asFile().readLines('UTF-8').first()
/* BOM */ /* ? */ println resources.text.fromArchiveEntry(configurations.spotbugsStylesheets, 'fancy.xsl').asFile('UTF-8').readLines('UTF-8').first()
/* ? */ /* ? */ println resources.text.fromArchiveEntry(configurations.spotbugsStylesheets, 'fancy.xsl', 'UTF-8').asFile('UTF-8').readLines('UTF-8').first()
/* ? */ /* ? */ println resources.text.fromUri(getClass().classLoader.getResource('fancy.xsl')).asFile('UTF-8').readLines('UTF-8').first() The main point here is, if not specifying any encodings, it just works with |
Actually I also wonder that there is no variant of |
The encoding problem also is especially problematic if you do not use it yourself but give it to some task. tasks.withType(SpotBugsTask) {
reports {
xml.enabled false
html {
enabled true
stylesheet resources.text.fromUri(getClass().classLoader.getResource('fancy.xsl'))
}
}
} the transformation will not work due to the encoding problem. tasks.withType(SpotBugsTask) {
reports {
xml.enabled false
html {
enabled true
stylesheet resources.text.fromFile(resources.text.fromUri(getClass().classLoader.getResource('fancy.xsl')).asFile('UTF-8'))
}
}
} to make it work. |
I've also hit encoding problem in Should I open another issue specifically about encoding? |
This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution. |
still an issue with version 6.5.1 |
This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution. |
I didn't find a way to do it, besides having a separate non-transitive configuration with one dependency and then use
resources.text.fromArchiveEntry(configurations.myConfiguration, 'my-file.txt')
.It would be nice if you could do something like
resources.text.fromClasspath('my-file.txt')
orresources.text.fromUri('classpath:my-file.txt')
or similar.The text was updated successfully, but these errors were encountered: