1033

Using gradle to download Jar dependencies only

This will download all the dependency jars (and in turn their dependencies too) into the current directory. You need to blank settings.gradle file in the same directory. It works with gradle 7.

apply plugin: 'application'

repositories {
  mavenCentral()
}

dependencies {
  implementation 'org.xerial:sqlite-jdbc:3.40.0.0'
}

task copyToLib(type: Copy) {
  into "."
  from configurations.runtimeClasspath
}

build.dependsOn(copyToLib)

Then run gradle build.

gradle java kotlin
1032

Kotlin: Basic gradle file

Here's a basic build.gradle file you need to compile kotlin. It can go in a directory with a blank settings.gradle file.

plugins {
  id 'org.jetbrains.kotlin.jvm' version '1.8.0' 
  id 'application' 
}

repositories {
  mavenCentral()
}

sourceSets {
  main.kotlin.srcDirs = ['src']
}

compileKotlin {
  kotlinOptions {
    jvmTarget = "17"
  }
}

application {
  mainClass = 'demo.AppKt' 
}

Then in src/ we can put

package demo

class App {}

fun main() {
  println("Hello")
}

Then gradle build run will build and run your application.

You can attempt to reduce the amount of RAM the gradle daemon uses, the thing that makes kotlin compilation not horrifically slow, with export GRADLE_OPTS="-Xmx64m -Dorg.gradle.jvmargs='-Xmx256m -XX:MaxMetaspaceSize=256m'"

kotlin gradle
1031

Vim: if statement based on filetype

&filetype will return something like java or javascript. So this will work

if (&filetype == "java") 
  " whatever you want
endif
vim vimscript
1029

List all the imports in the java standard library with unix tools

There's a src.zip file in /usr/lib/jvm/jdk-17/lib. We can list all the files in this to extract the java imports.

unzip -l src.zip | 
awk '{ print $4 }' | 
sed 's/[^/]*\///'  | 
grep -v module-info | 
grep -v package-info |
sed 's/\.java$//' | 
tail -n +4 | 
sed '/^$/d' | 
sed 's/\//./g'
java unix
Page 1 of 224
vimscript tut
plpgsql tut
nodejs tut
android   
java   
unix   
javascript   
swift  
vim  
kotlin  
ios  
swiftui  
css  
gradle  
maven  
sql
git
kmm
ant
awk
sed
elm
csv
wip
ssh
xml
svg
I'm no longer visiting the Reddit tabloid. It's anger-inducing and divisive
I'm writing small thoughts here