6

I try to change the version while publishing a android project to my local maven repository. Simple publishing works fine with./gradlew publishToMavenLocal.

While researching I found out that it should be possible to override the version number of my maven package on executing the publishing process. But when executing for example publishToMavenLocal -Pversion="asdf" this does not change the version in anyway. it seems like it is ignored.

I got the idea of the -Pversion flag from the comments of this post Furthermore also the gradle docs say that it should be possible to override the version in some way when building it:

Overriding the default identity values is easy: simply specify the groupId, artifactId or version attributes when configuring the MavenPublication.

i don't know if i got anything wrong but is there a way to override the version of a maven package. Also publishing something like -SNAPSHOT to my local maven repo would help me a lot.

tscheppe
  • 588
  • 5
  • 18

2 Answers2

0

It works for me with Gradle 7.6.

$./gradlew publishToMavenLocal -Pversion=31
...
BUILD SUCCESSFUL in 1s
21 actionable tasks: 18 executed, 3 up-to-date

$ls -al ~/.m2/repository/com/foo/bar/client
total 8
drwxr-xr-x  4 johnkramer  staff  128 Jan 26 18:05 .
drwxr-xr-x  5 johnkramer  staff  160 Jan 26 18:05 ..
drwxr-xr-x  6 johnkramer  staff  192 Jan 26 18:05 31
-rw-r--r--  1 johnkramer  staff  334 Jan 26 18:05 maven-metadata-local.xml
Kramer
  • 927
  • 2
  • 13
  • 30
0

Make sure you're not already specifying a version in your build.gradle file, otherwise the flag version won't be applied. Tested with Gradle version 7.6.1.