You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When publishing with maven-publish the produced jar file should contain the compiled class files.
Current Behavior
The published jar file contains the sources not the class files.
Context (optional)
Gradle 8.1.1
Build time: 2023-04-21 12:31:26 UTC
Revision: 1cf537a
Kotlin: 1.8.10
Groovy: 3.0.15
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 17.0.4.1 (Eclipse Adoptium 17.0.4.1+1)
OS: Mac OS X 13.3.1 x86_64
Steps to Reproduce
Create a project with the following build.gradle
plugins {
id 'java-library'
id 'maven-publish'
}
group ='my.group'
version ='0.0.1-SNAPSHOT'
sourceSets {
src{
main {
java {
srcDir('src/main/java')
srcDir('src/main/java-gen')
}
}
}
}
// WORKAROUND! If you comment this out gradle will report false duplicates
task sourcesJar(type: Jar) {
duplicatesStrategy ='exclude'
from sourceSets.main.allSource
}
java {
withJavadocJar()
withSourcesJar()
}
publishing {
publications {
sonatype(MavenPublication) {
from components.java
}
}
repositories {
maven {
name ='local'
url="${project.rootDir}/repo"
}
}
}
Create a java File und src/main/java like:
publicclassMain {
}
You can leave the source folder src/main/java-gen empty.
Start publishing with:
❯ jar -tf repo/my/group/PublishError/0.0.1-SNAPSHOT/PublishError-0.0.1-*-1.jar
META-INF/
META-INF/MANIFEST.MF
Main.java
Gradle version
8.1.1
Build scan URL (optional)
No response
Your Environment (optional)
Gradle 8.1.1
Build time: 2023-04-21 12:31:26 UTC
Revision: 1cf537a
Kotlin: 1.8.10
Groovy: 3.0.15
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 17.0.4.1 (Eclipse Adoptium 17.0.4.1+1)
OS: Mac OS X 13.3.1 x86_64
The text was updated successfully, but these errors were encountered:
First of all, your Gradle script looks a bit strange:
sourceSets {
src{ // <-- What is it for? Are you defining `src` source set?
main {
java {
srcDir('src/main/java')
srcDir('src/main/java-gen')
}
}
}
}
I suppose the issue is that you add a dir that is already added: src/main/java. By default, this dir is already presented in the main source set. So, the fix, I suppose, is to remove srcDir('src/main/java') line.
Your issue appears to be a question about how to use Gradle. Your question might be answered in Gradle documentation or on our community Slack or forums. Find links to these resources on help.gradle.org.
If you think you have come across a Gradle bug, please file a new issue describing the problem and how to reproduce it.
If you think Gradle is missing a feature, please file a new issue describing your use case for the feature.
Expected Behavior
When publishing with maven-publish the produced jar file should contain the compiled class files.
Current Behavior
The published jar file contains the sources not the class files.
Context (optional)
Gradle 8.1.1
Build time: 2023-04-21 12:31:26 UTC
Revision: 1cf537a
Kotlin: 1.8.10
Groovy: 3.0.15
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 17.0.4.1 (Eclipse Adoptium 17.0.4.1+1)
OS: Mac OS X 13.3.1 x86_64
Steps to Reproduce
Create a project with the following build.gradle
Create a java File und src/main/java like:
You can leave the source folder src/main/java-gen empty.
Start publishing with:
gradle publishSonatypePublicationToLocalRepository
List the content of published jar file:
Gradle version
8.1.1
Build scan URL (optional)
No response
Your Environment (optional)
Gradle 8.1.1
Build time: 2023-04-21 12:31:26 UTC
Revision: 1cf537a
Kotlin: 1.8.10
Groovy: 3.0.15
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 17.0.4.1 (Eclipse Adoptium 17.0.4.1+1)
OS: Mac OS X 13.3.1 x86_64
The text was updated successfully, but these errors were encountered: