Closed luogeshibu closed 3 months ago
vagrant@ubuntu:~/my_spring_boot$ tree . . ├── BUILD.bazel ├── src │ └── main │ ├── java │ │ └── com │ │ └── example │ │ └── devops │ │ └── ci │ │ ├── BUILD.bazel │ │ ├──CIApplicationService.java # my spring boot main function file. │ │ ├── aspect │ │ │ ├── BUILD.bazel │ │ │ └── OperationalLogAspect.java │ │ ├── common │ │ │ ├── BUILD.bazel │ │ │ └── CommonUtils.java │ │ ├── config │ │ │ ├── BUILD.bazel │ │ │ ├── MvcConfig.java │ │ │ └── RestTemplateConfig.java │ │ ├── controller │ │ ├── BUILD.bazel │ │ ├── BuildDefinitionAuditController.java │ │ ├── ...... │ │ └── RefreshRadiatorController.java │ ├── resources │ │ ├── application.properties │ │ ├── META-INF │ │ │ └── additional-spring-configuration-metadata.json │ │ └── static │ │ ├── css │ │ │ ├── error.css │ │ │ └── main.css │ │ ├── images │ │ │ ├── Banner_Trimmed.png │ │ │ ├── ...... │ │ │ └── Stages.png │ │ └── js │ │ ├── debugDataSet.js │ │ ├── ...... │ │ └── util.js │ └── webapp │ └── jsp │ ├── ...... │ └── manage.jsp └── WORKSPACE.bazel
29 directories, 82 files
This is my part of the spring boot project tree. My spring boot application before using Gradle for building system tools. and it can build successfully and this spring boot project is already run on the product environment. The Gradle builds the spring boot project by WAR package. Now I only want to use Bazel with my spring boot application.
now I can use the java_binary rule to run my spring application. I can access Swagger UI, PNG, CSS, and JS. But I can not access my src/main/webapp/jsp/*.jsp files. we also find many documents on StackOverflow (https://stackoverflow.com/questions/21243690/is-it-possible-with-spring-boot-to-serve-up-jsps-with-a-jar-packaging) that said jar package can not run with JSP files. So currently, I need to build a war package with my spring boot project. Thanks a lot.
We're looking to make Bazel increasingly more language-agnostic, but this could be something worth adding to a java rules related repository.
A quick search yielded https://github.com/bmuschko/rules_java_war . Does that work for you?
If not, consider filing a FR with https://github.com/bazel-contrib/rules_jvm or https://github.com/bazelbuild/rules_java
https://github.com/bmuschko/rules_java_war. This is not working with my project. this rule supports the spring boot project tree is different with my project. I can not change my project tree because my project is already working with gradle build tools. Now I only want to use Bazel to build and run my project.
This is not working with my project
Could you provide a link to your project repository?
This is not working with my project
Could you provide a link to your project repository?
Hi, hvadehra, Thank you for your reply. this is our private repository, I can provide the project tree.
and for this rule https://github.com/bmuschko/rules_java_war, the project tree is like below:
It's hard to say exactly what changes are needed without having a repro, but I would expect such a packaging rule to be generally simple. I had a go at it: https://gist.github.com/hvadehra/b0e4c9f56056af8d6f4d5e8733652c6e
Note: this is the result of just a few minutes of coding but appears to produce a working WAR for a trivial springboot project. You may need some small changes to the rule to make it work perfectly for you, but I think it's simple enough for anyone with basic Starlark experience. Hope this helps.
because My spring boot needs to support JSP files, but I find that the jar package can not support JSP files, So I want to create a WAR package with Bazel. I know the java_binary rule can create a jar package. and we already use the java_binary rule to run the spring boot application, we can run it, and we can access the swagger UI, but we can not access the JSP page, I only want to create the WAR package. Thanks.