Java – gradle without main class?
Can I use gradle without specifying the main class? I want to create a library and use gradle to manage my dependencies, and it doesn't make sense to create a main class, but I can't seem to find any unnecessary documents
thank you
Solution
It seems that you are using the spring boot gradle plug-in to create a library. It may call task bootrepackage to find the main class. Some errors will be thrown when the main class cannot be found
Use bootrepackage Enabled works for me
bootRepackage.enabled = false
If you use kotlin DSL like me, try the following tasks:
tasks.withType<RepackageTask> { enabled = false }
Also:
val bootRepackage by tasks.getting { enabled = false }
I'm looking for a better answer about the spring boot gradle plug-in, but I haven't found it yet
Alternatively, we can use spring boot dependencies and Io spring. Dependency management, which do not attach the task bootrepackage to our project
plugins { id("io.spring.dependency-management") } dependencyManagement { imports { mavenBom("org.springframework.boot:spring-boot-dependencies:X.Y.Z.RELEASE") } }
But I don't think it's a good idea
Also, if you want to upgrade the spring boot version to 2.0 Y. Z.relax, please change bootrepackage to bootjar