gradle cannot find flatDirs file - gradle

The external jar exists. However, gradle cannot get it even though the path is right. How should it be resolved?
project build.gradle
buildscript{
repositories {
mavenLocal()
mavenCentral()
flatDir {
dirs "../libs"
}
}
dependencies {
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.2"
}
}
module build.gradle
repositories {
mavenLocal()
mavenCentral()
flatDir {
dirs "../libs"
}
}
folder structure
X:/Dev/IntelliJProjects/libs //all flatDir libs go here
X:/Dev/IntelliJProjects/my-project/my-project--core
when i run gradlew clean publishtomavenlocal
Could not resolve all files for configuration ':my-project--core:compileClasspath'.
Could not find external-project:myDependency:1.0.0.
Searched in the following locations:
- file:/X:/Dev/IntelliJProjects/libs/myDependency-1.0.0.jar
but when I go to the folder, the file is there.

Related

How setup gradle to prefer repositories from init.gradle to build.gradle?

Pls, help understand how gradle work.
In linux server i have Java project and build them from gradle 4.10.3.
In Project i have build.gradle file with repositories section. Also in subproject i have this file too.
build.gradle example:
repositories {
maven { url 'http://1.2.3.4'}
}
subprojects {
buildscript {
repositories {
maven { url 'http://1.2.3.4'}
}
}
repositories {
maven { url 'http://8.2.3.4/'}
}
}
I`m try override repositories in init.gradle file (locate in folder $GRADLE_HOME/init.d/)
But this doesnt work. When build project, gradle use repositories from build.gradle project (and subproject) file.
Also i`m try run gradle with option -I and path to init.gradle file - same result.
gradle -I $GRADLE_HOME/init.d/init.gradle -Pprod clean build
Can i override repositories section in build.gradle (located in project and subproject) by use some file in local environment, or may be some $env or something else ?
UPD.
in init.gradle file i write this:
settingsEvaluated { settings ->
settings.pluginManagement {
resolutionStrategy {
}
repositories {
maven {url 'http://13.1.1.21:8084'
}
}
}
}
allprojects {
repositories {
mavenLocal()
maven {url "http://10.8.13.21:8080/repository/"
}
}
}

Plugin with id 'com.wonbin.myplugin' not found

I wrote a demo for learning gradle for android . i used the JAR
1) project root dir build.gradle
buildscript {
repositories {
jcenter()
flatDir {dirs 'build_libs'}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.wonbin.myplugin:MyPlugin:1.0'
}
}
apply plugin: 'com.wonbin.myplugin'
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have leanrd that the plugin id is the properties filename in the plugin project. But still when I run ./gradlew assemble , it happens:
Build file '/home/wonbin/MyApp/build.gradle' line: 13
What went wrong: A problem occurred evaluating root project 'MyApp'.
Plugin with id 'com.wonbin.myplugin' not found.
what should i do ?
Probably your build_dir doesn't correspond to the correct file structure. You can reference your jar in the classpath directly instead, like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath file('/path/to/your/plugin.jar')
}
}
apply plugin: 'com.wonbin.myplugin'

How can I use Gradle to just download JARs?

I have a non-standard project layout.
How can I use Gradle to just download a bunch of JAR dependencies into a lib directory, under the same directory where build.gradle is? For now, I don't need it to do anything else.
Here is what I have so far:
apply plugin: "java"
repositories {
mavenCentral()
}
buildDir = "."
libsDirName = "lib"
dependencies {
runtime group: "...", name: "...", version: "..."
}
If I run gradle build, it builds an empty JAR file in the lib directory, instead of downloading my dependencies there.
Switching "lib" with "." in the properties does not work either.
Something like the following should work:
apply plugin: 'base'
repositories {
mavenCentral()
}
configurations {
toCopy
}
dependencies {
toCopy 'com.google.guava:guava:18.0'
toCopy 'com.fasterxml.jackson.core:jackson-databind:2.4.3'
}
task download(type: Copy) {
from configurations.toCopy
into 'lib'
}

Gradle error: Could not find org.apache.httpcomponents:httpclient-android:4.3.5.1

I'm trying do use the Apache httpclient for Android in my Gradle project and I don't understand why I get this error when running ./gradle build:
Could not find org.apache.httpcomponents:httpclient-android:4.3.5.1.
My top-level build.gradle contains:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
My project build.gradle starts with:
apply plugin: 'com.android.application'
dependencies {
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':workspace:google_play_services:libproject:google-play-services_lib')
}
What's wrong with that?
In The Central Repository Browser of Maven the package I need is listed:
http://search.maven.org/#browse|-305040853
You have to add in your project build.gradle
repositories {
mavenCentral()
}
If you would like to put it in the top level file you can add this in the top level build.gradle:
allprojects {
repositories {
mavenCentral()
}
}

Gradle Multiple Maven Repo

I added a dependency to my build.gradle: spring-data-neo4j
It requires neo4j-cypher-dsl-2.0.1.jar/pom, which is only located in the repo: https://repo1.maven.org/maven2/.
However as per the output below gradle never looks at this repo for the artifact. How can I get gradle to search this repo as well.
//build.gradle
buildscript {
repositories {
mavenCentral()
maven {
url "https://repo1.maven.org/maven2/"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.9.RELEASE")
}
}
gradle build:
FAILURE: Build failed with an exception.
What went wrong: Could not resolve all dependencies for configuration ':compile'.
Could not find org.neo4j:neo4j-cypher-dsl:2.0.1. Searched in the following locations:
https://repo1.maven.org/maven2/org/neo4j/neo4j-cypher-dsl/2.0.1/neo4j-cypher-dsl-2.0.1.pom
https://repo1.maven.org/maven2/org/neo4j/neo4j-cypher-dsl/2.0.1/neo4j-cypher-dsl-2.0.1.jar Required by:
**:feedserver:1.0.0 > org.springframework.data:spring-data-neo4j:3.2.2.RELEASE**
* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Edit:---------------------------------------
Sorry I accidently posted the incorrect build.gradle contents above, which has repeated maven central locations. This is my actual build.gradle file...When I build using these settings I still get the error above:
buildscript {
repositories {
mavenCentral()
maven {
url "http://m2.neo4j.org/content/repositories/releases/"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.9.RELEASE")
}
}
neo4j-cypher-dsl is not in Maven central. It is available in Neo4j repository you have to add another repo something like this:
repositories {
maven {
url "http://m2.neo4j.org/content/repositories/releases/"
}
}
NOTE is not necessary to use another maven ponting to maven central using mavenCentral() is enough
EDIT 1
repositories section in buildscript just works for dependencies inside. In this case for spring-boot-gradle-plugin
buildscript {
ext {
springBootVersion = '1.1.9.RELEASE'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
In your case you want to add another dependencies for your project. So you need to add another repositories section out of buildscript
repositories {
mavenLocal()
mavenCentral()
maven {
url "http://m2.neo4j.org/content/repositories/releases/"
}
}

Resources