I just tried my first baby-steps but got stuck aft...
# refreshversions
n
I just tried my first baby-steps but got stuck after the Gradge 6 upgrade. My
settings.gradle
starts with
pluginManagement { repositories { gradlePluginPortal() } plugins { id "org.jetbrains.kotlin.jvm" version "1.3.60" ...
(with proper whitespace) and I could not add the new stuff in there. So I removed the references to plugin
buildSrcVersions
in both
settings.gradle
and
build.gradle
, added
refreshVersions
and
dependencies
to both, and added
buildScript.dependencies.classpath "de.fayard:dependencies:0.5.8"
and the
import
to
build.gradle
. This gets me past the "import" (note: 0.5.8 seems to have changes the layout and I use
import de.fayard.dependencies.DependenciesSetup
) but now I am stuck at
DependenciesSetup.bootstrapRefreshVersionsAndDependencies(gradle.settings)
which fails with "Cannot change the plugin resolution strategy after projects have been loaded." Most likely I painted myself into a corner here...
l
@nkiesel Can you post your full
settings.gradle
in this thread?
n
My current version (there are more
include
but that should not matter)
Copy code
pluginManagement {
    repositories {
        gradlePluginPortal()
        maven {
            name "ext-release-local"
            url "<http://msjenkins:8081/artifactory/ext-release-local>"
        }
    }
    
    plugins {
        id "com.gradle.build-scan" version <http://Versions.com|Versions.com>_gradle_build_scan_gradle_plugin
        id "org.sonarqube" version <http://Versions.org|Versions.org>_sonarqube_gradle_plugin
        id "de.fayard.buildSrcVersions" version <http://Versions.de|Versions.de>_fayard_buildsrcversions_gradle_plugin
        id "com.palantir.jacoco-full-report" version <http://Versions.com|Versions.com>_palantir_jacoco_full_report_gradle_plugin
        id "org.ajoberstar.grgit" version <http://Versions.org|Versions.org>_ajoberstar_grgit_gradle_plugin
        id "com.github.voplex95.lesscompiler" version <http://Versions.com|Versions.com>_github_voplex95_lesscompiler_gradle_plugin
        id "com.moowork.node" version <http://Versions.com|Versions.com>_moowork_node_gradle_plugin
        id "com.moowork.grunt" version <http://Versions.com|Versions.com>_moowork_grunt_gradle_plugin
        id "com.bmuschko.cargo" version <http://Versions.com|Versions.com>_bmuschko_cargo_gradle_plugin
        id "org.jetbrains.kotlin.jvm" version <http://Versions.org|Versions.org>_jetbrains_kotlin_jvm_gradle_plugin
        id "org.jlleitschuh.gradle.ktlint" version <http://Versions.org|Versions.org>_jlleitschuh_gradle_ktlint_gradle_plugin
        id "io.gitlab.arturbosch.detekt" version <http://Versions.io|Versions.io>_gitlab_arturbosch_detekt
        }
}

// core modules
include "modules:bmo"
include "modules:bpcsfw"
include "modules:briefcase"
for 6.x, I replaced the
<http://Versions.xxx|Versions.xxx>
with their values
and beginning of top-level
build.gradle
Copy code
buildscript {
    dependencies {
        // for using DigestUtils
        classpath Libs.commons_codec
    }
}

plugins {
    // plugin versions are defined in the top-level settings.gradle
    id "java"
    id "eclipse"
    id "maven"
    id "jacoco"
    id "com.gradle.build-scan"
    id "org.sonarqube"
    id "project-report"
    id "base"
    id "maven-publish"
    id "de.fayard.buildSrcVersions"
    id "com.palantir.jacoco-full-report"
    id "org.ajoberstar.grgit"
}

description = 'Platform Master Project'

import groovy.xml.XmlUtil
import org.apache.commons.codec.digest.DigestUtils
import org.gradle.api.internal.file.IdentityFileResolver
import org.gradle.api.java.archives.internal.DefaultManifest
import org.gradle.internal.jvm.Jvm

buildScan {
    termsOfServiceUrl = '<https://gradle.com/terms-of-service>'
    termsOfServiceAgree = 'yes'
}

// initialization scripts
init()

def excludedProjectNames = [
	'modules',
	'plugins',
	'extensions',
	'sso',
	'security',
	'resources',
	'common',
	'api',
	'ui',
	'qa',
	'test-frameworks',
	'integration',
	'tools',
	'mls',
	'search',
	'rest-api'
]

def getDate() {
	def date = new Date()
	def formattedDate = date.format('yyyyMMddHHmmss')
	return formattedDate
}

def buildNumber = ""

if (project.hasProperty('timestamp')) {
	buildNumber = timestamp
}

ext.buildTime = new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
ext.jarBuildTime = findProperty('jarBuildTime') ?: buildTime

allprojects {
	plugins.withType(JavaPlugin) {
		test {
		ignoreFailures = false
        // set fork arguments for the test.
        // test.maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
        // test.maxParallelForks = 20
        // test.forkEvery = 80
		}
	}

	group = 'com.metricstream.egrcp'

	def egrcpMajorVersion = property('egrcp.project.version')
	def egrcpPatchVersion = property('egrcp.project.patch_version')
//	def buildNumber = getDate()
	version = "${egrcpMajorVersion}.${egrcpPatchVersion}-SNAPSHOT"
	if (buildNumber == "") {
		ext.versionValue = "${egrcpMajorVersion}.${egrcpPatchVersion}"
	}else {
		ext.versionValue = "${egrcpMajorVersion}.${egrcpPatchVersion}.${buildNumber}"
	}
	buildDir = "gbuild"
	ext.msarVersion="NA"
	repositories {
		mavenLocal()
		maven {
			name "ext-release-local"
			url "<http://msjenkins:8081/artifactory/ext-release-local>"
		}
		maven {
			name "libs-release-local"
			url "<http://msjenkins:8081/artifactory/libs-release-local>"
		}
		maven {
			name "libs-snapshot-local"
			url "<http://msjenkins:8081/artifactory/libs-snapshot-local>"
		}
	}

	configurations.all {
		resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
	}
}

htmlDependencyReport {
	projects = project.allprojects
}

subprojects {

	if (name in excludedProjectNames) {
		// skip applying 'gradle' plugins
		// to avoid the creation of empty jars
		return
	}

	apply plugin: 'java'
	apply plugin: 'eclipse'
	apply plugin: 'maven'
	apply plugin: 'jacoco'

	sourceSets {
		main {
			java {
				srcDirs = ['src/main/java']
			}
		}

		test {
			java {
				srcDirs = ['src/test/java']
			}
		}
	}
l
You'll need to migrate buildScan to gradleEnterprise for Gradle 6: https://docs.gradle.com/enterprise/gradle-plugin/#upgrading_to_gradle_6
Then, for all the plugin versions defined in your
settings.gradle
file, you'll need to take the id of the plugin, prepend it with
plugin.
, put it as a key in
versions.properties
, and put the actual value as a value for the property key. Example for `id "org.sonarqube" version Versions.org_sonarqube_gradle_plugin`: You need that in your
versions.properties
file:
<http://plugin.org|plugin.org>.sonarqube=versionYouAreUsing
where
versionYouAreUsing
is the value of
<http://Versions.org|Versions.org>_sonarqube_gradle_plugin
. One all of that is done, you'll need to ensure that there's no
plugins
block in the
pluginManagement
block, and you'll need to put the refreshVersions/dependencies boilerplate setup just below that
pluginManagement
. @nkiesel Ping me if you still have blockers after doing that.
n
will do (hopefully today)
one Q: do I also have to manually convert the rest of
Libs.kt
and
Versions.kt
? I currently have 391 entries in
Libs.kt
...
l
If you have that much in there, it's probably best to wait for the migration tool to be improved then…