Publish fat jar and thin jar for a project

I am trying to publish both fat jar and thin jar artifacts for a specific project.
When I include the shadow plugin logic to publish the fat jar, bot the artifacts are published with dependencies only.
If I remove the shadow plugin logic and try publishing thin jar, it works well.

Code:
build.gradle changes used for publishing.
publishing {
publications {
code(MavenPublication) {
groupId ‘com.pega.cloud.services.cmdb-service’
artifactId project.name
from components.java
}
shadow(MavenPublication) { publication ->
project.shadow.component(publication)
groupId ‘com.pega.cloud.services.cmdb-service’
artifactId project.name+"-with-dependencies"
}
}
}

artifactoryPublish {
publications (‘code’)
publications (‘shadow’)
}

I have tried using plugin/mavenJava/mavenPlugin instead of code. If I remove the shadow block, I could succesfully publish thin jar. If i include shadow block it is publishing both jars with dependencies included.

Is it possible to publish fat jar and thin jar at a time? Am I missing anything?

It is possible.

Try removing the artifactoryPublish block, and call gradle publish.

(You can also assign to group at the top level instead of calling groupId.)