This message was deleted.
# community-support
s
This message was deleted.
c
are these Java sources? the
java-library
plugin handles all that for you, with some minor configuration to enable sources/javadoc jar generation,
d
@Chris Lee Yes I am using java 11 . I already used but still facing issue
Copy code
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'idea'
apply plugin: 'maven-publish'
c
Unclear what the issue is. The snippet above looks to be attempting to create * publish source JAR files, which can be handled by built-in means per the provided links.
d
@Chris Lee I have created a Selenium JUnit project using Gradle 8.2. The
src/test
and
src/main
directories contain some generic code (consider this project as a base project). I am trying to publish two JAR files using Gradle 8.2. The first one is for
src/main
, and the other is for
src/test
. I am facing an issue while creating the JAR for
src/test
. When I perform
./gradle publish
, the JAR file is created in Azure. However, the dependencies used in my base project are not available in the
src/test
JAR. Additionally, I can't import code from src/test my base project into another project where I am using that JAR
c
Unclear why this is custom instead of using the built-in packaging/publishing mechanisms. Test code can be redistributed using the test fixtures plugin.
plus1 1
d
@Chris Lee I have existing project and number of people are working on it .I dont want to change existing stucture so looking for solution with above approach. Please help me
c
none of that match the documented examples for configuring / publishing test fixtures - have you tried the conventional way?
d
Sorry which one bit confused here
Actually I want to publish test fixture code to azure artifacts and then other projects should be consume that code after adding dependancy
c
test fixtures are automatically published - why is there a publication defined? What are you attempting to do withe the first
testFixtures
block? Neither of those are necessary for test fixtures to be packaged and published.
d
Ohh let me try to update my code . Thanks @Chris Lee
c
This is how to declare a testFixtures dependency:
implementation(testFixtures("com.yourcompany:basemain-project:8.0.0-SNAPSHOT"))
btw, terminology wise - for gradle a ‘project’ dependency is another project in the same build; this is an external artifact dependency (even if its one of your own published artifacts).
d
@Chris Lee: its still not working. Getting below issue
c
Something is not publishing properly; ensure you are using a recent Gradle version (8.5) and strip out custom group/artifact/version qualifiers (those are pulled from elsewhere by default).
d
You mean while publishing I want to strip out group/artifact/version qualifiers. if so then I am getting below error * What went wrong: Execution failed for task ':publishMavenJavaPublicationToMavenRepository'. > Failed to publish publication 'mavenJava' to repository 'maven' > Invalid publication 'mavenJava': groupId cannot be empty.
c
in your build.gradle file, outside of any block, set
group = "whatever…".
ideally you would set that globally for the build in
gradle.properties
to avoid repeating it for each project.
ditto for
version
Move these as noted earlier in case they are getting in the way; are there any additional plugins in use beyond
java-library
, publishing, test fixtures?
d
Yes , I am using below plugins
Copy code
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'idea'
apply plugin: "net.serenity-bdd.serenity-gradle-plugin"
apply plugin: 'application'
apply plugin: 'org.sonarqube'
apply plugin: 'maven-publish'
apply plugin: 'java-test-fixtures'
@Chris Lee: I have tried publish as per your suggestions but looks like test dependancies are still missing even after properly publing to azure artifacts. I can see dependancies in the external lib in the intellij but unavailable during import
c
perhaps create a separate, minimal project using just the basics, following the Gradle documented samples to get that working, then apply to your real-world scenario.