This message was deleted.
# community-support
s
This message was deleted.
๐Ÿงต 1
v
Please do not split topics across several threads. This makes following the conversation in the threads view very hard as the context of the other messages is missing. If you have additional information either edit the original message or post to its thread. Regarding the problem, I don't think you should set the
Main-Class
attribute like that, especially as Spring Boot builds a good-practice fat jar that needs to be launched through its bootstrap class iirc. So if you remove that configuration and just take the result of the
bootJar
task, I think it should run properly.
a
@Vampire when I remove the manifest inside task tasks.withType<Jar> it complains about missing manifest file when I try to run generated jar through java -jar application.jar. Also I am able to run it directly from the main class but any deployment tool is not able to run it as it is missing location of main class inside manifest.
v
Are you sure you are using the result of
bootJar
, not
jar
?
How does the content list of the jar look like?
a
I extracted the jar and there are package folders along with meta-inf folder containing manifest file
Manifest file doesnt contain the main class info if I remove the Jar task manifest attribute
@Vampire
๐Ÿง 1
v
Can you show it?
Yeah, as I said, that is not the good-practice fat jar that is produced by Spring Boot and would properly contain your dependencies, but just the normal
jar
only containing your code.
a
I am using application plugin along with spring-boot should I remove it
how do I ensure that spring boot jar gets created and not the normal jar?
v
By default the
jar
task even is disabled with the spring boot plugin applied, so if you actually can execute the
jar
task you manually enabled it. But as I said, use the
bootJar
task to produce the right jar.
a
tasks.named<BootJar>("bootJar") { archiveClassifier.set("boot") }
this way?
v
If you look inside you will see a
BOOT-INF
directory that contains all your dependencies in a
lib
directory, all your code and resources in a
classes
directory, and besides the
BOOT-INF
folder
org/springframework/boot/loader/...
classes.
this way?
what "this way?"? That is setting the classifier for the boot jar, yes.
But you don't need that if you are happy with the default
a
spring documentation only tells to apply the springframework boot plugin so I dont need any specific config in the bootJar task correct
v
If you are happy with the defaults, yes.
a
ok let me try once again as it is not getting generated for me somehow
v
What task do you invoke?
a
Copy code
tasks.withType<JavaCompile>() {
    options.encoding = "UTF-8"
}

tasks.withType<Javadoc>() {
    options.encoding = "UTF-8"
}

tasks.withType<Test> {
    useJUnitPlatform()}
v
I asked what you invoke, not what you configure
./gradlew <what do you do here?>
a
./gradlew clean build -x test
v
Maybe
bootJar
is not wired to
build
. So as I said, invoke the
bootJar
task.
And don't always use
clean
task, that is a bad habit coming from Maven which was unreliable if you did not always run with
clean
. If you need that in a Gradle build, you have a build bug somewhere.
It just wastes your time by hindering Gradle to do one of the things it is excellent in, avoiding unnecessary work.
โœ… 1
a
is it not wired by default -bootJar to build?
v
I don't know, I seldomly used Spring Boot. If it is not, you can wire it, for example to
assemble
which is the task that also depends on
jar
and is depended upon by
build
So
Copy code
tasks.assemble {
    dependsOn(tasks.bootJar)
}
then
./gradlew build
will also build the boot jar
Or actually you seem to intend executing
assemble
, not
build
, then you do not need to suppress
test
task.
a
yes I want to skip any test or check tasks
v
Because
build
depends on
assemble
and
check
while
assemble
depends on
jar
and
check
depends on
test
(and possibly other verification tasks)
a
sure will use assemble directly
is it bad practice to use application plugin with spring boot plugin
Thanks for your help @Vampire I think I should be able to resolve
๐Ÿ‘Œ 1
v
is it bad practice to use application plugin with spring boot plugin
I don't know. Maybe not as the Spring Boot Plugin has some support for when the
application
plugin is applied. The question is, whether it is necessary, whether you really want it and what it does.
a
from spring documentation: Executable jars can be built using the
bootJar
task. The task is automatically created when the
java
plugin is applied and is an instance of
BootJar
. The
assemble
task is automatically configured to depend upon the
bootJar
task so running
assemble
(or
build
) will also run the
bootJar
task.
but build is not running bootJar for me. I can do ./gradlew bootJar but I hve to run ./gradlew check seperately in the jenkins script
@Vampire
v
Don't ping me, that is unnecessary in a conversation I'm taking part in already anyway and in any other conversation is extremely rude unless you really need something specifically from me
a
My issue is still unresolved but thanks for your help
v
As I said, I seldomly use Spring Boot. If it documents that
assemble
is wired to
bootJar
but it isn't, you should probably open a bug report to Spring Boot.