2

I have a standalone custom code packed as a zip file(custom-1.0.zip) using maven-shade-plugin –uploaded to my company's artifactory

<dependency>
    <groupId>com/mypackage/domain</groupId>
    <artifactId>custom</artifactId>
    <version>1.0</version>
    <type>zip</type>
</dependency>

I want to use this zip file in my Grails 2.3.5 project which is configured to use maven for resolving dependencies. I believe I need to do following:

  1. Download the zip file from artifactory to local maven repository
  2. Copy the zip file from local maven repository to web-app/resources folder of my project

I added following to Build.groovy to download the zip file:

grails.project.dependency.resolver = "maven"

dependencies {
     compile ("com.mypackage.domain:custom:1.0")
}

… ..

plugins {
     compile ("com.mypackage.domain:custom:1.0")

}

Above code downloads the jar, pom and zip file to my local maven repository and then fails

Loading Grails 2.3.5
|Configuring classpath
|Downloading: com.mypackage.domain/custom/1.0/custom-1.0.pom
|Downloading: com.mypackage.domain/custom/1.0/custom-1.0.zip
|Downloading: com.mypackage.domain/custom/1.0/custom-1.0.jar
.
|Environment set to development
.................................
|Packaging Grails application
Error |
Zip C:\Users\userid\.m2\repository\com\mypackage\domain\custom\1.0\custom-
1.0.zip is not a valid plugin

Does anyone has a working example for downloading zip using Grails 2.3.5 and copying to desired folder?

Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156

1 Answers1

0

You do not need the following unless the custom artifact is built as a plugin. You can remove

plugins {
     compile ("com.mypackage.domain:custom:1.0")
}

and edit the dependencies to include the type:

dependencies {
     compile ("com.mypackage.domain:custom:1.0:zip")
}

then compile your project.

Naman
  • 27,789
  • 26
  • 218
  • 353
  • Thanks for your help. Removing plugin is fine but adding colon - ':' before path does not fix this. – Rohit Kumar Aug 22 '17 at 17:58
  • @RohitKumar Grails 2.x version onwards, you should have ":" in front of the dependency. – Naman Aug 22 '17 at 18:01
  • Adding ":" fails the process- |Loading Grails 2.3.5 Error | There was an error loading the BuildConfig: Bad artifact coordinates :com.mypackage.domain:custom:1.0, expected format is : [:[:]]: (Use --stacktrace to see the full trace – Rohit Kumar Aug 22 '17 at 19:42
  • @RohitKumar ya seems like https://stackoverflow.com/a/28065980/1746118 answers why. Edited tthe answer. – Naman Aug 23 '17 at 04:21
  • No above post does not answer my question. It says add dependency to plugin. That's where I posted this question. I need an working example where a zip file is downloaded to specified folder in Grails-2.3.5 – Rohit Kumar Aug 23 '17 at 18:03
  • @RohitKumar Did you try the edited answer? All you need to do is get rid of the plugin section in your code and make sure the dependency details other than that are correct. – Naman Aug 23 '17 at 18:09