tunix
March 17, 2021, 11:56am
1
I’m trying to modify gradle snap for easier management of the package version. I don’t want to change multiple lines each time I need to update to the latest version. The latest version of snapcraft.yml is here: https://github.com/tunix/gradle-snap/blob/master/snap/snapcraft.yaml#L44
When I try to package this the first time, the following happens:
...
Pulling java
+ snapcraftctl pull
Building gradle
++ /root/parts/gradle/src/gradle-6.8.3/bin/gradle -v
++ awk '/Gradle/{print $2}'
+ version='to
6.8.3'
+ snapcraftctl set-version to 6.8.3
Usage: snapcraftctl set-version [OPTIONS] VERSION
Try 'snapcraftctl set-version --help' for help.
Error: Got unexpected extra argument (6.8.3)
Failed to run 'override-build': Exit code was 2
But if I run it again, this is what happens:
snapcraft-gradle # snapcraft
snapd is not logged in, snap install commands will use sudo
snap "core20" has no updates available
Skipping pull gradle (already ran)
Skipping pull java (already ran)
Building gradle
++ /root/parts/gradle/src/gradle-6.8.3/bin/gradle -v
++ awk '/Gradle/{print $2}'
+ version=6.8.3
+ snapcraftctl set-version 6.8.3
+ snapcraftctl build
+ mkdir -p /root/parts/gradle/install/opt
+ mv /root/parts/gradle/build/gradle-6.8.3 /root/parts/gradle/install/opt/gradle
Copying needed symlink target '/etc/ssl/certs/java/cacerts' from host to satisfy '/root/parts/java/install/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/cacerts'.
Building java
+ snapcraftctl build
Staging gradle
+ snapcraftctl stage
Staging java
+ snapcraftctl stage
Priming gradle
+ snapcraftctl prime
Priming java
+ snapcraftctl prime
Snapping |
Snapped gradle_6.8.3_amd64.snap
I’m not sure where that “to\n” part comes from. Any ideas?
ogra
March 17, 2021, 1:15pm
2
check the raw outout of /root/parts/gradle/src/gradle-6.8.3/bin/gradle -v
?
tunix
March 17, 2021, 2:31pm
3
Pulling java
+ snapcraftctl pull
Building gradle
++ /root/parts/gradle/src/gradle-6.8.3/bin/gradle -v
++ awk '/Gradle/{print $2}'
+ version='to
6.8.3'
+ snapcraftctl set-version to 6.8.3
Usage: snapcraftctl set-version [OPTIONS] VERSION
Try 'snapcraftctl set-version --help' for help.
Error: Got unexpected extra argument (6.8.3)
Failed to run 'override-build': Exit code was 2.
snapcraft-gradle # /root/parts/gradle/src/gradle-6.8.3/bin/gradle -v
------------------------------------------------------------
Gradle 6.8.3
------------------------------------------------------------
Build time: 2021-02-22 16:13:28 UTC
Revision: 9e26b4a9ebb910eaa1b8da8ff8575e514bc61c78
Kotlin: 1.4.20
Groovy: 2.5.12
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 1.8.0_282 (Private Build 25.282-b08)
OS: Linux 5.4.0-53-generic amd64
snapcraft-gradle # /root/parts/gradle/src/gradle-6.8.3/bin/gradle -v|awk '/Gradle/{print $2}'
6.8.3
ogra
March 17, 2021, 2:44pm
4
sorry, i meant you should do that from your snapcraft.yaml so it runs in the exact same context and environment … i.e. add a line above version=...
, just reading:
$SNAPCRAFT_PART_SRC/gradle-*/bin/gradle -v
and see what that prints …
tunix
March 17, 2021, 3:20pm
5
Ah ok
Looks like the issue is with the text gradle prints when it’s first launched. Thanks @ogra !
Pulling java
+ snapcraftctl pull
Building gradle
+ /root/parts/gradle/src/gradle-6.8.3/bin/gradle -v
Welcome to Gradle 6.8.3!
Here are the highlights of this release:
- Faster Kotlin DSL script compilation
- Vendor selection for Java toolchains
- Convenient execution of tasks in composite builds
- Consistent dependency resolution
For more details see https://docs.gradle.org/6.8.3/release-notes.html
------------------------------------------------------------
Gradle 6.8.3
------------------------------------------------------------
Build time: 2021-02-22 16:13:28 UTC
Revision: 9e26b4a9ebb910eaa1b8da8ff8575e514bc61c78
Kotlin: 1.4.20
Groovy: 2.5.12
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 1.8.0_282 (Private Build 25.282-b08)
OS: Linux 5.4.0-53-generic amd64
++ /root/parts/gradle/src/gradle-6.8.3/bin/gradle -v
++ awk '/Gradle/{print $2}'
+ version=6.8.3
+ snapcraftctl set-version 6.8.3
+ snapcraftctl build
ogra
March 17, 2021, 3:21pm
6
tunix:
Welcome to Gradle 6.8.3!
there you go
(you match for “Gradle” and then print the second word of the matched line with awk)