Replies: 26 comments
-
Ho, Thiago! The file tree structure a project uses to organize its Java sources should(!) not matter to Bach. Bach infers the modular setup by locating So, yes, building a modular Java project using standard Maven structure is supported - perhaps with a little help/guidance/tweaks. The Piranha project looks like a very good candidate to verify this:
Keen to try it out?
|
Beta Was this translation helpful? Give feedback.
-
Here you go |
Beta Was this translation helpful? Give feedback.
-
Thanks. Let's see what happpened. All external modules...
...must be present in the Then, a few test-related modules were put into the So, Bach needs some help here: If you create a @com.github.sormuras.bach.project.ProjectInfo(
modules = {"cloud.piranha.api"},
tests = {}
)
module build {
requires com.github.sormuras.bach;
} ...at least one module should be created. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, the folder
Sure, we can skip them for now.
Well, I tried your example and it didn't find any module.
But changing the modules to So now I'll use the ProjectInfo annotation to configure further. Looks very promising :) |
Beta Was this translation helpful? Give feedback.
-
Dooh! My fault. Thought, that passing module names was supported. Here's the bach/.bach/build/module-info.java Lines 23 to 26 in 020995d |
Beta Was this translation helpful? Give feedback.
-
Well, for one module it worked, but as soon as I specify two, the Javac starts to complain: Maybe the handling for multiple modules specified in the ProjectInfo annotation doesn't work? I've specified the following: @com.github.sormuras.bach.project.ProjectInfo(
version = "21.2.0-SNAPSHOT",
modules = {"api/src/main/java/module-info.java", "naming/api/src/main/java/module-info.java"},
tests = {}
)
module build {
requires com.github.sormuras.bach;
} (Both directories exists) |
Beta Was this translation helpful? Give feedback.
-
No, seems like you found a bug in Bach. The Can you please call the following command directly in your shell?
|
Beta Was this translation helpful? Give feedback.
-
That worked! |
Beta Was this translation helpful? Give feedback.
-
I've got to say: building with Bach is way faster than with Maven. Of course, the Maven build does a lot of extra stuff, but interactive development is way faster! (Running with I just want to know which way we should do to actually run the tests with JUnit. I'm struggling a little with that. I've added the module-info.java in the tests and tried to put the Tweak with JUnit. Is there somewhere any example? |
Beta Was this translation helpful? Give feedback.
-
Thanks for your great feedback. Much appreciated.
Yes, local launchers cut boot times by a lot: bach(.bat)
Best example is Bach itself. https://github.com/sormuras/bach/blob/releases/16/.bach/build/module-info.java#L17-L22 tests = {
"com.github.sormuras.bach/test/java-module/module-info.java",
"test.base/test/java/module-info.java",
"test.integration/test/java/module-info.java",
},
requires = {"org.junit.platform.console"}, Here are 3 test modules in play: 1 in-module test module and 2 extra-module test modules. The first is patched at compile time into the main module from the main code space. The other 2 keep the modular boundaries intact and use other modules via their API. Find basic information and more details about it here: https://sormuras.github.io/blog/2018-09-11-testing-in-the-modular-world You may also copy and paste your current |
Beta Was this translation helpful? Give feedback.
-
Sure. (Actually thanks for helping me ;) import com.github.sormuras.bach.project.ProjectInfo;
import com.github.sormuras.bach.project.ProjectInfo.Link;
import com.github.sormuras.bach.project.ProjectInfo.Tweak;
@ProjectInfo(
version = "21.2.0-SNAPSHOT",
modules = {
"api/src/main/java/module-info.java",
"naming/api/src/main/java/module-info.java", "naming/impl/src/main/java/module-info.java", "naming/thread/src/main/java/module-info.java",
"policy/api/src/main/java/module-info.java", "policy/impl/src/main/java/module-info.java",
"resource/api/src/main/java/module-info.java", "resource/impl/src/main/java/module-info.java",
"servlet/api/src/main/java/module-info.java",
"pages/wasp/src/main/java/module-info.java",
"webapp/api/src/main/java/module-info.java", "webapp/impl/src/main/java/module-info.java", "webapp/annotationscan/src/main/java/module-info.java", "webapp/scinitializer/src/main/java/module-info.java", "webapp/tempdir/src/main/java/module-info.java", "webapp/webannotation/src/main/java/module-info.java", "webapp/webxml/src/main/java/module-info.java",
"modular/modular/src/main/java/module-info.java",
"http/api/src/main/java/module-info.java", "http/impl/src/main/java/module-info.java", "http/webapp/src/main/java/module-info.java", "http/grizzly/src/main/java/module-info.java", "http/embedded/src/main/java/module-info.java", "http/nano/src/main/java/module-info.java", "http/jdk/src/main/java/module-info.java", "http/undertow/src/main/java/module-info.java",
"extension/servlet/src/main/java/module-info.java",
"transaction/api/src/main/java/module-info.java", "transaction/impl/src/main/java/module-info.java",
"cdi/weld/src/main/java/module-info.java",
"nano/src/main/java/module-info.java",
"embedded/src/main/java/module-info.java",
"server/src/main/java/module-info.java",
},
tests = {
"http/tests/src/main/java/module-info.java",
// "http/grizzly-test/src/main/java/module-info.java",
"http/impl-test/src/main/java/module-info.java"
// "transaction/api/src/test/java/jakarta/transaction/tests/module-info.java"
},
// HTTP - Undertow
requires = {"xnio.api"},
links = {
// Pages - WASP
@Link(module = "org.glassfish.wasp", to = "org.glassfish.wasp:wasp:3.0.1"),
@Link(module = "grizzly.framework", to = "org.glassfish.grizzly:grizzly-framework:3.0.0"),
@Link(module = "grizzly.http", to = "org.glassfish.grizzly:grizzly-http:3.0.0"),
@Link(module = "grizzly.http2", to = "org.glassfish.grizzly:grizzly-http2:3.0.0"),
@Link(module = "grizzly.http.server", to = "org.glassfish.grizzly:grizzly-http-server:3.0.0"),
@Link(module = "jakarta.cdi", to = "jakarta.enterprise:jakarta.enterprise.cdi-api:3.0.0"),
@Link(module = "jakarta.interceptor.api", to = "jakarta.interceptor:jakarta.interceptor-api:2.0.0"),
@Link(module = "undertow.core", to = "io.undertow:undertow-core:2.2.3.Final"),
@Link(module = "xnio.api", to = "org.jboss.xnio:xnio-api:3.8.4.Final"),
@Link(module = "jakarta.security.enterprise.api", to = "jakarta.security.enterprise:jakarta.security.enterprise-api:2.0.0"),
@Link(module = "weld.api", to = "org.jboss.weld:weld-api:4.0.Final"),
@Link(module = "weld.core.impl", to = "org.jboss.weld:weld-core-impl:4.0.0.Final"),
@Link(module = "weld.spi", to = "org.jboss.weld:weld-spi:4.0.Final"),
@Link(module = "weld.servlet.core", to = "org.jboss.weld.servlet:weld-servlet-core:4.0.0.Final"),
@Link(module = "weld.environment.common", to = "org.jboss.weld.environment:weld-environment-common:4.0.0.Final"),
@Link(module = "arquillian.container.spi", to = "org.jboss.arquillian.container:arquillian-container-spi:1.7.0.Alpha6"),
@Link(module = "arquillian.core.spi", to = "org.jboss.arquillian.core:arquillian-core-spi:1.7.0.Alpha6"),
@Link(module = "io.netty.all", to = "io.netty:netty-all:4.1.58.Final"),
@Link(module = "jakarta.security.auth.message", to = "jakarta.authentication:jakarta.authentication-api:2.0.0"),
@Link(module = "jakarta.security.jacc", to = "jakarta.authorization:jakarta.authorization-api:2.0.0"),
@Link(module = "jersey.common", to = "org.glassfish.jersey.core:jersey-common:3.0.0"),
@Link(module = "maven.plugin.annotations", to = "org.apache.maven.plugin-tools:maven-plugin-annotations:3.6.0"),
@Link(module = "maven.plugin.api", to = "org.apache.maven:maven-plugin-api:3.6.3"),
@Link(module = "microprofile.jwt.auth.api", to = "org.eclipse.microprofile.jwt:microprofile-jwt-auth-api:1.1.1"),
@Link(module = "microprofile.jwt.auth", to = "org.omnifaces:microprofile-jwt-auth:1.0.1"),
@Link(module = "shrinkwrap.api", to = "org.jboss.shrinkwrap:shrinkwrap-api:1.2.6"),
@Link(module = "shrinkwrap.descriptors.api.base", to = "org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-api-base:2.0.0"),
@Link(module = "shrinkwrap.resolver.api.maven", to = "org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api-maven:3.1.4"),
@Link(module = "smallrye.health", to = "io.smallrye:smallrye-health:3.0.0-RC2")
},
tweaks = {
@Tweak(tool = "jar(cloud.piranha.server)", with = {"--main-class", "cloud.piranha.server.ServerPiranha"}),
@Tweak(tool = "junit", with = "")
}
)
module build {
requires com.github.sormuras.bach;
} |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, we use Shrinkwrap, and it is not JPMS friendly. They use a proprietary ServiceLoader format, inside the META-INF/services; as result, the ModuleFinder will try to parse it as a service and it will fail, thus causing the whole process to not even start (FYI: com.github.sormuras.bach.BuildException: Build failed: java.lang.module.FindException: Unable to derive module descriptor for .bach/external-modules/shrinkwrap.resolver.api.jar). I guess by now we won't be able to use Bach in the simplest form (with the ProjectInfo annotation). Maybe using the Builder API would work. |
Beta Was this translation helpful? Give feedback.
-
You won the prize for compiling 30+ modules in one go with Bach. Nice feat!
Does this happen already during test space compilation or later, when running tests with junit on the module path? |
Beta Was this translation helpful? Give feedback.
-
🏆
What's actually happening: The ProjectInfo and the log I've sent is before I tried to add JUnit configuration. But I tried to compile all the modules with Bach. Unfortunately, in one place we need the shrinkwrap-resolver-api. If we put that library in the external-modules, the build doesn't start up. Is there a way to use the --patch-module without knowing the location of the Jar? If we could patch it to another module it could build and after that, I would be able to actually try the tests. I guess now I have a little understanding of what I need to configure to get the tests running (using the Bach itself as example). |
Beta Was this translation helpful? Give feedback.
-
Well, I could use the --patch-module, but I moved the shrinkwrap-api to the .bach directory and used the following tweak:
Now I'm getting: No module-info.java found in: []. I know that we don't have the module-info for all tests, but with this information it is not possible to detect from where it is coming from. Edit: I've looked into the logs and it specifies from where it tried to find the test module. I fixed it. |
Beta Was this translation helpful? Give feedback.
-
(In the logs the |
Beta Was this translation helpful? Give feedback.
-
Oh no: |
Beta Was this translation helpful? Give feedback.
-
Tried to find the reason for why Oh yes! 😎
Well, that's unfortunate. Either a bug in Bach (wrong configuration of module layering) or a setup problem with the test module named |
Beta Was this translation helpful? Give feedback.
-
@TomerFi had a similar issue. My reply reads:
Could be the show-stopper I mentioned above. Best solution: get Shrinkwrap to behave on the module path. |
Beta Was this translation helpful? Give feedback.
-
Sure, it would be the best way to solve some workarounds that we currently have in Piranha. Looks like the Shrinkwrap (and Arquillian, the parent project) has slowed down the development 😞 Best way would be forking it and release a new version, but I guess it is not so easy because of their proprietary service loader and the split packages across several jars. For now we "solved" it by using --patch-module to avoid the split packages |
Beta Was this translation helpful? Give feedback.
-
@arjantijms I knew shrinkwrap would come back and bite :D |
Beta Was this translation helpful? Give feedback.
-
😳 :P But indeed, "Best solution: get Shrinkwrap to behave on the module path." We should invest some time into that, do a PR upstream, and in the meantime use our own fork if needed. |
Beta Was this translation helpful? Give feedback.
-
I've got something working here: https://github.com/Thihup/shrinkwrap/tree/patches |
Beta Was this translation helpful? Give feedback.
-
I like where this discussion and actions are headed to. 👍 |
Beta Was this translation helpful? Give feedback.
-
Well... While the Shrinkwrap project itself was straightforward to modularize, we cannot say the same thing for the shrinkwrap-resolver. The main reason is that it requires the Maven project, and the Maven project has split packages 🙄. |
Beta Was this translation helpful? Give feedback.
-
Yikes. Maven 5 ... if ever. There're sooo many artifacts that make up "the Maven project". Ah, MNG-7037 looks promising. We'll see. |
Beta Was this translation helpful? Give feedback.
-
Hi!
Is there a way to compile projects using the Maven structure?
I'd like to give this project a try compiling the Piranha project.
Currently the project uses a standard Maven structure to compile the modules.
Beta Was this translation helpful? Give feedback.
All reactions