Add source jar with Gradlegradle/with-sourcegenerate a sources.jar while project build
1// For Gradle 6.0+
2// Require "java" or "java-library" plugin
3java {
4 withSourcesJar()
5}
6
7// For Any Gradle Version
8// no plugin required
9task sourcesJar(type: Jar, dependsOn: jar) {
10 classifier = 'sources'
11 from sourceSets.main.allSource
12}Disclaimer
The code snippet is provided for reference and learning purposes only. Users should use it at their own risk. I, along with the related developers, shall not be held responsible for any direct or indirect losses caused by the use of this code snippet, including but not limited to data loss, computer malfunctions, program errors, etc.