Menu
  • HOME
  • TAGS

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

Tag: gradle

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?

Best How To :

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'
  }
}

Visualizing gradle dependencies in Intellij

intellij-idea,gradle,intellij-14

I did a small search in IDEA and Google and looks like there is not way to see Gradle dependency but I have found the plugin "Gradle View" which does what you need http://plugins.jetbrains.com/plugin/7150 You can open a ticket and maybe they will add a better Gradle support in IDEA...

How to create different build variants pointing to different Servers?

android,gradle

It is really easy to do with gradle. productFlavors { first_server { buildConfigField "String", "SERVER_URL", "\"https://first_server_url/\"" } second_server { buildConfigField "String", "SERVER_URL", "\"https://second_server_url/\"" } } You may want to find more information here. So later you can easy access this variable by BuildConfig.SERVER_URL...

Android studio gradle flavor dimensions build varients not working correctly

android-studio,gradle,android-gradle,build.gradle,android-productflavors

I think you misunderstood the concept of flavorDimension. A flavorDimension is something like a flavor category and every combination of a flavor from each dimension will produce a variant. In your case, you must define one flavorDimension named "type" and another dimension named "organization". It will produce, for each flavor...

Deploy closed source aar maven repo to github

android,git,maven,github,gradle

use the raw link, try changing blob for raw: http://downright-amazed.blogspot.com/2011/09/hosting-maven-repository-on-github-for.html...

Choosing specific ports on local development server for non-default modules

java,google-app-engine,android-studio,gradle,app-engine-modules

@crazystick answered it for Maven. Here's the same solution re-done for Gradle: apply plugin: ear ... appengine { downloadSdk = true httpAddress = "0.0.0.0" jvmFlags = ['-Dcom.google.appengine.devappserver_module.default.port=8080', '-Dcom.google.appengine.devappserver_module.module1.port=8081'] appcfg { email = "[email protected]" oauth2 = true } } ...

Gradle & Jacoco: Get jacoco reports for Test-type task other than “test”

java,gradle,jacoco

Turns out, this works: task integTestReport (type: JacocoReport) { executionData project.tasks.integTest sourceDirectories = project.files(project.sourceSets.test.allSource.srcDirs) classDirectories = project.sourceSets.test.output def reportDir = project.reporting.file("jacoco/integTest/html") reports { html.destination = reportDir } doLast { println "See report at: file://${reportDir.toURI().path}index.html" } } I hope this is helpful :) EDIT: This needs to be later in the...

Gradle : Cannot add task ‘:helloFromBuild1′ as a task with that name already exists

gradle

Task name collision may result from improperly importing files. For a better explanation see here.

Gradle Exec : Why it is not running in configuration phase?

gradle,exec,mkdir

Please have a look at AbstractExecTask from which Exec inherits. As you can see there are lots of getters and setters. What happens at configuration time is setting the values for that fields only, not running them. All the properties set will be used in only when exec() method annotated...

Gradle Assemble Debug is Successful But Does Not Work [duplicate]

android,command-line,gradle

Look for build outputs under the app module. app/build/outputs/...

scala minecraft forgemod 'gradle runClient' gives runtime exception

scala,gradle,akka,minecraft,minecraft-forge

I figured it out. application.conf had: provider = "akka.cluster.ClusterActorRefProvider" cluster isn't part of akka-actor its part of akka-cluster. I've switched to provider = "akka.actor.LocalActorRefProvider" That works now. The other option is to add akka-cluster to the dependancies list. If your actually trying to use ClusterActorRefProvider...

Spring Boot Actuator Info Endpoint Version from Gradle File

gradle,spring-boot

This exact use case is spelled out in the Boot docs: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production-ready-application-info-automatic-expansion-gradle So in your build.gradle do this version = '0.0.1-SNAPSHOT' processResources { expand(project.properties) } Your application.yml info: build: version: ${version} Make sure to escape any spring placeholders so it doesn't conflict with Gradle. Both use ${} as the replacement...

gradle execute task after build

gradle,build.gradle

What you need is finalizedBy, see the following script: apply plugin: 'java' task finalize << { println('finally!') } build.finalizedBy(finalize) Here are the docs....

Add project on outer level as dependency to module

android,intellij-idea,gradle

Add dependencies in the 'build.gradle' of your MainProject, like this: compile project(':proj1') compile project(':proj2') EDIT: And in the 'settings.gradle' this: include ':proj1' project(':proj1').projectDir = new File('../proj1') include ':proj2' project(':proj2').projectDir = new File('../proj2') ...

duplicate an android studio project

android,gradle,duplicates,project,sync

i think that i found the source of my problem it was a virtual machine problem. so the solution is : open file -> settings clic to : compiler in the VM option field put te following value: -Xmx512m That's all...

Adding Android AppWidget just for one Product Flavor

android,gradle,android-appwidget,android-productflavors

So we will have our example packages is as follows for your production and staging builds within the gradle product flavors. productFlavors { production { packageName "x(path).x(path).gradleexample" } staging { packageName "x(path).x(path).gradleexample.staging" } } Here is an example of your folder structure some of which may or may not apply...

Issue building project on Android Studio - support-v4

android,gradle,android-gradle,build.gradle

Alrighty the solution was to update gradle on build.gradle of my project, not module // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.2.3' } } allprojects { repositories { jcenter() } } it was set...

Paid and Free versions of android app

android,gradle,android-version

You could have two versions of the application in Play store. However, you would have to maintain these separately and it is frustrating to upgrade from free to paid with this approach. If you chose this way of maintaining your application, you would have to have two projects, one for...

Android Studio and gradle

android,android-studio,gradle

So I have found the solution at this http://www.alonsoruibal.com/my-gradle-tips-and-tricks/. The trick is in your Java Library module's build.gradle file you need to include the following. apply plugin: 'java' sourceCompatibility = 1.6 targetCompatibility = 1.6 Wrong Java Compiler When Including a Java Module as Dependency in Android Studio...

How to declare a constant that is visible to all modules' build.gradle file?

android,gradle,android-gradle

The way I choose to do something similar is to create a properties file and then just read that for all my global variables. You can do this with java syntax: Properties props = new Properties() props.load(new FileInputStream("/path/file.properties")) A more groovy like syntax is that's what you perfer is: Properties...

Proguard - also use proguard files from modules

android,android-studio,gradle,proguard,android-proguard

The solution is to add following line to the libraries build.gradle: consumerProguardFiles 'proguard-rules.pro' So my androKnife library looks like following: apply plugin: 'com.android.library' android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { minSdkVersion 15 targetSdkVersion 22 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' consumerProguardFiles...

android studio “Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly”

android-studio,gradle,android-gradle

Have you had the project compile / work before? If so the issue is most likely your XML files having issues. Also try to make clean and make sure all of your dependencies are correct if you imported any. You haven't given much info besides the error code about your...

How to download a library dependence on gradle for external use?

cordova,android-studio,gradle,android-gradle,cordova-plugins

What you're looking for is an aar file. You can copy this file to lib folder with the following script: apply plugin: 'java' repositories { mavenCentral() } dependencies { compile 'io.filepicker:filepicker-android:[email protected]' } task copyLibs(type: Copy) { from configurations.compile into 'lib' } ...

How to use Library from GitHub in android App

android,github,gradle,libraries

You have add path to your aFileDialog library in your settings.gradle Make sure that folder you point to includes build.gradle file include ':app' include ':aFileDialog' project(':aFileDialog').projectDir = new File(settingsDir, 'aFileDialog') or (judging from the library folder structure on GitHub) project(':aFileDialog').projectDir = new File(settingsDir, 'aFileDialog/library') ...

Gradle not using latest version of the support library?

android,android-studio,gradle,android-support-library,recyclerview

I am not sure, How are you able to import it, But if you want to use RecyclerView, you need to add its dependency, i.e. compile 'com.android.support:recyclerview-v7:22.2.0' I don't see if you have added RecyclerView dependency to your gradle script. Also, keep in mind, it doesn't come with appcompat package....

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException

android,android-studio,gradle,multidex

Try adding dexOptions{ incremental true javaMaxHeapSize "4g" } ...

Phonegap: Command failed with exit code 8

android,cordova,gradle

I have already managed to solve this problem, so, in case of anyone has a similar trouble, here it goes the situation I've gone through. When I performed the first build, phonegap attempted to download and extract it's own gradle distribution, and he was attempting to download it from the...

Duplicate entry for class in gradle

java,android,android-studio,gradle

The above library is already on maven. Just remove the imported folder and add the code below to your dependencies: compile 'com.flaviofaria:kenburnsview:1.0.6' Sometimes due to downloading issues; the library fails to download. In that case ; just find your .gradle folder and clear cache inside it. Recompile and you are...

How to exclude dependencies of other subproject in Gradle build?

java,eclipse,gradle,dependencies,dependency-management

You could exclude all transitive dependencies of a dependency: compile('groupId:artifactId:version') { transitive = false } Or you could, but I do certainly not recommend this exclude every dependency by hand like this: compile('groupId:artifactId:version') { exclude module: 'groupId:artifactId:version' ... } ...

what is gradle missing to map hibernate?

java,hibernate,gradle

I think the problem is not really with gradle. It's with the fact that the JPA spec stupidly requires that the classes of the entities are in the same jar/directory as the persistence.xml file. And since Gradle doesn't store the "compiled" resources in the same output directory as the compiled...

Android Studio work with module

java,android,android-studio,gradle

You need to check all Manifest files and ensure your modules are not providing activity with <intent-filter> used by Lauchers: <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> Also ensure your module's build.gradle for module is lists apply plugin: 'com.android.library' (as it should), and not apply plugin: 'com.android.application' (which is not correct)...

Gradle : Stackoverflow Error

gradle,stack-overflow

Actually , I was creating cyclic dependency in files which resulted into this.For a better explanation see here.

Gradle Jar structure is different than the real project structure

java,jar,gradle,build

When your project is managed by gradle you should always use standard layout introduced by maven or have a good excuse to using any different layout. Here you can find sample project that shows how to use the this layout and read the resources that will be later included in...

Is it possible to exclude specific build variant when using flavor Dimensions?

android,gradle

Since Gradle 0.9 you can apply a variant filter and iterate over them: productFlavors { freeapp { dimension "version" } x86 { dimension "abi" } paidapp { dimension "mips" } } // Loop variants android.variantFilter { variant -> // Loop flavors variant.getFlavors().each { flavor -> println variant.buildType.name + " "...

Android build project error trying to build apps > 65K (65536) methods

android,android-studio,gradle,build,android-gradle

You need to reduce the size or include only the imports you need to for your application. You are hitting the dex limit of 65536 methods. Here's the link Building Apps with Over 65K Methods which might help....

How to elegantly build selected parts of a project

gradle

Considering what you describe I would definitely go for a multi project set-up, this solves problem one as there are default ways to call only certain subprojects. More about multi-project build can be found here and a more specific StackOverflow question about executing tasks of subprojects can be found here....

Automatically copy .so files from NDK library project?

android-studio,gradle,android-ndk

I does not know if ther is a way to have you .so files copied as you want whiout wirtting anything. But you could have gradle doing it for you. In your gradle file, add a task that copy those .so files where you need them to be. android {...

Install gradle on Centos

jenkins,gradle

... but when I unzipped I got gradle.bat file inside bin directory which tells me that this is for Windows. It also contains a file called gradle, which is a shell script. Your download is also suitable for running on any Linux or UNIX platform .... including CentOS....

Exclude Package From Gradle Dependency

java,web-services,rest,gradle

I found out that com.sun.jersey:jersey-core:1.19 doesn't bundle the javax.ws.rs class files and instead lists them as a compile-time dependency. Adding this snippet to my build.gradle fixed the issue. configurations.all { resolutionStrategy { // For a version that doesn't package javax.ws force 'com.sun.jersey:jersey-core:1.19' } } ...

Set variable to Gadle build file

gradle

That's because the line versionNameSuffix " branch: " + "$branch" is executed during the configuration phase, when all the tasks are configured. Then, when this phase is done and gradle knows all the tasks and their dependencies, setArgs is executed, and the following line is executed: branch = "$word1" You...

Incorrect liferay-plugins dependency

gradle,dependencies,liferay,liferay-6.2

The 6.2 branch is mainly used for development, and those Gradle scripts are not designed to run on Liferay 6.2. Furthermore, they've been removed in the master branch, replaced by a series of Gradle plugins written in Java. Everything is still under active development, but anyway you're more than welcome...

Gradle - Error:Failed to find: com.squareup.okhttp:okhttp:2.4.0

android,android-studio,gradle,okhttp

You need to add the following block to the build script: repositories { mavenCentral() } ...

Can't use RecyclerView in my Android library project

android,gradle,dependencies,recyclerview,android-library

Rebuilt the project and clean it

Using GradleBuild , how to specify individual task to execute from tasks list

gradle

As far as I understood you just need to run: gradle hi or gradle hello All tasks from other.gradle are imported to build gradle and can be used out of the box....

Get the Git Working Branch in Gradle on Jenkins

git,jenkins,gradle

If this is only for testers/downstream, what about using Jenkins' Git environment variables instead, e.g. $GIT_BRANCH? Locally, it will show no version/empty when you build, but when you build on Jenkins it will show the correct branch name in your 'version' string. To get around the local builds producing an...

Creating and referencing a library for Android project (using command line and gradle)

java,android,linux,opencv,gradle

I was finally able to create a library and use it in my Android project! The following links were helpful: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Dependencies-Android-Libraries-and-Multi-project-setup https://docs.gradle.org/current/userguide/multi_project_builds.html http://www.petrikainulainen.net/programming/gradle/getting-started-with-gradle-creating-a-multi-project-build/ This whole process made me understand why most people just use Ecipse or Adnroid Studio. But if anyone else wants to try this, I will...

Gradle multi-project custom build.gradle file name

gradle,build,multi-project

A simple web search for "gradle rename build.gradle" renders the below example settings.gradle file: rootProject.buildFileName = 'epub-organizer.gradle' rootProject.children.each { project -> String fileBaseName = project.name.replaceAll("\p{Upper}") { "-${it.toLowerCase()}" } project.buildFileName = "${fileBaseName}.gradle" } Note that the author is here also renaming the root project's build script, which you may or may...

Roboblender use annotation databases with multiple modules

android,gradle,dependency-injection,roboguice,roboblender

After some hours I found the problem. It was proguard. Adding the following line fixed the issue. -keep public class * extends com.google.inject.AnnotationDatabase You can check that the classes are being generated by running in the project folder: find . | grep -i AnnotationDatabaseImpl ...

Gradle: Adding sources.jar file within /lib folder of published dist.zip along with all my other dependencies

java,maven,jar,gradle

You need to tell the application plugin to include the output of your sourcesJar task in the distribution: distributions { main { contents { from sourcesJar } } } That will place it in the root, if you want it somewhere else you can do this: distributions { main {...

Android Studio Best way import module from other repository

android,git,gradle,repository

I'd advice to use Jitpack Jitpack: Easy to use package repository for GitHub, just include it inside your gradle, and now you can deal with github project as a module Thanks Jitpack <3 For example: we have this repository: https://github.com/florent37/MaterialViewPager and with Jitpack in your gradle: repositories { maven {...

Using ant.replace in gradle

replace,ant,gradle

It should be: task writeVersion << { ant.replace( file: 'version.txt', token: 'versionNumber', value: '1.0.0' ) } and: version.number=versionNumber ...