Eclipse m2eclipse clean, build projects, build automatically commands, what are they? - java

What is the command that m2eclipse runs when you
highlight a project -> Menu Project -> Clean -> Select anything -> Ok ?
It then goes on to "Building Workspace".
What is the command that allows it to do so?
The reason I am asking is that I am trying to do this from outside Eclipse, from the command line. I am trying to automate all maven stuff in a Groovy script. I am on Windows xp.
EDIT:
Also, the command update maven dependencies would be nice to have as well.
Thanks!

Maven-invocations are put in the Run and Debug menus. Just building the workspace does not run maven - it just does all the work Eclipse needs to do to know your files.

For your purposes these will suffice for the command line build:
cd /to/where/pom.xml/is
mvn clean
mvn install

No commands are directly run. Instead, the m2e plugin uses the configuration in the pom to create equivalent configurations in eclipse.
For example, if you change the source directories it will update the eclipse source directories for the java builder. If you change the target directories for the source compilation, it'll ensure that when you do a Project -> Clean, the plugin knows which directories to clean.
If you are trying to do this though a scripting language, I would recommend just running commands on the command line. The alternative would be to add the maven libraries to the classpath and to use them.

Related

a method to build an executable JavaFX Jar from Maven Archetype

I want to be set an archetype for a stable JavaFX (Java 8) Maven build that will produce an executable JAR that (always) runs from the command line. And preferable without needing to build an UberJar or similar.
When we use the Netbeans 'Maven JavaFX' archetype the resultant JAR file following a build runs. As a project grows we find that sometimes the JAR won't run from the command line. Some Maven POM edits have been needed to 'encourage' the program to run from the command line again. This applies to Linux and Windows.
This also happens directly with the ZenJava JavaFX archetype, e.g. a project artifactId=xx:
java -jar target\xx.jar
no main manifest attribute, in target\xx.jar
This is just from the mavan generate command. The details of the two archetypes in question are:
zenjava
archetypeArtifactId=javafx-basic-archetype
archetypeGroupId=com.zenjava
netbeans
archetypeArtifactId=javafx
archetypeGroupId=org.codehaus.mojo.archetypes
Comparing the resulting POM files shows these that the codehaus.mojo (netbeans) uses these plugins in the build:
maven-dependency-plugin
maven-compiler-plugin
exec-maven-plugin
Either project runs happily from within Netbeans IDE. The challenges occur when we want to test on command line. It isn't really the best look externally when the build looks unstable to outsiders like that.
The questions arising are about what are the requirements to make a JavaFX command-line executable JAR file? For JDK 8 and beyond.
Is there an alternative JavaFX archetype available that will build projects with dependent JAR-s and run from the command line?
What allows Netbeans (say) to execute JAR when the same the built JAR won't run on the command-line?
What 'magic' does Netbeans be add to the execute step?
What is needed for the zenjava archetype to run "Java -jar"?
The JAR resulting from the follow steps doesn't run on the console.
mvn archetype:generate -DarchetypeGroupId=com.zenjava -DarchetypeArtifactId=javafx-basic-archetype ... -DartifactId=xx
mvn install
java -jar target/xx-001.jar
What influences the: maven-dependency-plugin and maven-compiler-plugin when building the JAR for bigger projects?
In other words, what assumptions might be being broken a project grows and bind with other JAR files.
Needless to say, the Maven generate and build steps are using the JDK Java environment. The execution though, java -jar target/xx-001.jar, need to run under the simple JRE (without the JDK). I guess question #4 is a long stretch unless you are someone who has a biggish JavaFX project and solved this already. Suggestions welcome.
just to mention: I'm the maintainer of the javafx-maven-plugin (and the archetype).
To answer your question 3:
You have to call the GENERATED jar-file from the plugin, which is located at target/jfx/app/yourapp.jar
The generated jar-file will reference all required dependencies, which are noted inside the META-INF/MANIFEST.MF-file inside it. While creating that jar-file, the pom is scanned for runtime-dependencies, these will be placed at the target/jfx/app/lib-folder. When bundling your app into native bundle, the JRE is put aside of the generated launcher under the target/jfx/native/-folder.
What confuses me about your problem: mixing CLI- and GUI-application might result in problems, but i guess it's just your special requirement :)
EDIT:
Calling mvn install does NOT generate jfx-jar without special configuration, you have to call mvn jfx:jar or mvn jfx:native to call the MOJOs of the plugin. For easier configuration, please visit our configuration-website: http://javafx-maven-plugin.github.io/

Creating a Site Using Eclipse Maven Plugin

I would like to create a 'site' containing test reports for my Maven Java project. However, all the online resources that I found were talking about the command 'mvn site'. I do work on Windows, though, therefore I would like to avoid any interaction with its console.
Can I do it using solely the Eclipse Maven Plugin? If I want to tell Maven to build my project, I can right-click it and then choose 'Run As' 'Maven Install'. Is there something similar for generating sites?
Thank you all in advance!
Why the hate for specifically the Windows command prompt? What has it done to you to deserve a cold shoulder?
In any case and more seriously: Eclipse allows you to define run configurations yourself. run -> run configurations. Under "maven build" you can add a new configuration to do a mvn site. This page gives an idea by demonstrating how to do a clean install:
http://books.sonatype.com/m2eclipse-book/reference/running-sect-running-maven-builds.html

Eclipse gradle refresh from cmd

I wondered if there is a cmd command for refreshing an eclipse gradle project?
Normally you would right-click -> gradle -> refresh -> refresh all.
I am looking for something like gradlew project:refresh eclipse, to be able to update projects using a .bat file.
Cheers :)
It depends on how you are integrating with Eclipse. If you are using the project file generation approach, just run gradlew eclipse (or gradlew cleanEclipse eclipse) another time, then hit F5 to refresh the Eclipse project. If you are using the Eclipse plugin (also known as Eclipse Gradle integration), you can only refresh in the IDE, in the way you already described (but perhaps you could assign a shortcut).
Reading a documentation can give you the answer - http://www.gradle.org/docs/current/userguide/eclipse_plugin.html
Just apply the eclipse plugin in your gradle buildscript(s) and you will be able to run gradle eclipse from command line.

How to use Maven dependencies in eclipse auto import

I have a new maven project in eclipse and all maven stages work fine.
Problem comes when I write code.
I want classes in my dependencies to be available when I use organize imports.
On pressing Ctrl+Shift+O, eclipse does not use maven dependencies and I need to
manually type imports: this shows errors due to java builder
wait for maven build to compile
Can I not use eclipse java editor like I Used to with a simple java project which has some jars on classpath?
If so, how?
I hope there is a simple solution.
I don't want to spend more spend time mavenizing then writing code.
Use the Maven Eclipse plugin and tell it to download sources and javadocs for you or you can use M2eclipse(which automagically recognizes maven projects.)
use mvn eclipse:eclipse thanks to #Abdullah Shaikh
else
Window -> Preferences -> Java -> Code Style -> Organize Imports.(check
what your ctrl + shift +O do.?)
To convert a maven java project to support Eclipse, you can use below command to generate configuration files
mvn eclipse:eclipse
Run this command from the directory containing the pom.xml
In your case it will build classpath having all the dependencies mentioned in your pom
More details here maven eclipse plugin
mvn eclipse:eclipse
But don't forget to change the directory to your maven project first (command cd)
Then reboot Eclipse
Than go to Eclipse Explorer - right click on your file with import errors - Source -
organize imports (or Ctrl-Shift-O)

How do I view Ant scripts that eclipse uses?

I am having a bit of trouble building my project with Ant. I wanted to take a look at the Ant scripts that eclipse uses to build my project. How can I do this?
I don't think eclipse uses ant scripts to build your project by default. However, eclipse can generate ant scripts for you. This can be done by right click project > export > General > Ant buildfiles. Make sure you uncheck the 'use eclipse compiler' if you want the build file to be usable from outside of eclipse.
No ant scripts are used building in the workspace, however, exporting your projects does use ant scripts. You can generate such scripts by right click on the MANIFEST.MF or feature.xml and PDE Tools -> Create Ant Build File.
The exact contents of the generated ant scripts will depend on the options selected for export, so there may be some differences.
Select Project » Properties » Builders to see what runs when Eclipse builds your project.

Categories

Resources