Giter Site home page Giter Site logo

Comments (7)

Pante avatar Pante commented on July 19, 2024

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.

Pante avatar Pante commented on July 19, 2024

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.

CC007 avatar CC007 commented on July 19, 2024

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.

CC007 avatar CC007 commented on July 19, 2024

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.

CC007 avatar CC007 commented on July 19, 2024

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.

Pante avatar Pante commented on July 19, 2024

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.

Pante avatar Pante commented on July 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.