Comments (14)
Alright, I was able to reproduce aforementioned behavior on [email protected] (worked fine on gradle 2.4.1).
Solution is described at https://discuss.gradle.org/t/download-all-dependencies/6294/4, which boils down to:
- add to build.gradle
allprojects {
task dependenciesResolve {
doLast {
configurations.all { it.resolve() }
}
}
}
- instead of
gradle dependencies
usegradle dependenciesResolve
.
Tested on chibatching/docker-android-sdk
docker image.
🎈
from ktlint.
@jeremymailen thank you for trying to help, I appreciate it 🙇♂️
from ktlint.
Hi @Drarok. Any chance you can share your build.gradle? The only case I can think of where ktlint would download anything is when using external 3rd party ruleset (-R flag). But even then caching ~/.m2 should work just fine.
FYI: You can use ktlint as a standalone binary (see https://ktlint.github.io/#getting-started) without the need for Maven or Gradle.
from ktlint.
I may have put things into the wrong gradle file, so here's both! Thanks for looking into this.
Project build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.2-3'
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// The exception to this rule is compile-time dependencies, such as these:
classpath 'de.felixschulze.gradle:gradle-hockeyapp-plugin:3.5'
classpath 'com.github.shyiko:ktlint:0.6.1'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'de.felixschulze.gradle.hockeyapp'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "<REDACTED>"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations {
ktlint
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
testCompile 'junit:junit:4.12'
ktlint 'com.github.shyiko:ktlint:0.6.1'
}
task ktlint(type: JavaExec) {
main = "com.github.shyiko.ktlint.Main"
classpath = configurations.ktlint
args "src/**/*.kt"
}
check.dependsOn ktlint
task ktlintFormat(type: JavaExec) {
main = "com.github.shyiko.ktlint.Main"
classpath = configurations.ktlint
args "-F", "src/**/*.kt"
}
hockeyapp {
apiToken = "<REDACTED>"
}
from ktlint.
@Drarok Just to clarify: you are caching both ~/.gradle and ~/.m2?
from ktlint.
@Drarok what gradle target do you currently run in the dependencies
section of your circle.yml
to pull things to cache? Gradle of course is notoriously lazy/efficient about getting dependencies and of course CircleCI only caches after the dependencies step which is usually ahead of most people's gradle targets that do interesting things.
from ktlint.
I've just double checked, both are cached, yes.
Run: ./gradlew dependencies
Cache: Creating dependency cache from the following paths:
/home/ubuntu/.go_workspace
/home/ubuntu/.gradle
/home/ubuntu/.m2
Run: ./gradlew ktlint
Output (note the downloads from
> Connecting to Daemon> Configuring > 0/2 projects > root project > Resolving dependencies ':classpat> Configuring > 1/2 projects > :appNDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to /usr/local/android-sdk-linux/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
> Configuring > 2/2 projects > Resolving dependencies ':app:_debugApk'> Configuring > 2/2 projectsIncremental java compilation is an incubating feature.
> Configuring > 2/2 projects > Resolving dependencies ':app:_releaseUnitTestApk> Configuring > 2/2 projects > Resolving dependencies ':app:_debugAndroidTestAp> Configuring > 2/2 projects> Building 0% > :app:ktlint > Resolving dependencies ':app:ktlint'> Building 0% > :app:ktlint:app:ktlint
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.1.0/kotlin-compiler-embeddable-1.1.0.jar
> Building 0% > :app:ktlint> Building 0% > :app:ktlint > 833 KB/25.88 MB downloaded> Building 0% > :app:ktlint > 1.87 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 3.06 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 4.50 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 6.25 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 7.14 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 8.92 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 9.64 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 10.87 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 11.70 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 12.78 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 13.99 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 15.26 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 15.92 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 16.50 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 17.23 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 17.77 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 18.54 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 20.03 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 21.31 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 23.57 MB/25.88 MB downloaded> Building 0% > :app:ktlint > 25.88 MB/25.88 MB downloaded
> Building 0% > :app:ktlintDownload https://jcenter.bintray.com/org/apache/httpcomponents/httpclient/4.3.5/httpclient-4.3.5.jar
> Building 0% > :app:ktlint
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcore/4.3.2/httpcore-4.3.2.jar
> Building 0% > :app:ktlintDownload https://jcenter.bintray.com/commons-codec/commons-codec/1.6/commons-codec-1.6.jar
> Building 0% > :app:ktlint> Building 0%
BUILD SUCCESSFUL
from ktlint.
It looks like it only triggers the download when the configurations
ktlint
is resolved. I don't think the classpath 'com.github.shyiko:ktlint:0.6.1'
in the buildscript
block is triggering a dependency download since it isn't part of an applied plugin? If you remove it I think you'll find your ktlint
task still works 🤔.
from ktlint.
Well on 2nd take it looks like having classpath 'com.github.shyiko:ktlint:0.6.1'
in buildscript
does trigger a download of some dependencies on gradle dependencies
but not a few of the transitive ones like kotlin-compiler-embeddable
.
from ktlint.
Hmm, so am I stuck having it download its transitive dependencies, or can I force Gradle to download those somehow?
from ktlint.
Sorry @Drarok, got distracted at work. I'll try to provide an answer within 24h.
from ktlint.
Honestly, don't rush! I'm not back in work where this is is only a minor inconvenience until Tuesday anyway.
Have a good weekend! 😄
from ktlint.
@Drarok have a great weekend too ;)
from ktlint.
Finally got around to implementing this change, and my latest build didn't download anything extra, so everything's being cached as expected! 🎉
Thanks to everyone that helped.
from ktlint.
Related Issues (20)
- Improve quality control whether formatted code can still be compiled
- Remove SDKMan
- Unstable format results with anonymous function HOT 2
- Indentation error on malformed formatter closing tag
- Imports only used in blocks which may not be formatted are reported as unused
- Restrict import package HOT 1
- Add copy/paste enable/disable lines for each rule HOT 3
- ktlint has become too opinionated HOT 38
- No args constructor can be improperly removed HOT 1
- The class-signature rule wrong wrapping in 1.3.0. HOT 2
- Single-line chain method calls with operator HOT 3
- v1.3.0 class-signature error for android_studio config HOT 7
- Properties that start with `_` should be suppressed by `PropertyName` HOT 1
- Cannot apply default formatting Kotest\StringSpec when migrate from 1.0.1 -> 1.3.0 HOT 5
- Documentation unclear/inconsistent about rule names HOT 4
- Enable installing a specific version of ktlint via brew HOT 1
- Format was not able to resolve all violations which (theoretically) can be autocorrected
- Some rules in https://pinterest.github.io/ktlint/latest/rules/standard/ missing "Suppress or disable rule" HOT 1
- Allow single-line `try`/`catch` statements HOT 2
- Inconsistent starting position of chain method continuation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ktlint.