0

I am migrating a project from Maven to Gradle and everything seems to be going well. I am however, getting caught up on a particular dependency.

In maven pom.xml the dependency was included as such:

<dependency>
  <groupId>com.company</groupId>
  <artifactId>models</artifactId>
  <version>1.0.0</version>
  <scope>system</scope>
  <systemPath>${project.basedir}/src/main/libs/models-templates-1.0.0.jar</systemPath>
</dependency>

I have been looking into how to achieve something like this in gradle and haven't found a clear answer.

I thought I would need to first download the entire directory and extract the dependency so I started looking at this solution: How to add local .jar file dependency to build.gradle file?

However, after looking into what is happening a little more I've found that I actually need to declare an alternative jar name to download. So I still need it to look in the correct "models" group name but I need to download the "models-tempaltes" jar instead.

thank you.

Community
  • 1
  • 1
Brodie
  • 8,399
  • 8
  • 35
  • 55
  • Possible duplicate of [How to add local .jar file dependency to build.gradle file?](http://stackoverflow.com/questions/20700053/how-to-add-local-jar-file-dependency-to-build-gradle-file) – Michael Easter Aug 19 '16 at 02:59
  • So I started off with that question. I think i might be on track. The difference is that I need i need to extract a specific jar from a dependency and include it in the classpath before the project is compiled. – Brodie Aug 19 '16 at 03:01
  • I took a look at my setup a little more to make sure I couldn't solve it with the solution provided in the question you mentioned @MichaelEaster, I think it is different, if not please feel free to correct me and i'll close this. I've edited the question to reflect the situation more clearly. – Brodie Aug 19 '16 at 03:17
  • If however I was downloading an entire directory and then needing to copy a file over I was able to find my way to a solution starting with the answer provided there. – Brodie Aug 19 '16 at 03:20

1 Answers1

1

I was able to find a solution to this.

The alternative to the pom.xml pattern of:

<dependency>
  <groupId>com.company</groupId>
  <artifactId>models</artifactId>
  <version>1.0.0</version>
  <scope>system</scope>
  <systemPath>${project.basedir}/src/main/libs/models-templates-1.0.0.jar</systemPath>
</dependency>

would be

compile (group = 'com.company', name = 'models', version = '1.0.0') {
  artifact {
    name = 'models-data-template'
    type = 'jar'
    extension = 'jar'
  }
}

Important to note that this needed both the type and extension properties to work, I tried w/ just the alternative name and that caused a bunch of errors.

Hope this helps someone.

Brodie
  • 8,399
  • 8
  • 35
  • 55