Giter Site home page Giter Site logo

gradle-use-latest-versions-plugin's Introduction

Gradle Use Latest Versions Plugin

Build Status

A Gradle plugin that updates module and plugin versions in your *.gradle or *.gradle.kts files to the latest available versions.

This plugin depends on the Gradle Versions Plugin.

Maintainer: Patrik Erdes

Usage

Apply this plugin and the Gradle Versions Plugin.

Include in your build.gradle

plugins {
  id 'se.patrikerdes.use-latest-versions' version '0.2.18'
  id 'com.github.ben-manes.versions' version '0.41.0'
}

or

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
        jcenter()
    }
    dependencies {
        classpath "se.patrikerdes:gradle-use-latest-versions-plugin:0.2.18"
        classpath 'com.github.ben-manes:gradle-versions-plugin:0.41.0'
    }
}

apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'se.patrikerdes.use-latest-versions'

Usage for Gradle Kotlin DSL

Include in your build.gradle.kts

plugins {
  id("se.patrikerdes.use-latest-versions") version "0.2.18"
  id("com.github.ben-manes.versions") version "0.41.0"
}

or

buildscript {
    repositories {
        maven {
            maven { url = uri("https://plugins.gradle.org/m2/") }
        }
        jcenter()
    }
    dependencies {
        classpath("gradle.plugin.se.patrikerdes:gradle-use-latest-versions-plugin:0.2.18")
        classpath("com.github.ben-manes:gradle-versions-plugin:0.41.0")
    }
}

apply {
    plugin("com.github.ben-manes.versions")
    plugin("se.patrikerdes.use-latest-versions")
}

Multi-project usage

In case you have a Multi-project build and you have some common dependency configuration in some common file in root project (like *.gradle file), you should apply plugin to all projects. Easiest way to do this is with allprojects block like:

plugins {
  id 'se.patrikerdes.use-latest-versions' version '0.2.13'
  id 'com.github.ben-manes.versions' version '0.41.0'
}

allprojects {
    apply plugin: 'se.patrikerdes.use-latest-versions'
    apply plugin: 'com.github.ben-manes.versions'
}

This is because se.patrikerdes.use-latest-versions plugin scans files for every project separately.

In case you handle dependencies per project separately this is not needed and you can apply plugin just to selected projects.

Example

Given this build.gradle file:

plugins {
    id 'se.patrikerdes.use-latest-versions' version '0.2.18'
    id 'com.github.ben-manes.versions' version '0.19.0'
}

apply plugin: 'java'

repositories {
    mavenCentral()
}

ext.log4jversion = '1.2.16'
ext.codecVersion = '1.9'
def commonsLoggingVersion = "1.1.2"

dependencies {
    testCompile 'junit:junit:4.0'
    compile "log4j:log4j:$log4jversion"
    compile "commons-codec:commons-codec:" + codecVersion
    compile group: 'commons-lang', name: 'commons-lang', version: '2.4'
    compile group: 'commons-logging', name: 'commons-logging', version: commonsLoggingVersion
}

If you run

gradle useLatestVersions

Your plugin and module dependencies in build.gradle will be updated โ€“ both inline version number and versions based on variables โ€“ and you build.gradle file will look like this:

plugins {
    id 'se.patrikerdes.use-latest-versions' version '0.2.18'
    id 'com.github.ben-manes.versions' version '0.41.0' // <- Updated
}

apply plugin: 'java'

repositories {
    mavenCentral()
}

ext.log4jversion = '1.2.17' // <- Updated
ext.codecVersion = '1.11' // <- Updated
def commonsLoggingVersion = "1.2" // <- Updated

dependencies {
    testCompile 'junit:junit:4.12' // <- Updated
    compile "log4j:log4j:$log4jversion" // <- The variable above was updated
    compile "commons-codec:commons-codec:" + codecVersion // <- The variable above was updated
    compile group: 'commons-lang', name: 'commons-lang', version: '2.6' // <- Updated
    compile group: 'commons-logging', name: 'commons-logging', version: commonsLoggingVersion // <- The variable above was updated
}

Tasks

useLatestVersions

gradle useLatestVersions

# Configuration and default values:
useLatestVersions {
   # A whitelist of dependencies to update, in the format of group:name
   # Equal to command line: --update-dependency=[values]
   updateWhitelist = []
   # A blacklist of dependencies to update, in the format of group:name
   # Equal to command line: --ignore-dependency=[values]
   updateBlacklist = []
   # When enabled, root project gradle.properties will also be populated with 
   # versions from subprojects in multi-project build
   # Equal to command line: --update-root-properties
   updateRootProperties = false
   # By default plugin tries to find all relevant gradle files (e.g. *.gradle, gradle.properties etc). 
   # This can be slow in some cases when project has a lot of gradle files. For example when using conventions 
   # in buildSrc. With this option you can specify what files should plugin search and check. Plugin will ignore
   # files that don't exist. Empty list means use default strategy. File paths are relative to project dir.
   #
   # Example:
   # versionFiles = ["gradle.build", "gradle.properties"]
   # Will check just $projectDir/gradle.build and $projectDir/gradle.properties
   #
   # Note:
   # You always have to specify file that has dependencies in some common dependency format with artifact coordinates,
   # e.g. compileOnly "group:module:version" or compileOnly("group:module:version") or val dependency = "group:module:version" etc. 
   # For example if you set just versionFiles = ["gradle.properties"] this won't work, since plugin 
   # won't be able to correlate variable with artifact coordinates.
   #
   # Equal to command line: --version-files=[values]
   versionFiles = []
   # List of root project files to update when updateRootProperties is enabled.
   # `build.gradle` is not an acceptable entry here as it breaks other expected
   # functionality. Version variables in `build.gradle` need to be moved into
   # a separate file which can be listed here.
   # Equal to command line: --root-version-files=[values]
   rootVersionFiles = ['gradle.properties']
}

Updates module and plugin versions in all *.gradle files in the project root folder or any subfolder to the latest available versions. This task depends on the dependencyUpdates task in the Gradle Versions Plugin to know which dependencies can be updated.

useLatestVersionsCheck

# gradle useLatestVersions && gradle useLatestVersionsCheck

This task will succeed if all available updates were successfully applied by useLatestVersions, and it will fail if any of the updates were not successfully applied. This task depends on the dependencyUpdates task in the Gradle Versions Plugin to know which dependencies were successfully updated.

useLatestVersionsCheck can not run in the same gradle run as useLatestVersions, since the dependencyUpdates task will check the *.gradle files as they were when the gradle build started, which means that it can not pick up the changes applied by useLatestVersions.

Updating only specific dependencies (whitelist)

If your Gradle version is 4.6 or higher, you can pass the --update-dependency flag to useLatestVersions and useLatestVersionsCheck with a value in the format $GROUP:$NAME. A complete dependency group can be updated by using the format $GROUP. Multiple dependencies can be updated by passing the flag multiple times.

# gradle useLatestVersions --update-dependency junit:junit --update-dependency com.google.guava && gradle useLatestVersionsCheck --update-dependency junit:junit --update-dependency com.google.guava

Ignore specific dependency updates (blacklist)

If your Gradle version is 4.6 or higher, you can pass the --ignore-dependency flag to useLatestVersions and useLatestVersionsCheck with a value in the format $GROUP:$NAME. A complete dependency group can be ignored by using the format $GROUP. Multiple dependencies can be ignored by passing the flag multiple times.

# gradle useLatestVersions --ignore-dependency junit:junit --ignore-dependency com.google.guava && gradle useLatestVersionsCheck --ignore-dependency junit:junit --ignore-dependency com.google.guava

Supported dependency formats

Dependencies stated in the following formats should cause the version to be successfully updated by the useLatestVersions task. (If not, please create an issue.) Single and double quotes are interchangeable in all formats below.

Plugin dependencies

Plugin dependencies can only be updated in Gradle 4.4+.

The plugins DSL only allows a strict format, e.g. only string literals for the version number, so there is basically only one format to support.

plugins {
    id 'se.patrikerdes.use-latest-versions' version '0.1.0'
}

Module dependencies

String format

dependencies {
    compile "log4j:log4j:1.2.15"
    testCompile 'junit:junit:4.0'
}

Map format

Currently only if the order is group, name, version, without other elements in between.

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.0'
}

Module dependencies based on variables

def and ext. (extra properties extensions) can be used interchangeably in all example below.

String format

ext.junit_version = '4.0'

dependencies {
    testCompile "junit:junit:$junit_version"
}
def junit_version = '4.0'

dependencies {
    testCompile "junit:junit:${junit_version}"
}
ext.junit_version = '4.0'

dependencies {
    testCompile "junit:junit:" + junit_version
}

Map format

Currently only if the order is group, name, version, without other elements in between.

ext.junit_version = '4.0'

dependencies {
    testCompile group: 'junit', name: 'junit', version: junit_version
}

Compatibility

Gradle version: 2.8 - 4.10.2 (Updating plugin dependencies only work in 4.4+)
Versions Plugin version: 0.12.0 - 0.41.0
JDK version: 7 - 11 (7 is targeted but not tested, 11 is currently not tested but is known to work)

Instructions for building this plugin from source

  • Clone or download this project.
  • Open the project, for example in IntelliJ open the build.gradle file.
  • You can build the jar with the Gradle assemble task, it will be in build/libs/.
  • If you want to use the plugin locally, first publish to your local Maven repository with the Gradle publishToMavenLocal task.
  • To use it in a different project, add to your build.gradle file
buildscript {
    repositories {
        mavenLocal()
    }
    dependencies{
        classpath group: 'se.patrikerdes',
				name: 'gradle-use-latest-versions-plugin',
				version: '0.2.18'
    }
}

apply plugin: se.patrikerdes.UseLatestVersionsPlugin

FAQ

How do I exclude alpha/beta/rc versions?

The Versions plugin can be configured to achieve this, it is documented in the Versions plugin README

Where does the name "Use Latest Versions" come from?

From the Maven Versions Plugin goal called use-latest-versions

Changelog

0.2.18

Fixed issue #57, kotlin("plugin.spring") isn't updated (ghmulti)

0.2.17

PR #53, Recognise kotlin plugin format, e.g. 'kotlin("jvm") version "1.5.10"' (MxKaras)

PR #52, Fix "The variable ... is assigned more than once" message if variable has another as a suffix (xenomachina)

0.2.16

PR #49, Add option to specify version files (asodja)

0.2.15

PR #45, Adding list of root files with variables to update (tony-schellenberg)

0.2.14

PR #41, Add support to update root gradle.properties (asodja)

0.2.13

PR #35, Add flag to ignore specific dependency updates (blacklist) (Balthasar Biedermann)

PR #36, Allow setting of outputDir and reportfileName (dependencyUpdates) (Balthasar Biedermann)

0.2.12

PR #27, Add flag to update only explicitly listed dependencies. (Ian Kerins)

0.2.11

Fixed issue #25, Don't crash when dependencyUpdates/report.json has a version range

0.2.10

Fixed issue #24, Allow for non-standard buildDir setting

0.2.9

PR #23, Changes to address issues with Gradle multi-project builds. (b-behan)

Support com.github.ben-manes.versions version 0.21.0

0.2.8

PR #18, Support kt files within buildSrc. (Balthasar Biedermann)

Fixed issue #14, Kotlin dsl separate named and unnamed group name and version. (Balthasar Biedermann)

Fixed issue #15, changed the README to contain the correct way to use the plugin in a buildscript block.

Made the plugin work on Windows.

0.2.7

Fixed issue 10, Multiple versions in gradle.properties (Balthasar Biedermann)

PR #12, Support dependencySet of Spring Dependency management plugin. (Balthasar Biedermann)

PR #13, Support classifier and extension in dependencies. (Balthasar Biedermann)

0.2.6

Fixed issue 7, Update version variables in gradle.properties file, again. (0.2.4 didn't fix #7)

0.2.5

Fixed issue 8, Support for string interpolation with curly braces ${}

0.2.4

Fixed issue 7, Update version variables in gradle.properties file.

0.2.3

Fixed issue 3, Output formats are forced to be json,xml. (Tony Baines)

0.2.2

Fixed issue 2, Hardcoded Milestone Usage.

0.2.1

Added support for Gradle Kotlin DSL build files. (Thomas Schouten)

gradle-use-latest-versions-plugin's People

Contributors

asodja avatar b-behan avatar ghmulti avatar isker avatar mokevnin avatar patrikerdes avatar phpirates avatar tony-schellenberg avatar tonybaines avatar usr42 avatar xenomachina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gradle-use-latest-versions-plugin's Issues

useLatestVersions isn't upgrading versions in properties file of a multi-project build as of release 0.2.9

We have a multi-project build. Many of our version numbers we keep in gradle.properties at the root project level. eg:

hikaricp_version = 3.3.1
jetbrains_annotations_version = 17.0.0
jooq_version = 3.11.11
kotlin_logging_version = 1.6.26
kotlintest_version = 3.3.2
kotlin_version = 1.3.41
log4j2_slf4j_version = 2.11.2
postgresql_jdbc_version = 42.2.5
slf4j_simple_version = 1.7.26
testcontainers_version = 1.11.3

Dependencies are specified in the sub-projects:

// project-sub/build.gradle
dependencies {
    implementation "com.zaxxer:HikariCP:$hikaricp_version"
    implementation "io.github.microutils:kotlin-logging:$kotlin_logging_version"
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation "org.jetbrains:annotations:$jetbrains_annotations_version"
    implementation "org.jooq:jooq:$jooq_version"

    testImplementation "io.kotlintest:kotlintest-assertions:$kotlintest_version"
    testImplementation "io.kotlintest:kotlintest-core:$kotlintest_version"
    testImplementation "io.kotlintest:kotlintest-runner-junit5:$kotlintest_version"
}

With 0.2.8, these version numbers in the properties file are upgraded correctly. With 0.2.9 through 0.2.12 they aren't.

kotlin("plugin.spring") isn't updated

Added a test demonstrating the behavior: JorgenRingen@837a800

As you can see, kotlin("jvm") is updated, but kotlin("plugin.spring") is not updated.

However, when I declare the plugin like this it works: id("org.jetbrains.kotlin.plugin.spring")

NB: The test was a little bit broken as well as assertions didn't fail when they ran inside lambda. Added assert keyword to make the test fail if an assertion failed.

Feature request: Support for Spring Dependency management plugin

Hi @patrikerdes,
me again with another feature request ;)

I'm using the Spring Dependency management plugin to control the versions of both the direct and the transitive dependencies of my projects.

An example (from the official README) looks like:

dependencyManagement {
     dependencies {
          dependency 'org.springframework:spring-core:4.0.3.RELEASE'
          dependency group:'commons-logging', name:'commons-logging', version:'1.1.2'
     }
}

dependencies {
     compile 'org.springframework:spring-core'
}

More details about the plugin:
https://github.com/spring-gradle-plugins/dependency-management-plugin

Thanks again and cheers,
usr42/Balthasar

Dependencies don't get updated if the version is delegated

I have the following build.gradle.kts:

val junitVersion: String by project

dependencies {
	testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", junitVersion)
}

and my gradle.properties:

junitVersion=5.3.1

If I run ./gradlew dependencyUpdates I can see that there is an update for junit to 5.3.2.

But if I run ./gradlew useLatestVersions the gradle.properties does not get updated.

Support for `properties.gradle.kts`?

Hello,

Are there any plans to support extra properties.gradle.kts version formats?
Example:

// properties.gradle.kts file
val fooVersion by extra("1.5.0-RC")
val barVersion by extra("1920")

Usage

// build.gradle.kts file
plugins {
    kotlin("jvm") version "1.5.0" apply false
    id("se.patrikerdes.use-latest-versions") version "0.2.15" apply false
}

allprojects {
    apply(from = "${rootProject.rootDir}/properties.gradle.kts")
    apply(plugin = "se.patrikerdes.use-latest-versions")

    val fooVersion: String by extra
    val barVersion: String by extra

    tasks.named<UseLatestVersionsTask>("useLatestVersions").configure {
        doFirst {
            updateWhitelist = FileReader(File("${project.buildDir}/identifyDependencies/identified-dependencies.txt")).readText().split(",")
            rootVersionFiles = listOf("properties.gradle.kts")
        }
        updateRootProperties = true

        dependsOn("identifyDependencies")
        mustRunAfter("identifyDependencies")
    }

    tasks.register<identifyDependenciesTask>("identifyDependencies") {
        // will create a file with property names to update. i.e.
        // -> org.x:foo
        // -> org.x:bar
        propertyNames = project.propertyOrBlank("propertyNames").split(",")
    }

    dependencies {
        implementation("org.x:foo:$fooVersion")
        testImplementation("org.x:bar:$barVersion")
    }
}

Running gw useLatestVersions -PpropertyNames=fooVersion does not update the versions in build.gradle.kts. Am I doing anything wrong here?

Thanks :D

Restricting to certain group IDs

Is there a way to make the plugin only touch versions of certain group IDs? Essentially, we depend on SNAPSHOT versions of our own libraries between releases, move to non-snapshot on release, and to next-snapshot after release. I'd like to automate this process, and this plugin looks very useful.

However, I want to only touch the versions of dependencies that are under the group ID "com.example", but not any of the other dependencies (like build tooling, etc). Is this possible?

Add support for version catalogs

Gradle 7 introduced version catalogs which are standardized ways of declaring dependency versions.

There are 2 forms which may be supported by this plugin:

  1. the easiest, the *.versions.toml file (e.g libs.versions.toml)
  2. the settings DSL

It would be nice to support at least 1., which is IMO the most common usage.

Hardcoded Milestone Usage

The usage of the milestone version is hardcoded. The problem with this approach is that the gradle-versions-plugin can be changed to use e.g. release or integration and those would never be used. A better approach would be to start from integration to milestone to release and use the first non-null value (and err if all are null).

Issue with classifier support

When running gradlew useLatestVersions in one of the example project, the correct results are not produced.

diff of the build.gradle file:

 dependencies {
     testCompile "junit:junit:$junitVersion"
     compile "log4j:log4j:$log4jversion"
-    compile "commons-codec:commons-codec:" + codecVersion
-    compile group: 'commons-lang', name: 'commons-lang', version: '2.4'
+    compile "commons-codec:commons-codec:1.12: 'commons-lang', name: 'commons-lang', version: '2.4'
     compile group: 'commons-logging', name: 'commons-logging', version: commonsLoggingVersion
 }

As can be seen here, the commons-codec and commons-lang lines are kind of merged together into one line, which doesn't make sense at all.

This issue was introduced by PR #13, when reverting that commit I don't see this problem.

Erroneous "The variable ... is assigned more than once" message if variable has another as a suffix

To reproduce:

  1. Create a new project with the following build.gradle and gradle.properties files:

    build.gradle

    buildscript {
        repositories {
            mavenCentral()
        }
    
        dependencies {
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        }
    }
    
    plugins {
      id("se.patrikerdes.use-latest-versions") version "0.2.16"
      id("com.github.ben-manes.versions") version "0.38.0"
    }
    
    apply plugin: 'kotlin'
    
    dependencies {
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
    }

    gradle.properties

    dotenv_kotlin_version = 6.2.2
    kotlin_version = 1.4.30
  2. Install gradle wrapper 7.0:

    gradle wrapper --gradle-version 7.0
  3. Execute ./gradlew useLatestVersions

Expected behavior

It should update kotlin_version (to 1.5.0, at the time I write this).

Actual behavior

It complains...

A problem was detected: the variable kotlin_version is assigned more than once and won't be changed.

...and does not update kotlin_version.

Work around

Ensure that no two version variables are a suffix of each other. In this case, kotlin_version is a suffix of dotenv_kotlin_version, so one or the other needs to be renamed.

Failing tests: ben-manes plugin not found

I improved the plugin and wanted to run the Unit Tests. However, for most of the tests the following message showed up. Can you help me with this?

Unexpected build execution failure in C:\Users\USERNAME\AppData\Local\Temp\junit2740443000582118919 with arguments [useLatestVersions]

Output:

FAILURE: Build failed with an exception.

  • Where:
    Build file 'C:\Users\USERNAME\AppData\Local\Temp\junit2740443000582118919\build.gradle' line: 4

  • What went wrong:
    Plugin [id: 'com.github.ben-manes.versions', version: '0.21.0'] was not found in any of the following sources:

  • Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
  • Gradle TestKit (classpath: PROJECTPATH\build\classes\java\main;PROJECTPATH\build\classes\groovy\main;PROJECTPATH\build\resources\main)
  • Plugin Repositories (could not resolve plugin artifact 'com.github.ben-manes.versions:com.github.ben-manes.versions.gradle.plugin:0.21.0')
    Searched in the following repositories:
    Gradle Central Plugin Repository
  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --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 11s

Boms not updated

Hi,

using this plugin within this little eample I discovered, that dependencies defined within boms are not updated.
https://github.com/gunkelolaf/dependencymanagement-demo

reproduce:
within the /backend/gradle/dependencymanagement.gradle file
Set the junit 5 bom version to 5.5.0

run
./gradlew useLatestVersions
The versions defined as dependencies are updated, the bom version isn't.

Not compatible with Gradle 7.0: property 'html' has redundant getters

using with gradle 7.0 leads to an error:

  • What went wrong:
    Some problems were found with the configuration of task ':uiservice:downloadLicenses' (type 'DownloadLicenses').

Task :internalRootAggregate FAILED - java.lang.ClassCastException

I recently had an error trying to use use-latest-versions in a multi-module build:

> Task :internalRootAggregate FAILED

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':sdk:useLatestVersions'.
> java.lang.ClassCastException: class org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to class org.apache.xerces.xni.parser.XMLParserConfiguration (org.apache.xerces.parsers.XIncludeAwareParserConfiguration is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @456aaa6f; org.apache.xerces.xni.parser.XMLParserConfiguration is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @36faac92)

Using OpenJDK 14 on this commit: https://github.com/CAU-Kiel-Tech-Inf/backend/tree/use-latest-versions-bug
I simply ran ./gradlew useLatestVersions, and it failed for the subprojects. dependencyUpdates worked. Logs:

dependencyUpdates.txt
useLatestVersions.txt

Interestingly the issue vanished when I updated some dependencies: software-challenge/backend@02e3fb1

Fix travis-ci integration

For old commits and PRs, it was possible to see a build annotation of the build status from travis-ci next to the commit/PR. This has stopped working at some point. Fix it.

Check failed when even when ignoring dependencies

I run useLatestVersions|useLatestVersionsCheck with
--ignore-dependency jakarta.annotation:jakarta.annotation-api --ignore-dependency jakarta.persistence:jakarta.persistence-api --ignore-dependency org.hibernate:hibernate-java8

which results in a failed build with the following

`useLatestVersions failed to update 2 dependencies to the latest version:
useLatestVersions skipped updating 3 dependencies in --ignore-dependency:

  • jakarta.annotation:jakarta.annotation-api [1.3.5 -> 2.0.0]
  • jakarta.persistence:jakarta.persistence-api [2.2.3 -> 3.0.0]
  • org.hibernate:hibernate-java8 [5.4.23.Final -> 6.0.0.Alpha6]`

so the failed dependencies are not listed which prevents me from ignoring conflicting (transitive?) dependencies.

I there any workaround? Do I miss something?

Gradle 6.7
JDK 8

Supporting JDK version as defined in sourceCompatibility and targetCompatibility

First of all, I want to shout out for contributing this plugin. One feature request I would like to see is when I run upgrade the version, I want the plugin to take current Java version into consideration.
For example, I am using JDK 12 and it upgrades spring plugin from 2.1.10 to 3.1.4, however that's not compatible with JDK 12.

./gradlew clean compileJava
      > No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.1.4 was found. The consumer was configured to find a runtime of a library compatible with Java 12, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.6.1' but:
          - Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.1.4 declares a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares an API of a component compatible with Java 17 and the consumer needed a runtime of a component compatible with Java 12

Temporary solution is I put this on blacklist for auto upgrade,

subprojects {
    sourceCompatibility = 11
    targetCompatibility = 11

    useLatestVersions {
        updateRootProperties = true
        updateBlacklist = [
                'org.springframework.boot',
                'org.springframework',
                'io.github.resilience4j'
        ]
    }
}

Upgrading to latest version supported on particular JDK version would be amazing.

cannot update version for plugin `org.cyclonedx.bom`

I have

plugins {
  id "com.github.ben-manes.versions" version "0.27.0"
  id "se.patrikerdes.use-latest-versions" version "0.2.13"
  id "org.cyclonedx.bom" version "1.1.1"
  ...
}

Running useLatestVersions then useLatestVersionsCheck I get output

> Task :useLatestVersionsCheck FAILED
useLatestVersions failed to update 1 dependency to the latest version:
 - org.cyclonedx:cyclonedx-gradle-plugin [1.1.1 -> 1.1.2]

I ran with --debug but it didn't seem to have anything different for org.cyclonedx.bom than any other dependency. The messages clearly stated that it found version 1.1.2, but nothing about actually trying to update. All other dependencies are getting updated.

`java.util.regex.PatternSyntaxException` when dependencyUpdates/report.json has a version range

build/dependencyUpdates/report.json contains a node like this:

            {
                "group": "com.foo",
                "available": {
                    "release": null,
                    "milestone": "0.22.20181102.232553",
                    "integration": null
                },
                "version": "[0.1,1.0)",
                "projectUrl": null,
                "name": "bar"
            },

The version being a range results in this (I pruned the extremely long Gradle stacktrace to the relevant frames):

Caused by: java.util.regex.PatternSyntaxException: Unclosed character class near index 691
((?:testRuntimeOnly|implementation|annotationProcessor|api|apiDependenciesMetadata|apiElements|compile|compileClasspath|compileOnly|compileOnlyDependenciesMetadata|implementation|implementationDependenciesMetadata|runtime|runtimeClasspath|runtimeElements|runtimeOnly|runtimeOnlyDependenciesMetadata|testAnnotationProcessor|testApi|testApiDependenciesMetadata|testCompile|testCompileClasspath|testCompileOnly|testCompileOnlyDependenciesMetadata|testImplementation|testImplementationDependenciesMetadata|testKotlinScriptDef|testKotlinScriptDefExtensions|testRuntime|testRuntimeClasspath|testRuntimeOnlyDependenciesMetadata)\s*\(\s*"com.foo"\s*,\s*"bar"\s*,\s*")[0.1,1.0)("\s*\))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ^
	at se.patrikerdes.UseLatestVersionsTask.updateModuleVersions(UseLatestVersionsTask.groovy:97)
	at se.patrikerdes.UseLatestVersionsTask.useLatestVersions(UseLatestVersionsTask.groovy:66)

I am new to both your plugin and the upstream gradle-versions-plugin so I'm not sure where the bug lies; should the report never contain a range there?

Unfortunately I've not been able to make a simple reproducing project; I haven't been able to convince gradle-versions-plugin to produce such a report.

Plugin uses hard coded build dir

If buildDir is redefined (for example by setting buildDir = file 'gradle-build' in build.gradle), useLatestVersions fails with java.nio.file.NoSuchFileException while trying to open dependencyUpdates/report.json.

This is because UseLatestVersionsCheckTask looks for new File(project.projectDir, 'build' + File.separator + 'dependencyUpdates' + File.separator + 'report.json') while it should probably be something like new File(project.buildDir, 'dependencyUpdates' + File.separator + 'report.json').

Bug: Multiple versions in gradle.properties

Hi @patrikerdes,

I found another issue. When the version variables are set in the gradle.properties file only the last version is updated.

Here is an example:
See https://github.com/usr42/use-latest-issues/tree/multiple-versions-in-gradle_properties

gradle.properties:

junitVersion = 4.0
hibernateValidatorVersion=6.0.12.Final

build.gradle:

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.3.10'
    id "se.patrikerdes.use-latest-versions" version "0.2.6"
    id 'com.github.ben-manes.versions' version '0.20.0'
}

repositories {
    mavenCentral()
}

dependencies {
    compile "org.hibernate:hibernate-validator:${hibernateValidatorVersion}"
    testCompile "junit:junit:$junitVersion"
}

When running ./gradlew useLatestVersions && ./gradlew useLatestVersionsCheckthe check is failing:

> Task :useLatestVersionsCheck FAILED
useLatestVersions failed to update 1 dependency to the latest version:
 - junit:junit [4.0 -> 4.12]

The gradle.properties was updated to:

junitVersion = 4.0
hibernateValidatorVersion=6.0.13.Final

Only the last variable (here hibernateValidatorVersion) is updated.
If I change the ordering of the variables in gradle.properties, then junitVersion (now the last variable) is updated, but not hibernateValidatorVersion.

Thanks and cheers,
usr42/Balthasar

Be able to only check direct dependencies

It would be an awesome feature, if you could configure the useLatestVersionsCheck to only "enforce" the direct dependencies.

Because I cannot control the dependencies of my dependencies, my build fails without me being able to really fix that.

se.patrikerdes.use-latest-versions not upgrading the plugins does upgrad dependencies

plugins {
    id("info.solidsoft.pitest") version ("1.9.0")
}

this one should be upgraded to

plugins {

    id("info.solidsoft.pitest") version ("1.9.11")
}

when we run

gradle useLatestVersions

while

Task :dependencyUpdatesdoes does report 

The following dependencies have later milestone versions:
 - info.solidsoft.pitest:info.solidsoft.pitest.gradle.plugin [1.9.0 -> 1.9.11]

but the build.gradle.kts file is not reflecting this version it remains as 1.9.0

image

Support for string interpolation with curly braces ${}

First, thanks for the super-fast implementation of #7

Now to my new request:
Using the dollar-only notation $versionVariable works.
But Groovy and Kotlin (and so gradle DSL) also supports the dollar with curly braces notation: ${versionVariable}
If I use this notation the version is not automatically updated.

Example to reproduce:

dependencies {
    ext {
        junitJupiterVersion='5.3.0-RC1'
    }

    testCompile "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}"
    testRuntime "org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}"
}

The following is successful:

dependencies {
    ext {
        junitJupiterVersion='5.3.0-RC1'
    }

    testCompile "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion"
    testRuntime "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion"
}

It would be nice if also the curly braces (${}) notation would work.

Thanks and cheers,
usr42 / Balthasar

Output formats are forced to be json,xml

Our nightly build takes the plain report format from gradle-versions-plugin and includes it in the notification e-mail (we don't automatically switch to the newer versions as part of CI).

After including user-latest-versions, the build fails since build/dependencyUpdates/report.txt can't be found.

Trying to set the report formats to include 'plain' by other means fails (in the build script, via system property).

Only some versions in the parent are updated when using sub-projects

Hi. I have a project which has a main build.gradle, and 3 sub-projects. We use the parent project to define versions for the sub-projects. It looks something like this:

buildscript {
    ext {
        springBootVersion = '3.1.0'
        internalLibraryVersion = '1.2.3'
   }
}

In each sub-project, we reference these versions like this:

implementation "org.springframework.boot:spring-boot-starter-web:$springBootVersion"
implementation "com.internal.library:my-library:$internalLibraryVersion"

When we run the plugin, it detects that both spring boot and my-library needs to be updated. It clearly prints which version updates are needed, but ultimately only the springBootVersion line in the parent is updated. If we use the versions directly in the sub-projects, the other libraries are also correctly updated. It's clear that the update mechanism works, and that it can read the correct version from the repository etc, but it just isn't updating the versions in the parent. Any thoughts on why this might be?

It doesn't seem to be the case that it's only our internal libraries, either. Spring-boot updates, but hibernate does not. It's very weird.

Disable `outputFormatter`

Is there a way to completely disable the outputFormatter similar to as passing an empty lambda to the outputFormatter parameter to the DependencyUpdatesTask.
It might be related to #3 but it should be way easier to achieve.

Feature request: Update version variables in gradle.properties file

I have some gradle projects where the version of dependencies is defined in the gradle.properties file in the project root directory. These versions are detected correctly, but are not automatically updated.

This would be a really helpful feature.

Thank you for the great work already done.

Cheers,
usr42

Multi-project with version variables in root does not update

When I use a version variable defined in the root project in a sub project, it does not update the root project variable. It updates the dependency used in the root project but not the one that is used in the sub project. Please let me know if more information is required and I'll do my best to provide it.

Gradle Version: 6.3
Gradle Versions Plugin: 0.29.0
Use Latest Version: 0.2.14

Project structure:

  • ./build.gradle -> root project
  • ./commonDependencies.gradle -> has an ext block with variables for versions
  • ./components/main/build.gradle -> subproject, only has a dependencies block on one of the libraries

All versions numbers are set in an ext block in commonDependencies.gradle as part of the root project as variables. There are only two dependencies/version variables defined. One dependency is referenced in each of the build.gradle files. I.e. one dependency is referenced in the root project and the other one is in the sub project.

In the root build.gradle, I've included the plugins in an allprojects stanza.

I've tried the following but haven't found a way to get the updates working:

  1. useLatestVersions
  2. useLatestVersions with --update-root-properties
  3. useLatestVersions with updateRootProperties = true
build.gradle
buildscript {
    repositories {
        jcenter()
    }
}

plugins {
    id 'com.github.ben-manes.versions' version '0.29.0'
    id 'se.patrikerdes.use-latest-versions' version '0.2.14'
}

wrapper {
    gradleVersion = '6.3'
}

def isNonStable = { String version ->
    def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
    def regex = /^[0-9,.v-]+(-r)?$/
    return !stableKeyword && !(version ==~ regex)
}

allprojects {
    apply plugin: 'java'
    apply from: "$rootDir/commonDependencies.gradle"

    apply plugin: 'com.github.ben-manes.versions'
    apply plugin: 'se.patrikerdes.use-latest-versions'

    // Change how the report for dependency updates is created to only include stable versions
    tasks.named('dependencyUpdates').configure() {
        rejectVersionIf {
            isNonStable(it.candidate.version)
        }
    }
    useLatestVersions {
       updateWhitelist = []
       updateBlacklist = []
       updateRootProperties = true
    }
}
commonDependencies.gradle
ext {
    junitJupiterVersion = '5.6.2'
    metricsVersion = '4.1.5'
}

repositories {
    jcenter()
}

dependencies {
    testImplementation "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion"
}
settings.gradle
include 'main'
project(':main').projectDir = new File(rootDir, 'components/main')

getRootProject().setName('demo')
components/main/build.gradle
dependencies {
    implementation "io.dropwizard.metrics:metrics-core:$metricsVersion"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.