How to get the Java Runtime environment for Maven Plugin - java

I am trying to write a Maven Plugin. This plugin needs to run a separate java process for a separate jar. How to obtain the maven java runtime?
Thanks.

Related

Java Cucumber - Trivago Cluecumber not creating report via runnable jar

I have a Java Cucumber project which I have to run via an executable jar (java -jar) instead of maven (mvn).
I am trying to add the Trivago Cluecumber report plugin (https://github.com/trivago/cluecumber-report-plugin) into it but it only works when I call it via the maven command:
mvn cluecumber-report:reporting
When I run the project via java -jar I can see that the plugin creates the .json file but does not create the reports with the html,css,js page.
Is there a way I can fire this plugin from my java code instead of the maven plugin in the pom.xml?
Or is there a way I can hook this plugin execution after the java cucumber framework runs?
Thanks
As Cluecumber in its current form is a Maven project, it needs to be invoked via Maven. Future versions of Cluecumber may also be usable without Maven.

How to execute maven plugins from gradle without having maven and java installed

I need to execute a maven plugin on a system that does not have both maven and java installed and installing both of them on the system is not an option. While searching for the ways, I found out that by using gradle we can build executable binaries that does not even require gradle to get executed, which perfectly fits my situation :) . Is there any way to execute maven plugins by using gradle. Thanks in advance
Java is required for Maven and for Gradle too.
You can use Maven Wrapper exactly like with Gradle.
Execute this command in project directory (this creates executable script like in gradle)
mvn -N io.takari:maven:wrapper
To invoke this project without maven installed use:
./mvnw GOAL
Gradle is a build system. You can build anything with it, including native binaries.
And yes, you can call Maven Plugins from Gradle, as Maven Plugins are written in Java and Gradle is based on Groovy and thus on Java.
But both facts have nothing to do with each other.
You can of course also use Gradle (or any other build system including manually stuffing things together) to build a distributable that includes a Java runtime environment. But then Java is, as said, shipped with your result. You cannot run Java code without having Java around, besides porting the Java code to something else like C++ that compiles to a native binary.
Yes, you can also call Java code from native code if you do some glueing, but no, also this will not work without having Java around, because that's the way Java works.
Both Maven and Gradle require java to be installed. See https://docs.gradle.org/current/userguide/installation.html

How do you dynamically pass in a cucumber feature file to a maven project Using the command prompt?

I've created maven project with selenium and cucumber. I'm trying to use jira X-ray in a continuous integration setup. Basically I take exported feature files and want to execute them on a command line using bamboo.
I think my main problem is I'm not sure how to feed in feature files to a compiled maven project that has the step definitions.
I have features defined in src/test/resources/shouty
If I only want to run the location.feature using Maven, then I can use the command
mvn test -Dcucumber.options="src/test/resources/shouty/location.feature"
What you want to do is to specify the feature in the CI job using Maven as above.

Compiling Groovy Code in my Java EE application

My web project includes Groovy class files.
How should I compile it for my project using Eclipse?
Rest of my team is using IntelliIDEA to use it but I want to set it up in Eclipse.
To start with I have installed a Groovy Plug-In for my Eclipse and installed Groovy on my Windows.
You should be able to right click on the project -> Configure -> Convert to Groovy project.
If your project is a maven project, then you should also install m2eclipse as well as the optional m2eclipse configurator for groovy-eclipse. This will automatically configure your project for Eclipse and groovy.
Hope this links helps you. It has step by step on how to import your existing Groovy Project into eclipse so you can work on it.
http://docs.codehaus.org/display/GROOVY/Create+Your+First+Groovy+Project
If the project is created using grails create project, I believe all of the .project and .setting files are there for eclipse.
If you have the groovy eclipse plugin installed you should be able to mix your groovy classes into the same packages as your java code. Are you using maven or ant to build your actual war file? If not you will have to make sure that you compile the groovy classes along with the java code. while in eclipse you will be fine. Both ant and maven have facilities for compiling the groovy and java code together for your actual war that you deploy.

How to run a maven Java app on a server

I have a standalone application which I have deployed using the Maven release plugin.
I now need to run it on the remote server...
Would you recommend using the mvn exec plugin?
Otherwise whats the best way of running the app (i.e. working out the correct classpath etc).
Thxs
You can use the Maven Assembly Plugin with jar-with-dependencies descriptor (it's one of default descriptors). It should include all dependencies, allowing you to easily run the jar on the server.
Either the exec plugin, or use the dependencies plugin (or any of the jarjar-/onejar-type utilities) to create an all-in-one jar and just distribute that.

Categories

Resources