rising3 / semver-gradle-plugin

Gradle plugin for Updates the project version.A plugin that can updating the semantic versions like `yarn version` command.
Apache License 2.0
15 stars 7 forks source link

A problem resolve build version from tag at jar task. #11

Closed rising3 closed 2 years ago

rising3 commented 3 years ago

When creating the JAR, the version cannot be resolved from the tag, so the latest version may not be available.

Fix as follows.

BrayanCaro commented 2 years ago

I have a problem, creating a simple Spring Boot project in spring.io, and after adding and running the plugin I got:

$ ./gradlew semver --patch --info
Initialized native services in: /home/recicla-mate2020/.gradle/native
Initialized jansi services in: /home/recicla-mate2020/.gradle/native
The client will now receive all logging from the daemon (pid: 437066). The daemon log file: /home/recicla-mate2020/.gradle/daemon/7.3.2/daemon-437066.out.log
Starting 4th build in daemon [uptime: 16 mins 53.427 secs, performance: 100%, non-heap usage: 30% of 256 MiB]
Using 4 worker leases.
Now considering [/home/recicla-mate2020/Descargas/demo] as hierarchies to watch
Watching the file system is configured to be enabled if available
File system watching is active
Starting Build
Settings evaluated using settings file '/home/recicla-mate2020/Descargas/demo/settings.gradle'.
Projects loaded. Root project using build file '/home/recicla-mate2020/Descargas/demo/build.gradle'.
Included projects: [root project 'demo']

> Configure project :
Evaluating root project 'demo' using build file '/home/recicla-mate2020/Descargas/demo/build.gradle'.
Applying dependency management to configuration 'bootArchives' in project 'demo'
Applying dependency management to configuration 'archives' in project 'demo'
Applying dependency management to configuration 'default' in project 'demo'

FAILURE: Build failed with an exception.

* Where:
Build file '/home/recicla-mate2020/Descargas/demo/build.gradle' line: 5

* What went wrong:
An exception occurred applying plugin request [id: 'java']
> Failed to apply plugin class 'org.gradle.api.plugins.JavaBasePlugin'.
   > Task with name 'jar' not found in root project 'demo'.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
My `build.gradle` plugins { id 'org.springframework.boot' version '2.6.2' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'com.github.rising3.semver' version '0.7.1' id 'java' } group = 'com.example' version = '0.0.1-SNAPSHOT' sourceCompatibility = '11' repositories { mavenCentral() } dependencies { implementation 'org.springframework.boot:spring-boot-starter' testImplementation 'org.springframework.boot:spring-boot-starter-test' } test { useJUnitPlatform() }

I think this was added in v0.6.0, here:

https://github.com/rising3/semver-gradle-plugin/blob/d69268271e81cd693315cb7719e676c0dc2aed55/src/main/groovy/com/github/rising3/gradle/semver/plugins/SemVerGradlePlugin.groovy#L40-L43

rising3 commented 2 years ago

@BrayanCaro

Thank you for reporting.

rising3 commented 2 years ago

@BrayanCaro

Hi, The dependency problem of gradle tasks will be addressed in the next version.

You can work around this problem by changing the order of the java plugins.

plugins {
        id 'org.springframework.boot' version '2.6.2'
        id 'io.spring.dependency-management' version '1.0.11.RELEASE'
        id 'java'
        id 'com.github.rising3.semver' version '0.7.1'
}
BrayanCaro commented 2 years ago

Putting the plugin at the bottom solved the issue, thank you! :smile: