Can I use a Maven plugin (enunciate) in Gradle? - maven

I have a maven plugin called enunciate that generates nice API documentation. I'd rather use Gradle as my build tool but it looks like it's limited in this aspect or maybe I just don't know how to use it.
I'm wondering if it's possible to use a maven plugin (enunciate) in gradle somehow? Do I have to write an ant script and call that? So far I can't find a gradle example for enunciate so I'm guessing it's not supported?

You can't use a Maven plugin as-is in Gradle; you'll have to port it to a Gradle plugin. How difficult this is depends on how many Maven APIs the plugin is using. Another strategy might be to call into Maven via Gradle's Exec task.

As of October 2015, a Gradle plugin for Enunciate is available.
https://github.com/stoicflame/enunciate-gradle

Related

Should I shadow Kotlin when writing a Gradle Plugin

I'm writing a plugin to extract some boilerplate from a selection of existing Gradle build scripts. The existing build scripts are primarily written in Groovy and compiling Java.
To build my plugin I'm using the Gradle Kotlin DSL and figured I'd take the opportunity to write the plugin in Kotlin too. This all works but now my plugin has a huge dependency on Kotlin - and the Gradle docs specifically recommend minimizing external libraries.
Java and Groovy plugins avoid this because Java & Groovy are a shared dependency with Gradle, but Kotlin isn't a shared pre-requirement and so we then have to be concerned about potentially conflicting Kotlin versions needed by different plugins.
I figure I should move forward with one of the following approaches but am not clear which:
Just list Kotlin's stdlib as a standard dependency and trust Gradle to sort things out.
This works for one plugin, but should I expect problems when another plugin is also being used but depending on a different Kotlin?
Build some sort of uber shadowJar shadowing Kotlin libraries for my plugin
Implying that every plugin I write like this will be 10s of MB bigger than necessary.
Give up on Kotlin based plugins and rewrite in Java/Groovy
Would be a shame to give up on the new goodness but might be better to avoid the above sins.
Recommendations welcome!
Since your plugin is replacing boilerplate and is presumably not destined for public release, would it make sense to write it as a script plugin in the Gradle Kotlin DSL? That way a new enough Gradle should be able to understand it natively.
Raised this in Gradle Community Slack and was recommended to use Gradle's kotlin-dsl plugin to automatically configure dependencies on gradleApi() and embeddedKotlin() versions, and therefore whatever Kotlin version is bundled with Gradle's Kotlin DSL support.
I was concerned that this might introduce a dependency on the calling script using Kotlin DSL, but I've tested with a Groovy script and have been able to use my plugin. I assume that it does still depend on a version of Gradle with Kotlin DSL support though - i.e. 4.0+.

What is the difference between gradle repository and a maven repository?

I’m trying to create a custom Artifactory repository to resolve dependencies in my gradle project, but I’m confused between gradle and maven repo: what repository key should I choose? And what is the real difference between a gradle repository and a maven repository?
There is no such thing as a Gradle repository.
While Maven is the name for both a build tool and a repository type, Gradle ist just a build tool. It supports both Maven and Ivy repositories.
Gradle is a Java development tool, but not the only one. An alternative is Maven, which is older and commonly used. Spring Framework let developers to choose between these two tools.
Gradle is an open source build automation system that's built on Apache Maven and Apache Ant concepts. It uses a domain-specific language based on the programming language Groovy. This is a very interesting difference between Gradle and older Apache Maven, which uses XML. Gradle was developed in 2007 and in 2013 it was adopted by Google for Android system (this must say a lot about how powerful is Gradle).
Maven Repository is a directory where all the project jars, library jar and plugins can be used by Maven/Gradle easily. Maven Repository are of three types: local, central or remote. Gradle can and use the Maven Repositories, as I've said before, Gradle is build on top of Maven concepts.
You can think of Gradle as goodness of Ant and Maven put together minus the noise of XML. And scriptability with groovy is very big plus.
Gradle gives you conventions but still gives you power to override them easily.
Gradle build files are less verbose as they are written in groovy.
It provides very nice DSL for writing build tasks.
Has lot of good plugins and vibrant ecosystem
When to use Gradle and When to use Maven ?
Almost everywhere for creating java/groovy project. The build files are much terse.
With Google choosing Gradle as the new build system for Android SDK and mature libraries like Spring, Hibernate, Grails, Groovy etc. already using it to power their builds, there is no doubt that Gradle is becoming de-facto build system for the Java ecosystem.

Gradle equivalent for Maven Java formatter that uses com.googlecode.maven-java-formatter-plugin

I'm switching a large project from Maven to Gradle. Existing Maven project uses com.googlecode.maven-java-formatter-plugin to format the Java code. Looked for the equivalent in Gradle. Found https://plugins.gradle.org/plugin/com.github.sherter.google-java-format, but it spewed a bunch of errors out, was really slow, and didn't generate the same output as the Maven plugin.
Also looked here: https://github.com/google/google-java-format - no help.
Is there a Gradle plugin which will give me same result as the Maven plugin?
There is this other Gradle plugin, which uses the Eclipse formatter. Maybe you can tweak it to achieve the same results as with the maven plugin you mentioned (I'm not using this plugin myself).
Note that it is an explicit non-goal of google-java-format and the corresponding Gradle plugin to be configurable. If you are not happy with the formatting style then this tool is probably not appropriate for you.
(if you have technical problems with my Gradle plugin, feel free to provide more details or open a ticket on Github)

Using custom maven plugin in gradle project

I developed custom maven plugin using java 5 annotations and I want to use that plugin in gradle project but I am not getting any useful stuff on internet even after lots of googling could you please let me know how to use custom maven plugin in project build with gradle?
Thanks and Regards,
Mahendra Tonape.

How Can I Write An Integration Test For A Gradle Plugin

I'm writing a plugin for Gradle. It's a port of a Maven plugin, which I testing using the Maven integration testing plugin. I'd like to create a series of tests for different build.gradle files.
Is there a good way to do this is Gradle (as what I have does not seem to work).
Yes, the easiest way to make a simple test is use the org.gradle.testfixtures.ProjectBuilder class.
Project project = ProjectBuilder.builder().build()
project.apply plugin: 'dependencyAnalysis'
project.apply plugin: 'java'
assertTrue(project.tasks.analyze instanceof AnalyzeTask)
This can however only test up to and including the configuration phase. So for a test of the execution phase this will not work.
You can also use the tooling API like Opal suggested, but I would suggest that you use it through the nebula test plugin. https://github.com/nebula-plugins/nebula-test
The Gradle TestKit has recently been added to the Gradle distribution to help with integration testing. At the time of writing it has some missing features but I have used it and it is very useful. I have not used nebula-test so cannot compare them.

Resources