0

I have two projects in the same SVN namely LOG and MAIN.

MAIN uses methods from LOG so I want to add LOG as a dependency.

Previously I copied LOG to my local directory and used below gradle setting to compile LOG.

settings:

include "LOG"
project(":LOG").projectDir = file("../LOG")

Since both are different projects we want to build LOG directly from SVN.

I used below build.gradle but it showed below error.

build.gradle:

repositories {

    ivy {
        url 'http://13.126.60.33/datastudio/DataStudio_Java/DataStudio_Java_Logger/Branch/Development/DataStudio_Java_Logger'
        credentials {
            username 'mob140003207'
            password 'VIGkalai1'
        }
    }
}

dependencies {

    compile project("DataStudio_Java_Logger")
}

Error:

Caused by: org.gradle.internal.component.model.ConfigurationNotFoundException: Project : declares a dependency from configuration 'compile' to configuration 'default' which is not declared in the descriptor for project :DataStudio_Java_Logger.

Is there any way to do this or what am I doing wrong.

The6thSense
  • 8,103
  • 8
  • 31
  • 65

1 Answers1

1

The normal approach is for the CI server (eg jenkins/travis) to build the LOG project every time it changes and upload the LOG.jar to a repository (eg nexus/artifactory). The MAIN project would then configure the repository (nexus/artifactory) and download the jar file from there. So MAIN project would have no knowledge of the LOG sources in SVN at all.

If you really want to get the sources from SVN in the MAIN project (not recommended!!!) and compile them there you'll need to create a svnDownload task in the LOG subproject (of the MAIN project). The javaCompile task (LOG subproject) would depend on the svnDownload task.

lance-java
  • 25,497
  • 4
  • 59
  • 101
  • Since both of them are in the same SVN is there no way to compile them rather then using the second step you siad – The6thSense Sep 13 '17 at 09:20
  • I saw a SO answer somewhat closer to this [question](https://stackoverflow.com/questions/10856113/how-to-deal-with-gradle-and-multi-project-configuration). I am trying to use the third methos. – The6thSense Sep 13 '17 at 09:22
  • ok... so put LOG and MAIN in the same SVN repo then as siblings under a root – lance-java Sep 13 '17 at 09:25
  • So what you are saying is Try to create a project ROOT and add MAIN and LOG there?. – The6thSense Sep 13 '17 at 09:27
  • 1
    If MAIN and LOG are always built together and released together then yes, I suggest creating a single repository in SVN for both. I'd suggest more meaningful names. Eg `myapp` (root), `myapp-main` and `myapp-log`. So you'd have `myapp/myapp-main` and `myapp/myapp-log` – lance-java Sep 13 '17 at 09:30
  • If I do like that how should my gradle.settings look ? – The6thSense Sep 13 '17 at 09:32
  • `myapp/settings.gradle` would simply be `include ':myapp-main', ':myapp-log'` – lance-java Sep 13 '17 at 09:33
  • Oh okay Thanks a lot lance!!!. I feel that your artifact method is the correct way to go forth – The6thSense Sep 13 '17 at 09:34
  • 1
    If LOG is used by other projects then yes, a separate SVN repo is recommended (and nexus/artifactory). If you wanted to build LOG and MAIN together (eg for development purposes) you would then use a [Composite build](https://docs.gradle.org/current/userguide/composite_builds.html) – lance-java Sep 13 '17 at 09:36