Missing the ‘maven package’ menu entry in eclipse - eclipse

I'm using Eclipse 3.7 with m2eclipse. Previously I know there was a menu entry ‘maven package’ but since I reinstalled Ubuntu there is no entry and I have to ‘maven install’ to do the same.
Now I'm wondering if it is possible to get the ‘maven package’ back so I could test something without installing it and allow other projects to use the test version as dependency.

Just use Maven Build... and type package in the goal field.

I also recently wanted to have this option with the new version of m2eclipse. The best solution i could find is, to create a configuration with the goal package, and as base directory give a variable name ${selected_resource_loc}. Still you have to go to run configurations page, but at least you don't have to define a new configuration for each project, but use the predefined one.
right-click project
run as
run configurations..
double click maven build (to create a new configuration)
give a name for configuration e.g. package
click variables
select "selected_resource_loc" and click ok
write your goal e.g. "package" or "clean package"
run
The next time when you want to package another project, you can use this configuration again:
right-click project
run as
run configurations..
select your maven configuration
run
At least you will not have to create a new configuration each time you want to package, as with maven build...

Related

Second Eclipse plugin project seems to be interfered with by first -- why?

I created a plugin project using the Eclipse wizard, wrote a little code and then created a second project without any change. When I run the second project so that it creates an instance of Eclipse for testing, I see the behavior of the first project. I am guessing that both projects share some directories or something. Can it be explained what is happening and how to create two plugin projects in same workspace?
You can have any number of plugins in a workspace, one of mine has 52.
Note that when you test a plugin using 'Run As > Eclipse Application' Eclipse normally includes all the plugins in the workspace in the run. So you would get both your plugins included.
If you don't want both plugins included go to 'Run > Run Configurations' and edit the plugins list in the run configuration. You can duplicate run configurations to create as many different setups as you need.

Maven multimodule projects linking in eclipse

I have a maven multi module project which has 5 modules. Some of my modules depend on one or more other modules, I am successfully able build the project and in eclipse also I am not getting any errors. However there is one problem which is bothering me, when i ctrl + click in my code and the class is defined on some other project eclipse does not open the file in the editor. I know i can attach the source code using maven but still i wont be able to make changes to that file.
Is there any way to be able to link projects in eclipse through maven?
Is there any way to be able to link projects in eclipse through maven?
That behaviour is the default. To check if for some reason that default is not in effect for your project, right click your project (the project you want to jump from) and go to "Maven". If there is an option "Disable Workspace Resolution" the workspace resolution is switched on, meaning you can theoretically jump from that project.
If you still cannot jump, then the project you want to jump to is not in your workspace. Take into account that for eclipse to identfy one project as dependency of another, everything including version must match.
Also check what rest_day said. You must have the projects importet as maven projects, but running eclipse:eclipse is not required anymore with current (up to ca 2 year old) eclipse.
Did you import the projects as Maven projects?
Also, could you go to the root of the project and run mvn eclipse:eclipse
eclipse:eclipse
Full name:
org.apache.maven.plugins:maven-eclipse-plugin:2.10:eclipse
Description:
Generates the following eclipse configuration files:
.project and .classpath files
.setting/org.eclipse.jdt.core.prefs with project specific compiler settings various configuration files for WTP (Web Tools Project), if the parameter wtpversion is set to a valid version (WTP configuration is not generated by default)
If this goal is run on
a multiproject root, dependencies between modules will be configured
as direct project dependencies in Eclipse (unless useProjectReferences
is set to false).
Instead of Ctrl+Click, click on the identifier and press F3. If you now see a red text reading "Current text selection cannot be opened in an editor", you've been hit by this bug.
See this question for a solution: How do I get rid of "Current text selection cannot be opened in an editor" in Eclipse?

How to run an eclipse m2e webapp project on a local server?

I'm trying to create a simple webapp as a maven project with m2e to help me manage dependencies, but I'm must be missing something, because I'm not able to run the project from eclipse.
To put a bit more context, here is what I do:
First, I choose to create a "Maven project"
Then, I select the "maven-webapp-archetype"
Finally, I fill the basic project information form of the next step and finalize project creation. Everything looks fine at this point.
The problem is that when I try to run the project, I don't find anything suitable to run the project on a local server:
Also, from the "Add and remove..." context menu entry of the local server, my project doesn't appear in the list of web projects.
Did I miss a step in the setup, or is there an other more suitable way to start the project?
You should install the m2e-wtp connector.
You can install this from: Window, Preferences, Maven, Discovery, click Open Catalog and search for wtp. Check the box next to m2e-wtp, and click Finish.
Once the installation process has completed, allow it to restart Eclipse. After that, you may need to right click on the project, choose Maven and Update project.

Launching run configuration outside Eclipse IDE

I have a run configuration defined for my Eclipse RCP application which is saved to a .launch file. Is there a way to use this launch configuration outside the Eclipse IDE? i.e, it would be nice to be able to launch the application from the command line for continuous integration purposes.
You can get the command line Eclipse uses:
Run your program in Eclipse
Go to the "Debug" view
Right-click on the process (probably the second item in the tree) and select "Properties"
Copy shell command and delete the agentlib flag to run in bash. Unfortunately, you need to do this whenever you change the configuration.
Yes, you could create and export a product configuration based on your launch-configuration:
Create new Product Configuration (File -> New -> Other)
Name the file (e.g. myrcp.product)
Select "Use a launch configuration" on the first page of the wizard
The product editor should open automatically. In the Exporting section you should be able to export your product using the "Eclipse Product export wizard".
Resource: Eclipse FAQ - How can I deploy my RCP app
Have a look at this PDE Build tutorial. It explains how to build and test (or run) your product using Ant.
It is possible to do that with a little workaround. You can find your configuration at workspace\.metadata\.plugins\org.eclipse.debug.core\.launches. So, open it in text editor and find an attribute containing goals, e.g. clean install -DskipTests=true.Then, go to the root of your project and execute that by the CMD:
mvn clean install -DskipTests=true
This should be similar for other goals.

Eclipse doesn't see my new junit test

I'm using eclipse to run the tests in a single junit(4) test class. The tests in the class all run just fine. Then I add an additional test and run the class through the test running in ecplise again. Only the old tests are run. The new test isn't seen by eclipse. There's no error or anything, it's just as if eclipse is looking at an old version of the test.
If I run the tests using maven, everything works fine. Additionally, after I run the tests in maven, ecplipse can see and run the new test correctly.
Any ideas what's going on? Any ideas how to get ecplipse's test runner to see my new test cases?
I had the same issue. I solved it by doing the following:
Going to Project -> Properties -> Java Build Path
For the source folder src/test/java, the output folder was set to
"Default output folder"
Setting this to the typical Maven target/test-classes directory in your Maven structure
After this, Maven and Eclipse were in sync (as opposed to Eclipse happily running an older version of the tests, from whenever the last Maven compile was).
Maybe you "just" need to create a new Run configuration. Eclipse "remembers" the latest used Run configuration and just repeats it if not told otherwise. To make sure you have a new Run Configuration you can rightclick the test case in the package explorer and choose Run As | Junit Test. Next time you hit play this will be the "remembered" Run configuration etc.
Possibly src/test is not in the Java Build Path.
Solution on Kepler:
Project -> Build Path -> Configure Build Path -> Source -> Add Folder
Then check the box corresponding to test under src
You might find this is likely caused by using Maven to build (Maven usually builds into the 'target' folder), but Eclipse is using a different build folder for its own build process. Simplest way is to go into the target folder under your Eclipse Project (or Bundle if using OSGi) and delete the conflicting subfolders/class-files from under that directory; for me this is my "target" folder. Then get Eclipse to rebuild, and everything should be fine.
Technically, and alternatively, you could just blow away the entire build/target folder if you wanted to, and let Eclipse rebuild everything.
In response to the answer provided by Ryan Dawe, I have found out that Default output folder can be set to only one folder, for all the source folders on build path. So if i changed the output folder to target/test-classes, my src/main/java was also outputting classes there.
You might have written this response for a different older version of eclipse, but as of Mars.2 release, we can only have one default output folder for all source folders.
The best solution i have found so far for this problem is to just include the target/test-classes as a class folder, by going to Project -> Properties -> Java Build Path -> Libraries -> Add Class folder.
It seems that your project wasn't recompiled. Either check Menu:Project/Build Automatically or do it manually as Boris Pavlocic commented.
This seems to be the same issue as junit not using the newest file
The problem seems to be that Eclipse puts the compiled tests in the wrong folder which can be solved by manually specifying where they should end up.
Add "test" in front of your test classes if not there already the #Test annotation isn't always picked up from Eclipse's Junit Test framework.
Here is how i fixed my problem...
right click project and go to Run As -> Run Configurations...
select JUnit -> [project-name] on the the popup that came up
(this configuration of [project-name] was created for me by eclipse
but if not there you can right click JUnit -> New and create it)
goto Classpath tab
highlight User Entries and click Advanced... button
on the Advanced Options popup that came up select Add Folders and click OK
on the Folder Selection popup that came up scroll to your project open up target and select test-classes and click OK
repeat steps 4-6 for the [project-name]/target/classes directory and any other directory needed in your classpath (like properties files used in your tests etc.)
Note: this assumes your project's default output folder for tests is target/test-classes, if it is not then adjust accordingly. Also, make sure you have the right JUnit version selected under the JUnit Run Configuration as well and your src/test/java directory is a source folder to your project, etc. as mentioned by others.
It means that you have created a Test class that you haven´t build yet.
After a build, for example with "gradle build" the Test class will be found by Eclipse too.
In my case I had to make a cleanup before as well.