Gradle changing module from nexus snapshot repo not updated - gradle

I have a problem with a snapshot artifact not being uploaded.
I'm using snapshot version. Atrifact is marked explicitly as changing: true and cacheChangingModulesFor is set to 0 seconds.
When i run --refresh-dependecies the artifact is redownloaded properly.
I found the problem while using gradle 2.9. But after upgrading to 2.14.1 the issue remains.
Below is my build.gradle file:
buildscript {
ext {
springBootVersion = '1.3.5.RELEASE'
}
repositories {
mavenCentral()
maven { url 'http://repo.spring.io/plugins-release' }
}
// dependencies for plugins
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7'
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'war'
apply plugin: 'propdeps'
apply plugin: 'propdeps-maven'
apply plugin: 'propdeps-idea'
configurations.all {
// Check for updates every build
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
jar {
baseName = 'someproject'
version = '0.0.1-SNAPSHOT'
}
war {
baseName = "someproject"
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
maven {
url 'http://nexus.example.com:8081/nexus/content/repositories/java-libs-snapshots/'
credentials {
username "someuser"
password "somepassword"
}
}
}
// enables to run with dev profile: $ gradle local bootRun
task local << {
bootRun.systemProperty 'spring.profiles.active', 'local'
}
bootRun {
jvmArgs = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"]
}
dependencies {
compile 'mysql:mysql-connector-java'
compile 'org.springframework.boot:spring-boot-starter-web'
compile group: "pl.example", name: "name", version: "0.7.6.1-SNAPSHOT", changing: true
compile 'org.jadira.usertype:usertype.core:5.0.0.GA'
compile group: 'com.rometools', name: 'rome', version: '1.6.0'
compile group: 'org.jsoup', name: 'jsoup', version: '1.9.2'
compile 'org.hibernate:hibernate-search:5.5.3.Final'
compile 'org.projectlombok:lombok:1.16.6'
}

I think you maybe have the syntax for the changing dependency slightly wrong.
Can you try replacing:
compile group: "pl.example", name: "name", version: "0.7.6.1-SNAPSHOT", changing: true
with:
compile ("pl.example:name:0.7.6.1-SNAPSHOT"){ changing = true }
Can you also try adding a line to the resolutionStrategy for cacheDynamicVersionsFor as follows:
configurations.all {
resolutionStrategy {
cacheDynamicVersionsFor 0, "seconds"
cacheChangingModulesFor 0, "seconds"
}
}

Related

Could not find method mavenContent() for arguments

I am trying to add a private nexus maven repo/utility to a gradle project (referred: https://docs.gradle.org/current/userguide/declaring_repositories.html#maven_repository_filtering).
Posting this issue as I haven't found any solution yet.
// Apply the java-library plugin to add support for Java Library
apply plugin: 'eclipse'
apply plugin: 'application'
apply plugin: 'spring-boot'
apply plugin: 'net.researchgate.release'
apply plugin: 'maven'
// Configure project-level settings.
project.ext {
mainClass = "${mainClass}"
configFile = "$rootProject.projectDir/src/resources/application.properties"
finalJarName = "${name}-${version}.jar"
javaVersion = '1.8'
springBootVersion = '1.3.4'
springBootActuatorClient = '1.5.3.RELEASE'
apacheCommonIOVersion = '2.5'
camelVersion = '2.17.2'
solrVersion = '5.4.0'
}
// JAR/FatJAR configuration
mainClassName = "${mainClass}"
// In this section you declare where to find the dependencies of your project
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
flatDir {
dirs 'lib'
}
maven {
url "http://nexus.repo.com/nexus/content/repositories/releases/"
credentials {
username = "${mavenUser}"
password = "${mavenPassword}"
}
mavenContent {
releasesOnly()
}
}
}
// Configure the build script.
buildscript {
ext {
springBootVersion = '1.3.6.RELEASE'
systemrulesVersion = '1.16.1'
}
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'net.researchgate:gradle-release:2.6.0'
}
}
dependencies {
........
compile group: 'com.some.utility.third-party-integrations', name: 'third-party-integrations', version: '1.0.29'
}
Firstly, the above implementation gives me error as,
Could not find method mavenContent() for arguments [build_6vwlfgalblecd5o2a6rgk023i$_run_closure1$_closure3$_closure6$_closure8#36b310aa] on org.gradle.api.internal.artifacts.repositories.DefaultMavenArtifactRepository_Decorated#10c2064a.
Secondly, if I remove that it generates an error for the dependency that I have added as below,
Could not resolve com.some.utility.third-party-integrations:third-party-integrations:1.0.29.
> inconsistent module metadata found. Descriptor: com.some.utility.third-party-integrations:third-party-integrations:1.0.0-SNAPSHOT Errors: bad version: expected='1.0.29' found='1.0.0-SNAPSHOT'

How do I configure KoTest with Gradle in a LibGdx project? Currently can't build because StringSpec is not recognised

I have a standard LibGdx project setup by the LibGdx tool, only targeting desktop. It uses Gradle (Groovy DSL) to manage dependencies and tasks. I've converted the core module to Kotlin, and I'm trying to add a Kotlin test module using Kotest.
I've followed the Kotest instructions for Gradle on their GitHub but the compile is failing because StringSpec isn't reocgnised (Unresolved reference: StringSpec). I think LibGdx's default Gradle setup may be a little outdated or use older syntax/structure, and perhaps it's conflicting with Kotest's instructions intended for newer versions of Gradle?
For now I've removed any test and am just trying to get it to recognise StringSpec and compile. I've not even reached the stage of getting IntelliJ to recognise and run the tests. Here's what I have so far:
core.tests/tests/com/me/game/AcceptanceTests.kt
package com.jansky.myproject
class AcceptanceTests : StringSpec() {
}
core.tests/gradle.build
version '1.0'
sourceCompatibility = 1.7
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = [ "tests/" ]
tasks.withType(Test) {
useJUnitPlatform()
}
eclipse.project.name = appName + "-core.tests"
./build.gradle (ie the root buildfile)
buildscript {
ext.kotlinVersion = '1.3.71'
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
google()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
allprojects {
apply plugin: "eclipse"
version = '1.0'
ext {
appName = "game"
gdxVersion = '1.9.10'
roboVMVersion = '2.3.8'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
google()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "kotlin"
dependencies {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.ashley:ashley:1.7.3"
compile group: 'io.github.libktx', name: 'ktx-ashley', version: '1.9.10-b4'
}
}
project(":core") {
apply plugin: "kotlin"
dependencies {
api "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
compile "com.badlogicgames.ashley:ashley:1.7.3"
compile group: 'io.github.libktx', name: 'ktx-ashley', version: '1.9.10-b4'
}
}
project(":core.tests") {
apply plugin: "kotlin"
test {
useJUnitPlatform()
}
dependencies {
api "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
compile "com.badlogicgames.ashley:ashley:1.7.3"
compile group: 'io.github.libktx', name: 'ktx-ashley', version: '1.9.10-b4'
implementation 'io.kotest:kotest-runner-junit5:4.0.2'
implementation 'io.kotest:kotest-assertions-core:4.0.2'
}
}
settings.gradle
include 'desktop', 'core', 'core.tests'
Gradle-wrapper.properties
#Sat Apr 04 15:53:20 BST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
I don't have much JVM experience, so I'm at a bit of a loss. Hopefully I've missed something that's obvious to someone that knows Gradle better. Any ideas?

One Gradle Thymeleaf project reloads on resource change, the other relaunches

EDIT: I've narrowed down the behavior a bit, not sure if there's a way to accomplish what I need.
Turns out, my app has the Thymeleaf templates one level down in the source tree:
src/main/resources/tools-server/templates
And I set this in my tools-server.yml file that gets explicitly loaded at application launch. Removing that specification from my configuration, and moving the templates directory up one level to
src/main/resources/templates
Allows spring-boot-devtools to simply reload the template without restarting the app. I think I’ll file a bug with the project, unless there’s a way around it.
I'm still getting the hang of Spring Boot, so bear with me. I've created two projects over the last few months, each starting from different examples found online.
With respect to reloading Thymeleaf templates, the first project does it neatly when they change, issuing two log messages when a template changes, and nothing more. The other does a complete stop and restart of the application, which causes problems because it re-creates the temporary security password, among other things (it also takes longer).
The two gradle.build files are nearly identical, with slightly different dependencies. I'm not sure if those are the differences causing the different behavior.
The working one:
buildscript
{
ext
{
springBootVersion = "1.4.3.RELEASE"
}
repositories
{
mavenCentral()
}
dependencies
{
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath group: "com.layer", name: "gradle-git-repo-plugin", version: "2.0.2"
}
}
apply plugin: "git-repo"
apply plugin: "java"
apply plugin: "maven"
apply plugin: "spring-boot"
jar
{
baseName = "HOA"
version = "0.0.1-SNAPSHOT"
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories
{
mavenCentral()
maven { url "https://maven.atlassian.com/3rdparty/" }
maven { url "https://mvnrepository.com/artifact/" }
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/milestone" }
}
dependencies
{
compile group: "org.mindrot", name: "jbcrypt", version: "0.4-atlassian-1"
compile group: "org.eclipse.persistence", name: "javax.persistence", version: "2.1.1"
compile group: "org.springframework.data", name: "spring-data-jpa", version: "1.10.4.RELEASE"
compile group: "org.springframework.hateoas", name: "spring-hateoas", version: "0.21.0.RELEASE"
compile group: "com.h2database", name: "h2", version: "1.4.192"
compile("org.springframework.boot:spring-boot-devtools")
compile("org.springframework.boot:spring-boot-starter-aop")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.boot:spring-boot-starter-groovy-templates")
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-starter-web")
// Automated Testing
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile("org.springframework.restdocs:spring-restdocs-mockmvc")
}
dependencyManagement
{
imports
{
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Camden.SR1"
}
}
compileJava
{
options.compilerArgs << "-Xlint:all" << "-Xdiags:verbose"
}
bootRepackage
{
mainClass = "com.latencyzero.hoa.Application"
}
bootRun
{
addResources = true
}
The messy one:
buildscript
{
ext
{
springBootVersion = '1.4.3.RELEASE'
}
repositories
{
mavenCentral()
}
dependencies
{
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'org.springframework.boot'
sourceCompatibility = 1.8
targetCompatibility = 1.8
archivesBaseName = 'toolcrib'
compileJava
{
options.compilerArgs << "-Xlint:all" << "-Xdiags:verbose"
}
jar
{
manifest
{
attributes 'Implementation-Title': 'ToolCrib',
'Implementation-Version': version
}
}
repositories
{
mavenCentral()
}
dependencyManagement
{
imports
{
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Camden.SR3'
}
}
dependencies
{
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
compile('org.springframework.boot:spring-boot-devtools')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
runtime('org.postgresql:postgresql')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
springBoot
{
mainClass = "com.latencyzero.toolcrib.services.tools.ToolsServer"
}
bootRun
{
addResources = true
}
Thanks for any insight!
Have you had a look to the documentation
By default changing resources in /META-INF/maven, /META-INF/resources, /resources, /static, /public or /templates will not trigger a restart but will trigger a live reload.
And
If you want to customize these exclusions you can use the spring.devtools.restart.exclude
There is also spring.devtools.restart.additional-exclude to add more excludes and keep the defaults. In your case, you should add the following to your configuration:
spring.devtools.restart.additional-exclude=classpath:/tools-server/templates/

Gradle How can i specify the cacheResolutionStrategy for the SNAPSHOT version in my buildscript block?

I am having problems with resolutionStrategy.cacheChangingModulesFor.
My project build.gradle looks similar to this
apply plugin: 'base'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply from: "gradle/mixins/cachestrategy.gradle"
configurations.all {
resolutionStrategy.cacheDynamicVersionsFor 5, 'minutes'
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
buildscript {
repositories {
maven {
url artifactoryUrl
}
}
dependencies {
classpath (group: 'com.myorg', name: 'aCustomPlugin', version: '1.5.0-SNAPSHOT') {
changing = true
}
}
}
allprojects {
apply plugin: 'base'
apply plugin: 'com.myorg.aCustomPlugin'
}
my question is: How can i specify the cacheResolutionStrategy for the SNAPSHOT version in my buildscript block?
specifying it outside the block, doesn't work (since the buildscript block is evaluated first, in order to build the scripts... ) so the cache strategy rules defined in the scripts haven't been evaluated yet.
the resolution strategy should be placed in the buildscript block like this
buildscript {
repositories {
mavenLocal()
maven {
url artifactoryUrl
}
}
dependencies {
classpath (group: 'com.myorg', name: 'aCustomPlugin', version: '1.5.0-SNAPSHOT') {
changing = true
}
}
configurations.all {
resolutionStrategy.cacheDynamicVersionsFor 5, 'minutes'
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
}

Setting up Gradle Cargo

I am trying follow this tutorial to set up Grails/ Cargo: https://github.com/bmuschko/gradle-cargo-plugin I wish to use this plugin to deploy wars to local tomcat instances and to start and stop them.
Here is my build.gradle
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'cargo'
sourceCompatibility = 1.5
version = '1.0'
jar {
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version
}
}
repositories {
mavenCentral()
}
dependencies {
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
testCompile group: 'junit', name: 'junit', version: '4.+'
classpath 'org.gradle.api.plugins:gradle-cargo-plugin:0.6.1'
def cargoVersion = '1.3.3'
cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion",
"org.codehaus.cargo:cargo-ant:$cargoVersion"
}
cargo {
containerId = 'tomcat6x'
port = 9090
deployable {
file = file('/Users/me/Documents/gradlemucks/grails_2/hello-world/target/hello-world-0.1.war')
context = 'helloworld'
}
local {
homeDir = file('/Users/me/developer/servers/apache-tomcat-6.0.37')
output = file('build/output.log')
tomcat {
ajpPort = 9091
}
}
}
test {
systemProperties 'property': 'value'
}
uploadArchives {
repositories {
flatDir {
dirs 'repos'
}
}
}
When I do gradle tasks in the terminal I get:
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/me/Documents/workspaces/regress_test/httptests/build.gradle' line: 3
* What went wrong:
A problem occurred evaluating root project 'httptests'.
> Plugin with id 'cargo' not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
What are my doing wrong?
The buildscript itself need the cargo dependency so adding:
buildscript {
repositories {
mavenCentral()
}
dependencies { classpath "org.gradle.api.plugins:gradle-cargo-plugin:0.6" }
}
should make it able to find the cargo plugin.

Resources