we have
desktopRuntime 'org.xerial:sqlite-jdbc:3.15.1'
in gradle file.
i build project but my zip file dont have this file in lib folder.
how can i build project for desktop?
my ide is netbeans.
Thankful.
The problem with the distZip or jar gradle tasks is they miss to include desktop dependencies.
When deploying to desktop you can change temporary desktopRuntime to runtime, so they will be included, as Ladislav Török suggests, but then you should undo the change so that dependency isn't included in the mobile deployment.
If you want to have a working zip, we have to modify the distZip task, to include the desktop dependencies in the lib folder, and also to include them in the class path (so they are also added to the scripts in the bin folder). Include this in your build.gradle script:
startScripts {
classpath += configurations.desktopRuntime
}
distZip {
into("$project.name/lib") {
from configurations.desktopRuntime
}
}
You can also solve the issue by using the shadowJar, providing you include the desktop dependencies, to create an executable fat jar, like in this solution.
Try next steps:
1.
dependencies {
compile 'org.xerial:sqlite-jdbc:3.15.1'
runtime 'org.xerial:sqlite-jdbc:3.15.1'
}
Go to "Files" tab in NetBeans IDE -> your_project -> build -> libs and here add your lib some as sqlite-jdbc.jar
Related
I new to Gradle. I'm trying to have all dependencies from my project copied to folder build/lib. Is it possible to do that?
Currently, I have a .zip and a .tar in build/distributions via the distribution plugin. However, I would like to have just the uncompressed libs.
I've seem a possible solution here, however I would like to have this as part of the main build and not as a separated task.
Just add the task as a dependency to build. That way it will be "part of the main build".
task copyDependencies(type: Copy) {
from configurations.runtimeClasspath // And/or:
from configurations.compileClasspath
into "$buildDir/lib"
}
build.dependsOn copyDependencies
You can, of cause, also hook it up to any other task that you use to build or deploy the application.
Just in case you are not aware of it, you can also use the installDist task from the distribution plugin (in combination with the application plugin) to create an exploded version in $buildDir/install.
The simple question;
Is there a way to make Intellij respect gradle configuration?
The details;
I created a new sourceSets called integrationTest
sourceSets {
integrationTest{
java.srcDir 'src/integration/java'
resources.srcDir 'src/integration/resources'
}
}
I added the new source set to Intellij testSourceDirs
idea {
module {
testSourceDirs += file('src/integration/java')
}
}
Everything works fine from Gradle perspective locally and on CI.
Now I don't want Intellij to create out directory which duplicates build dir I want Intellij to respect and follow gradle configuration as follows:
Source directory main/java should be compiled to classes/java/main
Source directory test/java should be compiled to classes/java/test
Source directory integrationTest/java should be compiled to classes/java/integrationTest
Resource directory main/resources should be compiled to resources/main
Resource directory test/resources should be compiled to resources/test
Resource directory integrationTest/resources should be compiled to `resources/integrationTest
The only solution I found so for (here) is to have
All source directories (in my case I have only one at main/java) and resource directories goes to classes/java/main.
All test directories (in my case I have two at test/java and integrationTest/java) and resource direcotries (in my case I have two at test/resources and integrationTest/resources) goes to classes/java/test; and this is so wrong I need now to pay attention to file names and location not to override each other.
Gradle Version: 4.5
Intellij Version: 2017.3
Update Jan 2021 This is not relevant anymore. It is working fine with newer Intellij. I personally tested with latest version 2020.3.2 Community edition.
I'm trying to install the Android SDK from Kontakt into a project in Android studio. I'm following the (seemingly basic) instructions on the Kontakt site here:
http://docs.kontakt.io/android-sdk/quickstart/#installing-the-sdk---android-studio
In brief, these steps say add maven { url 'http://repo.kontakt.io/repository/internal/' } in the repositories in your top-level build file, and add to add compile 'com.kontakt.sdk.android:library:1.0.5' in the dependencies in the main module build file.
However, when I try to sync my project with the updated files, it fails with an error message:
Error:Failed to find: com.kontakt.sdk.android:library:1.0.5
I tried with a totally fresh project and the same issue.
I'm guess this all has something to do with the fact that the instructions are written for Android's 0.12 version of the Gradle tools, but I'm using v1.1.0. I'm not across the detail of Gradle, so so any help would be appreciated.
My guess is that path to Kontakt.io public repository should be added to allprojects section instead of buildscript.
allprojects {
repositories {
jcenter()
maven { url 'http://repo.kontakt.io/repository/internal/' }
}
}
I am not 100% sure so don't shoot me:P
I think adding this line:
-->compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.kontakt.sdk.android:library:1.0.6'
Directly above the gradle project I wanted to compile fixed it.
Go to the Kontakt.io Android Proximity SDK https://github.com/kontaktio/kontakt-android-sdk on GitHub.
Click the Download ZIP button
Un-zip the file to a temporary location.
Add the jar file in your Android Studio Project.
File -> New Module -> Import .JAR/ .AAR Package -> Click Next -> Browse the SDK path (2.1.1) -> Finish (Take time to add in the project)
Then, Add module in dependencies
Right Click on Project Name -> Open Module Settings -> Under the list (Modules) -> Click on Dependencies -> Click on '+' -> Module Dependency -> Add Kontakt.io-android-sdk
Now Build your project It worked for me to kontakt io SDK. If anybody find the way to do this as Gradle build, please let me know.
Now,google use android studio,i can add dependencies at build.gradle as follows:
dependencies {
compile 'mobi.parchment:parchment:1.6.9#aar'
}
but sometime i want to see the source code "mobi.parchment:parchment#aar",maybe i want to modify it or use to eclipse but not use the gradle plugin
If AndroidStudio didn't download the source code, you can force the download of source (and javadoc) of your AAR dependency by adding these lines in the build.gradle file :
dependencies {
compile 'mobi.parchment:parchment:1.6.9#aar'
compile 'mobi.parchment:parchment:1.6.9:sources#jar'
compile 'mobi.parchment:parchment:1.6.9:javadoc#jar'
}
Then on AndroidStudio in the Projet tab, expand the external Librarie and right clic on your lib (parchment1.6.9), click "Library Properties ..." and the "+" button. the source's jar file is in the gradle cache under ${user_Home}/.gradle/modules-2/files-2.1 directory; you can select it.
(Once is done you don't need anymore to declare the source dependencies; so your build.gradle can contain only :
dependencies {
compile 'mobi.parchment:parchment:1.6.9'
}
I know it's an ugly process, but it's the only workaround I found until now.
I am migrating a legacy application from Ant to Gradle. The requirement is to build a zip file with a certain folder structure which is used by the deployment team. I am able to create the zip file in the correct format, so-far-so-good.
I am able to open the project in Eclipse, but cannot run it. In Eclipse (and IntelliJ) I need src/main/conf to be added to Eclipse's classpath, but not be included in the JAR (e.g. if I were to run gradle jar).
This is how the project is currently structured:
src
/main
/java
/com
/example
/App.java
/resources
/applicationConfiguration.xml
/conf
/dev.properties
/staging.properties
/prod.properties
How can I add the conf folder to Eclipse's classpath so that it is not included in the JAR that Gradle creates?
Given the limitations of Gradle's EclipseClasspath API, the most straightforward solution I can think of is to declare src/main/conf as another source directory:
sourceSets.main.java.srcDir "src/main/conf"
As long as the directory doesn't contain any Java files, this won't affect the outcome of the Gradle build. However, the directory will show up as a source directory in Eclipse, and its properties files will therefore be copied into the Eclipse output directory.
Another tip. If you need it to run in Eclipse WTP, then I set the sourceDirs property of eclipse.wtp.component:
eclipse {
project {
natures 'org.eclipse.wst.common.project.facet.core.nature',
'org.eclipse.wst.common.modulecore.ModuleCoreNature',
'org.eclipse.wst.jsdt.core.jsNature'
name 'blah-blah'
}
wtp {
facet {
facet type: 'fixed', name: 'wst.jsdt.web'
facet name: 'java', version: '1.7'
facet name: 'jst.web', version: '3.0'
facet name: 'wst.jsdt.web', version: '1.0'
}
component {
sourceDirs = new HashSet([
new File(project.getProjectDir().getAbsolutePath() + "/src/main/java"),
new File(project.getProjectDir().getAbsolutePath() + "/src/main/resources"),
new File(project.getProjectDir().getAbsolutePath() + "/src/main/conf")
])
}
}