I created a custom plugin 'myPlugin' for GRAILS. I compiled and installed it as a binary (my-plugin-0.1.jar) file.
The jar file can't be found by grails in a "normal" project, because it only looks for my-plugin-0.1.zip (the plugin is defined within the plugins-block in BuildConfig.groovy)
How can i add the .jar file as a plugin?
Binary plugins packaged as jar has to be referred in the dependencies section instead of the plugins section in BuildConfig
dependencies {
compile "mygroup:myplugin:0.1"
}
or you can put the jar in application's lib directory which I would discourage. :)
Add it in the dependencies block (not plugins) in BuildConfig.groovy.
Publish plugin installs the jar into local maven cache (/.m2). Verify the existence of the jar in .m2.
Also verify if the application using the plugin has mavenLocal enabled in repositories' buildConfig.
Related
If I add a JAR file to a gradle project's depenencies, the code compiles just fine, but after publishing to maven (publishToMavenLocal), the classes from the JAR are not found.
Obviously, this is because the jar is added as a "dependency" and not part of the project itself. Is there a way to get the contents of the JAR file to merge into the library? Do I need to make a separate maven repo for each JAR?
You can always try to create a fat jar which includes dependencies. You can follow the instructions provided here https://www.baeldung.com/gradle-fat-jar
I have a project build on gradle and it has a directory src/main/dist/deploy. In deploy folder there is a xml file. This xml file i want to add as a dependency in the jar file which my build.gradle is generating. This jar i am adding in the lib folder of another project that has a dependency on my gradle project. The other project is built using ant. When classes bundled in gradle jar are loaded from ant project they are unable to read that xml file from the gradle jar.
The standard java plugin does not look in src/main/dist/deploy for resources.
You should either move the xml file into java plugin's standard resource folder src/main/resources, or add the dist/deploy folder to your main sourceSet's resource list.
I am a gradle newbie. I see that gradle supports maven and ivy out of the box, however I have a need where the dependency for a java project is to be downloaded from a url. The dependencies are actually jar files which are zipped, I also need it to be extracted.
I have the following usecase. I have added a jar file(generated out of maven) as an external jar in the bundle path of a plugin (say Plugin A).
I have exposed all the packages inside this jar in Plugin A.
Now Plugin A is added as a dependency to Plugin B.
But in Plugin B, I am not able to access the classes inside the jar file which is added as an external jar to Plugin A and whose packages are exposed
Is it advisable to the same jar in every plugin ? Please pour in your suggestions.
I resolved this issue . In eclipse there is an option to generate a plugin from JAR file.So I have created a plugin from the jar file and added it as dependency to other plugin(after exposing the packages in the generated plugin).
I was having a dynamic webapplication created on eclipse. I converted it to a maven project using M2E plugin. I added maven war plugin in the pom.xml so that it can create war for my project using maven build.
But when I do the build, it fails to compile few classes which has reference to the jars of my webapp/Web-INF/lib folder. These jars I can't include as dependency in pom.xml.
How can I tell maven to include Web-INF/lib jars also while building classes and creating a war?
Its not correct way of doing this , you should not put any jar manually in WEB-INF/lib folder.
And if that jar is not available in MAVEN CENTRAL REPO , then you can download it and install it in your NEXUS CENTRAL REPO (if you have any) otherwise put that jar in your local maven repository and add it as a dependency in your pom file. If you don't want to include that jar in your WEB-INF/lib then change the scope to provided otherwise leave it as default i.e compile.
During build time MAVEN will look for that particular jar in your local repo first , and if it don't find it there then it try to download from Centra Repo.
Once it is available in your local repo , your build won't break.