Comments (7)
I think this issue can be split into two separate issues, this for tracking improvements to module support & another for the bug with MemoryFileManager
.
from elementary.
Looking at it, I think a decent short-term fix will be to patch the @Options
annotation. Personally, I haven't really used Java's modules. Would you mind elaborating on the following? It'll greatly help with fleshing out the feature!
- What difficulty do you currently face with loading modules?
- How do you currently load modules?
- How would an annotation like
@Module
work?
from elementary.
The idea would be for those annotations to mimic the --module
, --module-path
, --module-source-path
and --processor-path
arguments to the compiler, while also defaulting the base of path arguments to the src/test/resources
folder or .m2/repository
, rather than the module root folder (depending on which argument we are talking about), so:
@ExtendsWith(JavacExtension.class)
@Options("--module test -d .\\unimportant\\because\\in-memory\\but\\mandatory --module-source-path .\\src\\test\\resources\\modules --module-path my\\path\\to\\.m2\\repository\\my\\path\\to\\annotations\\1.0-SNAPSHOT\\annotations-1.0-SNAPSHOT.jar --processor-path my\\path\\to\\.m2\\repository\\my\\path\\to\\annotations\\1.0-SNAPSHOT\\annotations-1.0-SNAPSHOT.jar")
@Processors(MyAnnotationProcessor.class)
class MyAnnotationProcessorTest { ... }
Would become:
@ExtendsWith(JavacExtension.class)
@Module(name = "test", sourcePath = ".\\modules") // sourcePath is optional and points to src/test/resources by default
@ModulePath("my\\path\\to\\annotations\\1.0-SNAPSHOT\\annotations-1.0-SNAPSHOT.jar")
@ProcessorPath("my\\path\\to\\annotations\\1.0-SNAPSHOT\\annotations-1.0-SNAPSHOT.jar")
@Processors(MyAnnotationProcessor.class)
class MyAnnotationProcessorTest { ... }
from elementary.
Alternatively, for the module path and processor path, you could maybe specify them by their groupId, artifactId and version:
@ExtendsWith(JavacExtension.class)
@Module(name = "test", sourcePath = ".\\modules")
@ModulePath("my.path.to:annotations:1.0-SNAPSHOT")
@ProcessorPath("my.path.to:annotations:1.0-SNAPSHOT")
@Processors(MyAnnotationProcessor.class)
class MyAnnotationProcessorTest { ... }
from elementary.
I'm not fully happy with how the module path and processor path are specified in the current implementation in my Pull Request. Right now it feels a bit fragile due to its reliance on OS specific environment variables and the assumption that the .m2 folder is located in the user's home folder.
@Pante Do you have any better ideas? Or will these issues also be resolved by your PR?
from elementary.
My PR covers the use-case where the project that's under test is a module and relies on other modules. It does so by checking if the annotated test class is part of a module and adds all its dependencies to the classpath with zero configuration. I'm not sure if my PR covers 100% of what your PR does.
from elementary.
I’m going to close this issue for now since I believe that adding low-level support for this directly in Compiler
addresses most of the use-cases. The only exception being compiling module-info files. Even then, I could not find a way to support it.
Please feel free to reopen/comment on this issue if there’s any use-cases that #168 doesn’t address!
from elementary.
Related Issues (17)
- Your .dependabot/config.yml contained invalid details HOT 1
- [BUG] Repo missing in elementary/README.md HOT 9
- [FEATURE REQUEST] Rename @Case to something better HOT 36
- [BUG] Cannot use source with intentional compile errors for ToolsExtension HOT 10
- [BUG] `MemoryFileManager ` does not handle modules correctly
- [FEATURE REQUEST] Better support for parameterized tests HOT 1
- [BUG] Modules don't compile HOT 1
- Deploy artifacts to maven central HOT 12
- Dependency Dashboard
- [FEATURE REQUEST] Auto-format pull requests
- [FEATURE REQUEST] Primitives for Module support HOT 7
- [BUG] com.karuslabs:satisfactory 1.1.3 is not available HOT 2
- Requires `org.junit.jupiter:junit-jupiter-params`.
- Documentation lacks sufficient setup information to prevent missing class error. HOT 5
- Documentation examples require Utilitary. HOT 1
- Missing page "Why java 11?" HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elementary.