2

(Note that I am a novice at Eclipse / Gradle, so please bear with me.)

I am trying to modify the following project because there is a customization I would like to make: https://github.com/Swagger2Markup/swagger2markup

In turn, I would like to the use the modified binary in the following project: https://github.com/Swagger2Markup/swagger2markup-gradle-project-template

Overall I believe I need to do the following steps:

  1. Download the source for that project and compile it to a local .jar file
  2. Modify the "template project" build.gradle to reference the local .jar

I think I got step #1 to work by importing the Gradle project into Eclipse, going to Gradle Tasks, right clicking "jar" and running the task. A .jar is generated.

After that, I download the template project and copy the generated .jar into the libs folder of the template project. Then I modify build.gradle:

I comment out the following line under buildscript > dependencies

//classpath "io.github.swagger2markup:swagger2markup:1.0.1"

Then I added the following to the top of the file per this post:

apply plugin: 'java'

dependencies {
    runtime files('libs/swagger2markup-1.3.1-SNAPSHOT.jar')
}

(I also tried using compile instead of runtime, as well as fileTree.)

No matter what I do, the template project seems to download the remote (unmodified) binary.

How do I force the project to use the local file?

Community
  • 1
  • 1
user7606813
  • 23
  • 1
  • 3
  • How do your other dependencies looks like? Maybe it's being downloaded as a transitive dependency. Try running `gradle dependencies` and see if you can trace where does it come from. – MartinTeeVarga Feb 22 '17 at 21:25

1 Answers1

1

The problem is that the dependency is also declared in the plugin as you can see here:

https://github.com/Swagger2Markup/swagger2markup-gradle-plugin/blob/master/build.gradle

That means that the Dependency manager sees that and downloads it. First, you have to exclude it:

classpath 'io.github.swagger2markup:swagger2markup-gradle-plugin:1.2.0', {
  exclude group: 'io.github.swagger2markup', module: 'swagger2markup-gradle-plugin'
}

And the same for io.github.swagger2markup:swagger2markup-import-files-ext. Then you put your library on the classpath. So

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local/' }
        //mavenLocal()
    }
    dependencies {
        classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.3'
        classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.10.1'
        classpath 'io.github.swagger2markup:swagger2markup-gradle-plugin:1.2.0', {
          exclude group: 'io.github.swagger2markup', module: 'swagger2markup-gradle-plugin'
        }
        classpath files('libs/swagger2markup-1.3.1-SNAPSHOT.jar')   // YOUR VERSION
        classpath "io.github.swagger2markup:swagger2markup-import-files-ext:1.2.0", {
          exclude group: 'io.github.swagger2markup', module: 'swagger2markup-gradle-plugin'
        }
        classpath "com.bluepapa32:gradle-watch-plugin:0.1.5"
        classpath "org.kordamp.gradle:livereload-gradle-plugin:0.2.1"
    }
}

EDIT: And you have to use the dependency as a buildscript dependency, that means it must be declared inside buildscript { dependencies { ... } } not just in dependencies { ... }

Martin Linha
  • 979
  • 9
  • 21