Hey all. Hoping somebody with experience can help....
# multiplatform
a
Hey all. Hoping somebody with experience can help. Trying to work on uploading to jenkins and nexus pipelines. In our old project we had custom createPOM and buildXCFramework tasks that we used in our JenkinsFile, however since the upgrade to gradle 7 this has to change. Does anybody know how we can do something similar with gradle 7? Build the pom and ios framework etc
b
For POM, just apply maven-publish plugin and KMP plugin will autoconfigure the publications for you.
a
I have applied maven-publish. What do I need to run to configure the POM though? Isn't there some issues with dependencies being attached to it i thought
b
Can't recall the task name, but have a look at what this prints and try a few
./gradlew tasks | grep pom
a
doesnt seem to print anything
b
Are you able to share your buildfile with maven-publish plugin applied?
a
not the whole one, but I have added these:
Copy code
plugins {
    kotlin("multiplatform")
    kotlin("native.cocoapods")
    id("kotlinx-serialization")
    id("com.android.library")
    id("org.sonarqube")
    id("org.owasp.dependencycheck")
    id("com.squareup.sqldelight")
    id("maven-publish")
}
group = "com.testmultiplatform"
version = "1.0"

kotlin {
    android {
        publishLibraryVariants("release", "debug")
    }
}
i ran the command ./gradlew publishToMavenLocal()
b
Did it publish anything?
a
and i see in my multiplatform lib, under build/outputs I have the aar: MultiplatformLib-debug.aar
b
If so, run
./gradlew publishToMavenLocal --console=plain
and see what tasks referring to POM were executed.
a
generatePomFileForAndroidDebugPublication generatePomFileForAndroidReleasePublication generatePomFileForIosArm64Publication generatePomFileForIosSimulatorArm64Publication generatePomFileForIosX64Publication generatePomFileForKotlinMultiplatformPublication
they are the ones with POM in it
b
There we go, no have a look through
build
folder to figure out where these generated POMs are placed
a
would that be the pom-default.xml files? I see under publications
b
I believe so. Although double-check if it matches the one that's published by
publishToMavenLocal
a
How can I check that?
This pom does seem to contain libraries I am using
b
Manual inspection or just diff the two files in intellij
a
Where is the one that is published by publishToMavenLocal task though, not sure where that goes
b
~/.m2/repository/my/group/module/version/
a
Nice, thanks. it does seem to be the same! Thanks for the help with this. I thought there was going to be issues with the library being built or something due to dependencies. Do you know how it would for for ios? I see that the artifactId that is inside the pom-default is what I should of been using for building the android app with gradle using the library, so now I need to check the ios version
Or does that work that way already since its using cocoapods
b
I cannot comment on IOS side of things, unfortunatelly. Looks like pom-default is used as a template. Have another look through build directory to see if there are any other POMs generated. To keep things simple, I recommend running
./gradlew clean generatePomFileForAndroidReleasePublication
beforehand to get rid of unrelated files.
a
No worries. Yeah was about to ask that, in our old project we were doing it like this in the JenkinsFile:
Copy code
// android library
def libraryName = "multiplatformtest-android"
def aarFiles = findFiles(glob: '**/outputs/**/*.aar')
echo "AarFiles: ${aarFiles}"
aarFilePath = aarFiles[0].path
def pomFiles = findFiles(glob: "**/outputs/**/${libraryName}-${versionInfo.FullSemVer}.xml")
echo "pomFiles: ${pomFiles}"
pomFilePath = pomFiles[0].path
nexusCommonFileName = "${env.companyMavenRelease}com/ourcompany/${libraryName}/${versionInfo.FullSemVer}/${libraryName}-${versionInfo.FullSemVer}"
echo "Uploading to: ${nexusCommonFileName}"
buildHelper.uploadFileToNexus(aarFilePath, 'application/java-archive', "${nexusCommonFileName}.aar", "$USERNAME", "$PASSWORD", os)
buildHelper.uploadFileToNexus(pomFilePath, 'application/xml', "${nexusCommonFileName}.pom", "$USERNAME", "$PASSWORD", os)
Which is different to what it would look like here, since its now in a publications folder, but also no versions or library names
b
To get the version, either set in in the buildfile, gradle.properties file or pass it in via CLI
./gradlew doSomething -Pversion=4.2.0
Not sure what you mean by missing library names.
a
well in build.gradle i have
Copy code
version = "1.0"
what i mean by library names is, if you look at the old project code i pasted above, youll see that it looks in **/outputs/**/ And finds the .aar and .xml that way
while after cleaning and running generatePomFileForAndroidReleasePublication on the new project
it just looks like this
b
And nothing else??
a
the old one was multiplatformLibName-android-1.0
Yep thats all that was done there, which i guess makes sense since generatePomFileForAndroidReleasePublication sounds like it just makes a pom file
publishToMavenLocal seems to build aars and poms
b
Well worst-case you could just run
publishToMavenLocal
and grab required files from
~/.m2
although that would be a lot of unnecessary work for a few simple files.
I'll have a look at my own projects later to see if I can find something better for you.
a
Appreciate it! So I can run publishToMavenLocal, and then in my JenkinsFile I can just do more hard coded stuff i suppose