I want to write a simple ORM on Kotlin Native. I'm creating a project in the Multiplatform Library studio. Found the Sql Delight driver. According to the documentation, I'm trying to install it. But nothing comes out. How to connect SqlDelight driver to Multiplatform Kotlin Library?
Here is my gradle.wrappers:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
build.gradle:
plugins {
id 'org.jetbrains.kotlin.multiplatform' version '1.3.41'
}
repositories {
google()
mavenCentral()
}
group 'com.example.test'
version '0.0.1'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'maven-publish'
apply plugin: 'com.squareup.sqldelight'
archivesBaseName = 'store-item'
configurations {
compileClasspath
}
kotlin {
jvm()
sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib-common')
}
}
commonTest {
dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
}
}
jvmMain {
dependencies {
implementation kotlin('stdlib-jdk8')
implementation "com.squareup.sqldelight:sqlite-driver:1.1.4"
}
}
jvmTest {
dependencies {
implementation kotlin('test')
implementation kotlin('test-junit')
}
}
}
}
Gradle writes: Plugin with id 'com.squareup.sql delight' not found.
The first step in the SQLDelight docs is to set up the Gradle plugin.
By default Gradle will only search the Gradle Plugin Portal for plugins. But the SQLDelight Gradle plugin isn't published to Gradle Plugin Portal, it's published to Maven Central.
You need to add config to tell Gradle to search Maven Central for Gradle plugins.
However, you are on an old version of Gradle - 5.6. The current version of SQLDelight is 1.5.4, which is only compatible with Gradle 7+. You'll need to update your version of Gradle.
Related
I am trying to configure a project that uses react-native and google firebase native.
The set up for react-native worked fine, but I ran into a problem with google firebase native.
I followed the instructions at rnfirebase.io.
When I try to sync My project with gradle files from Android Studio, I get the following error:
Build file 'C:\github\flashcards\flashcards\android\app\build.gradle' line: 139
A problem occurred evaluating project ':app'.
> Could not find method plugins() for arguments [build_2psolmxgn6smlx7165ef739cv$_run_closure1$_closure5#1b639892] on extension 'android' of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.
* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
...
Here is the relevant portion of my /android/build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
...
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.2.1")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:5.0.1")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath('com.google.gms:google-services:4.3.14')
}
}
allprojects {
repositories {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup "com.facebook.react"
}
}
google()
maven { url 'https://www.jitpack.io' }
}
}
I added the following two lines to the top of my /android/app/build.gradle file:
apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'
Any suggesions for how to fix this problem?
I expected the Sync Project with Gradle files command to complete successfully, but I receive the error described above.
We have a Java app that was built using 2017 version of JFrog java services jar. Today I am trying to rebuild it using latest jfrog lib. I see that the new services jar doesn't have org.apache.* packages in it.
This is how I built jfrog services jar.
Downloaded 2.8.6 source zip and expanded it
Upgraded gradle to latest and ran "gradle clean build -x test -x javadoc"
Then copied services/build/lib/*services-2.8.6.jar ONLY to my project lib folder
When I try to build, I see so many compilation errors. The old lib was called something like artifactory-java-client-ning-services-1.2.0-all.jar.
How do I build one like it?
Update on 11/6/20 after Dror responses below:
I changed the build strategy to point to jcenter to download and create uber jar with all the dependencies with gradle file like below. I am still running into missing classes.
Below is one of those errors:
error: package org.jfrog.artifactory.client.ArtifactoryClient does not exist
import org.jfrog.artifactory.client.ArtifactoryClient.ProxyConfig;
In Netbeans IDE that I am using, I can expand each package in a jar and see the classes in it. I don't see anything under org.jfrog.artifactory.client package. That is strange.
My build.gradle:
group 'org.jftog.example'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.13
repositories {
jcenter()
}
dependencies {
compile 'org.apache.commons:commons-collections4:4.4'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
testImplementation group: 'junit', name: 'junit', version: '4.12'
implementation 'org.jfrog.artifactory.client:artifactory-java-client-services:+'
implementation 'org.jfrog.artifactory.client:artifactory-java-client-api:+'
}
jar {
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}
Update on Nov 10th 2020:
I found that the artifactory sdk changed and I was using stale classes. I fixed those references in my classes to use newer SDK counterparts and the issues were gone.
I ended up using following gradle file to build everything I needed:
group 'artifactory-client-sdk'
version ''
apply plugin: 'java'
sourceCompatibility = 1.8
buildDir="${rootDir}/../out/artifactory_client_sdk"
def signbridge_lib="${rootDir}/../libs"
jar.baseName = 'artifactory-client-sdk'
repositories {
jcenter()
}
dependencies {
implementation 'ch.qos.logback:logback-classic:1.2.3'
testImplementation group: 'junit', name: 'junit', version: '4.12'
implementation 'org.jfrog.artifactory.client:artifactory-java-client-services:+'
implementation 'org.jfrog.artifactory.client:artifactory-java-client-api:+'
}
jar {
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA','**/org/jfrog/example'
}
task copyJar(type: Copy) {
from jar // copies output of file produced from jar task
into "${signbridge_lib}"
}
build.finalizedBy copyJar
Thanks a lot to Dror for great pointers!
The sources of the Artifactory Java client can be found in the jfrog/artifactory-client-java GitHub repository.
The services module used to be built as an uber jar containing 3rd party dependencies. On Oct 2019 the build has changed to create a thin jar instead of an uber jar.
To solve you issue you can either:
Include the 3rd party dependencies of the service module when building you application
Revert the change in build.gradle and continue to build an uber jar
Instead of building from source, you can consume the artifact from jcenter where is it being published by JFrog. The artifacts are published together with Maven .pom files which contains all the required 3rd party dependencies (all of them are available in jcenter).
In addition, there is an example Github project which shows how to consume the client library using Maven or Gradle.
I was trying to implement the new Firebase-Crashlytics SDK. After going through the document, I got the following error.
Could not find com.google.firebase:firebase-crashlytics-gradle:17.0.0-beta01.
I found the following.
Wrong : com.google.firebase:firebase-crashlytics-gradle:17.0.0-beta01.
Correct : 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta01'
To implement the new Firebase Crashlytics SDK you need to add firebase-crashlytics-gradle classpath and firebase-crashlytics dependency.
In your project-level build.gradle file, add the Crashlytics Gradle plugin:
buildscript {
repositories {
// Check that you have Google's Maven repository (if not, add it).
google()
}
dependencies {
// ...
// Check that you have the Google Services Gradle plugin v4.3.2 or later
// (if not, add it).
classpath 'com.google.gms:google-services:4.3.3'
// Add the Crashlytics Gradle plugin.
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta02'
}
}
allprojects {
repositories {
// Check that you have Google's Maven repository (if not, add it).
google()
}
}
In your app-level build.gradle file, apply the Crashlytics Gradle plugin:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services' // Google Services Gradle plugin
// Apply the Crashlytics Gradle plugin
apply plugin: 'com.google.firebase.crashlytics'
In your app-level build.gradle, add dependencies for Google Analytics and Crashlytics.
dependencies {
// Recommended: Add the Firebase SDK for Google Analytics.
implementation 'com.google.firebase:firebase-analytics:17.2.2'
// Add the Firebase SDK for Crashlytics.
implementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta01'
}
From here.
If you're migrating from Fabric, don't forget to update google-services.json (download it from your Firebase console). It could changed after migration. Migration is described here.
P.S. answer for future strugglers.
Updating these dependencies work for me
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.0'
}
A have the following error and searched a lot to solve it, but can't get hold of what versions to use and what to do.
The library com.google.firebase:firebase-iid is being requested by various other libraries at [[16.2.0,16.2.0]], but resolves to 15.1.0.
remove
implementation 'com.google.firebase:firebase-messaging:17.0.0'
from your app gradle
and if someone is facing error like
'com.android.support:appcompat-v7' has different version for the compile (26.1.0) and runtime (27.0.1) classpath
then
under your project level gradle file
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.1.0"
}
}
}
}
add above lines to bottom of Project level gradle file
I am using Java, Spring, and Gradle. I am new to gradle and am trying to understand some stuff. I currently have gradle successfully building a jar file.
I would like to add a task so that gradle runs the jar that it builds.
this way I could do
./gradlew clean build run
or I could just do it in one command if possible. The pseudocode of which would be
task run {
clean
build
java -jar myJar.jar
}
How would I go about doing this?
---INFO----
my current build.gradle file:
buildscript {
repositories {
maven { url "http://repo.spring.io/libs-snapshot" }
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:0.5.0.M6")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'gs-rest-service'
version = '0.1.0'
}
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-snapshot" }
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web:0.5.0.M6")
compile("com.fasterxml.jackson.core:jackson-databind")
testCompile("junit:junit:4.11")
}
task wrapper(type: Wrapper) {
gradleVersion = '1.10'
}
It's important to think in task dependencies. run wouldn't execute some other tasks sequentially (tasks can't do that); rather, it would declare task dependencies on its prerequisites, such as perhaps jar. Anyway, the easiest solution is to just apply the application plugin, which you can learn more about in the Gradle User Guide.