Switching from Maven command line interface to Eclipse Plugin - maven-2

I'm working on a project that is built using maven to weave in AspectJ annotations when compiling. Up until now, it worked like this:
1) Turn off "Build Automatically" in eclipse
2) Make changes to code in Eclipse
3) Navigate to Project folder on command line
4) Run Maven from command line
5) Refresh in Eclipse
6) Run program in Eclipse
Since Eclipse Plugins for Maven integration exist, I'd like to figure out how to use them to simplify this process. However, I've only found instructions about how to begin a new Maven project using the plugin - nothing in any tutorials or documentation about converting an existing project. Will I need to re-import my project? Or is there a better way?

Just install m2eclipse, remove your maven project from your workspace, and then re-import it as an existing maven project like this:

Related

How to put Maven Tycho Dependency in my Eclipse Plug-in?

I've created a new project using tycho 0.26.0, it runs with Eclipse 4 Neon.2, so all modules are building successfully using maven, now I am trying to add a new dependency in my project, I have created a jar and I want to use it in my project, but I don't understand so good how is it working.
I add I am using a target definition, so I have to add my configuration to this file, this will be used by my modules.
I don't know if I got your question right.
I assume you want to build an Eclipse RCP application with tycho and use an JAR file from one of your plug-ins.
The simplest solution is then to create a new plug-in project from this jar by using the Plug-in from existing JAR Archives-Wizard.
If you have done this, you can add a dependency from this new plug-in to your existing plug-ins. Don't forget to export all packages of the library, by opening Manifest.mf and adding all packages in the Runtime tab.
To get this running with maven you have also to add a pom.xml file to the new Plug-in. This link help me a lot with maven tycho (http://codeandme.blogspot.de/p/tycho-articles.html).
Btw. if you don't need this library as plain JAR, you can also create directly a Plug-in project instead of first creating a JAR and then creating a Plug-in project.

IntelliJ IDEA 14.1.4 + Gradle: Cannot Compile Groovy Files

Each time I attempt to create a new IntelliJ 14.1.4 project on Windows with Gradle integration I receive the following error during the 'Make' command when I have any Groovy source files included in the project...
Error:Cannot compile Groovy files: no Groovy library is defined for module 'GradleCommandLine'
I have tried:
Creating a Gradle project through the new project wizard in IntelliJ, choosing Groovy as a an 'Additional Library'
Creating a new Gradle project outside of IntelliJ using the gradle init --type groovy-library command, then opening IntelliJ which finds the gradle.build file and automatically links to the project
Converting an existing project that was working with the IvyIDEA plugin to a Gradle build
I have tried adding (made sure) my groovy-all library as a 'Global Library' within the project structure
Each of these gave me the same 'Cannot compile Groovy files' error.
What does work:
I can run the gradle war command which compiles correctly and I can deploy the build war to an application server (in my case Tomcat 7.0.47)
However in watching the Getting Started with Gradle in IntelliJ IDEA 13 (they do not have one for IntelliJ 14) demo video, they are able to just run the standard 'Make' and add the unexploded war as a build artifact.
Also had a colleague using the Mac version of IntelliJ 14.1.4 do the same 'I have tried' attempts above and he did not run into any issues. They even imported the same project I was having issues with and it was able to do the 'Make' without any changes to settings.
Pointing to local Gradle installation solved issue. There was an issue with a corporate proxy preventing the Gradle distribution from installing properly.

Getting contents and natures of all projects in a Maven build

Currently I'm working on a Maven plugin that should generate files in all projects (OSGi bundles) that have a certain Eclipse project nature.
How can I access the contents of the projects included in the build and the project natures by using the Maven API?
Maven is a standalone build tool, not an Eclipse plugin. You cannot access Eclipse project settings from core Maven API.
Eclipse supports Maven with the M2E Eclipse plugin. It is possible to write M2E extensions and in the extension you can query the project natures via the functions of AbstractProjectConfigurator class.
However, M2E extensions will not run when you compile your code in the command line. I suggest that you choose one of the followings:
Write an Eclipse plugin that generates the source code into the src folder of the maven project. Code generation should be started by the user manually (selecting a context menu in the project or something).
Avoid using Eclipse project natures and solve your questions based on analyzing the source and pom of your project.
If you need to react on certain aspects in the source code like it looks from the thread with Balazs then you can simply write an ordinary maven plugin and include it in the parent pom. It will then run in every project and can analyze the code and react based on it.

IntelliJ IDEA with multiple gradle subprojects

I'm working on multiple Gradle projects with internal and external dependencies, and so far I am happy that thanks to Gradle's dependency management I can modify a library project without affecting every application that uses the library.
When I need to modify a library project and test it using an application project that uses it, I need to do the following,
Modify the library project and commit to SCM
Trigger CI to build the library project and push it to my Gradle repository
Update the application project's build.properties to refer to the new version of library project
Iterate the above steps until everything works and there is no bug
So it became quite combersome now. Can I configure IntelliJ IDEA so that
All my Gradle projects are in one window, like the screenshot below, which is Twitter's Finagle imported using its pom.xml. Sadly IntelliJ's JetGradle plugin doesn't seem to understand Gradle subprojects.
When build.properties's dependencies are my subprojects, read dependency from local snapshot, otherwise download them from the Gradle repository
Thanks.
If you want to open all projects in a single IDEA window, you'll have to aggregate them into a multi-project build, at least until IDEA 13 hits the market. Before IDEA 13, it's better to use Gradle's IDEA integration. Once you have a multi-project build, all you need to do is to add allprojects { apply plugin: "idea" } to the root build script, run gradle (cleanIdea) idea, then open the generated IDEA project.
Currently in IntelliJ IDEA 2019.2 you can add the gradle subprojects like so
Open Gradle Tool Window via View > Tool Windows > Gradle menu
Click on "Link Gradle Project" button (the plus sign)
Select the build.gradle file corresponding to the subproject
Go to File > Project Structure > Modules > NameOfSubproject
Navigate to main/java and click on Mark as: Sources
Mark the main/resources as Resources
Restart IntelliJ IDEA
The sources of the subproject will be recognized by IntelliJ and you can use Navigate Class action for the classes in the subproject

Maven2_Builder vs. Maven Project Builder

I inherited a project that relies on Maven 2 to build it. Via project's Properties > Builders I can see that it has two builders, in this order:
Maven2_Builder
Maven Project Builder
I thought that there should be only one Maven builder...
Why two?
What the relation between the two?
Using the m2e plugin, I can clean the project at any given time via the project's context menu Run As > 6 Maven Clean. Does this mean Eclipse's Project > Clean... is no longer relevant?
Looks like you are using Eclipse with M2E. These days that works very well.
Before one would run
mvn eclipse:eclipse
Which would generate the typical Eclipse configuration files.
These days, just use the Eclipse Import as Maven Project and all necessary files are created.