Home > Mobile >  gradle not finding dependencies in the build folder
gradle not finding dependencies in the build folder

Time:06-30

I am trying to build a gradle project.

here is my project structure :

|── build
|     |──src-gen
|
├── buildSrc
│      ├─gradle.build (2) 
| 
├── modules
│   ├── tobris-open-suite
│         ├── tobris-accounting
│         |     └── gralde.build
├         ├──tobris-admin
|               └── gralde.build
|
├── tobris-erp
      └── gralde.build (1)

here is my tobris-erp gradle.build (1)

import com.tobris.gradle.tasks.GenerateAosChangelog
import com.tobris.gradle.tasks.CheckEOLCharsInCsv

buildscript {
  ext.repos = {
   flatDir {
       dirs 'libs'
   }
    mavenCentral() {
      content {
        excludeGroup 'com.tobris'
      }
    }
    maven {
      url 'https://plugins.gradle.org/m2/'
      content {
        excludeGroup 'com.tobris'
      }
    }
    maven { url 'https://repository.tobris.com/nexus/public/' }
  }
  ext.openPlatformVersion = '5.4.13'
  ext.appVersion = '6.2.2'
  repositories repos
  dependencies {
    classpath "com.google.guava:guava:28.1-jre"
    classpath "com.opencsv:opencsv:3.9"
    classpath "gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.14.0"
    classpath "org.yaml:snakeyaml:1.25"
    
    
    classpath "org.hibernate:hibernate-core:5.6.5.Final"
    classpath  "org.hibernate:hibernate-hikaricp:5.6.5.Final"
    classpath  "org.hibernate:hibernate-validator:5.4.1.Final"
    classpath  "org.hibernate:hibernate-jcache:5.6.5.Final"    
    classpath 'javax.persistence:javax.persistence-api:2.2'
    classpath 'javax.persistence:javax.persistence-api:2.2'

    classpath "com.tobris:tobris-common:${openPlatformVersion}"
    classpath "com.tobris:tobris-core:${openPlatformVersion}"
    classpath "com.tobris:tobris-gradle:${openPlatformVersion}"
    classpath "com.tobris:tobris-test:${openPlatformVersion}"
    classpath "com.tobris:tobris-tomcat:${openPlatformVersion}"
    classpath "com.tobris:tobris-web:${openPlatformVersion}"
  }
}

allprojects { repositories repos }

apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: "com.tobris.app"

apply from: './gradle/style.gradle'

allprojects {

  configurations {
    runtimeClasspath.exclude group: "org.eclipse.birt.runtime.3_7_1", module: "org.apache.commons.codec"
  }

  apply plugin: 'idea'
  apply plugin: 'eclipse'

  group = "com.tobris"
  version = "${appVersion}"

  sourceCompatibility = 1.8
  targetCompatibility = 1.8

}

subprojects {
  group = "com.tobris.apps"
}

tobris {
  title "Tobris ERP"
  description "Tobris Entreprise Application"
}

dependencies {
  gradle.appModules.each { dir ->
    implementation project(":modules:$dir.name")
  }
}

task("dataImport", type: JavaExec) {
  main = "com.tobris.apps.erp.Main"
  classpath = sourceSets.main.runtimeClasspath
  if (System.getProperty("exec.args") != null) {
    args System.getProperty("exec.args").split()
  }
}

task archiveReports(type: Zip) {
  file("modules").traverse(type: groovy.io.FileType.DIRECTORIES, maxDepth: 1) { dir ->
    if (new File(dir, "build.gradle").exists() && new File(dir, "/src/main/resources/reports").exists()) {
      new File(dir, "/src/main/resources/reports/").listFiles().each { report ->
        from report.getPath()
      }
    }
  }

  classifier 'reports'
  includeEmptyDirs = false
  destinationDirectory = file("$buildDir/libs")
}


task generateChangeLog(type: GenerateAosChangelog) {
  group "Tobris application"
  description "Generate change logs from unreleased entries."
  files = fileTree(projectDir) {
    include '**/changelogs/**/*.yml'
    include '**/changelogs/**/*.yaml'
  }
}

task checkCsvEOL(type: CheckEOLCharsInCsv) {
  group "Tobris application"
  description "Generate change logs from unreleased entries."
  files = fileTree(projectDir) {
    exclude '**/build'
    exclude '**/bin'
    exclude '**/out'
    include '**/*.csv'
  }
}

build.finalizedBy archiveReports

and here is my buildSrc gradle.build (2) :

def repos = {
    jcenter()
    mavenCentral()
    mavenLocal()

    maven { url 'https://plugins.gradle.org/m2/' }
    maven { url 'https://repository.tobris.com/nexus/repository/maven-public/' }
}

ext.repos = repos

repositories repos
buildscript.repositories repos
dependencies {
    implementation 'org.yaml:snakeyaml:1.25'
    
    implementation "org.hibernate:hibernate-core:5.6.5.Final"
    implementation  "org.hibernate:hibernate-hikaricp:5.6.5.Final"
    implementation  "org.hibernate:hibernate-validator:5.4.1.Final"
    implementation  "org.hibernate:hibernate-jcache:5.6.5.Final"    
    implementation 'javax.persistence:javax.persistence-api:2.2'
}

I am generating database entities from XML files using hibernate. the generated classes are under the src-gen folder under the build.

the issue is when I build the project the classes under src-gen show this error /tobris-erp/build/src-gen/java/com/tobris/dms/db/DMSFile.java:9: error: package javax.persistence does not exist while the I put all the dependencies in all the gradle.build and eclipse is not showing error. I am sure that the jars are in the classpath.

Where should I put the dependencies ? any clue?

CodePudding user response:

I deleted this section from the gradle.build (1) :

dependencies {
  gradle.appModules.each { dir ->
    implementation project(":modules:$dir.name")
  }
}
  • Related