I've created gwt project using maven plugin:
mvn -DarchetypeGroupId=org.codehaus.mojo -DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.5.1 -DgroupId=com.savdev.BasicGwtProject -DartifactId=BasicGwtProject -Dversion=1.0 org.apache.maven.plugins:maven-archetype-plugin:generate
Then I created a new IDEA projext using the generated pom.xml file. At the moment Project Compiler Output folder points to PrjectName/out, as usual I set it to ProjectName/target folder, to build project both with maven and IDEA, but when I ran maven install I haven't found class folder in the ProjectName/target directory. Where does the "Project Compiler Output" should point when mix IDEA, Maven for GWT project.
'Project Compiler Output' is used as a base directory for output paths for modules when IDEA project structure is created by hand. If a project is imported from Maven IDEA set output paths for modules individually accordingly to Maven configuration (see 'Paths' tab of a module editor in 'Project Structure' dialog) and 'Project Compiler Output' isn't used at all.
Related
In an eclipse project, I referenced a class that was currently not in project's build path.
In the context sensitive pop-up that opens by hovering the mouse over the error, "Fix project setup" option has offered me to add a jar to the build path of the project. This jar is in my local maven repository.
However, the "correct" way to fix it is obviously by adding the relevant dependencies to my project's pom, instead of adding this jar to the build path of the project.
So is there a way to configure eclipse, so that it won't offer to add a maven repo jar to the build path, but it will offer to fix the project's pom?
This feature used to exist in m2eclipse (the predecessor of m2e), see e.g.
https://blog.sonatype.com/2010/03/adding-dependencies-using-m2eclipse/ which shows a "Search dependency for XXX" quickfix above the "Fix project setup..." quickfix.
Unfortunately it didn't make it into m2e, see https://www.eclipse.org/lists/m2e-users/msg01130.html
Make sure:
your project is fine outside of eclipse using only maven/pom, mvn
clean install (or similar) in an external shell/console
your eclipse project has maven nature
Eclipse -> Project -> Build Automatically is checked
Refresh your eclipse project
Do something in the pom.xml (save file) should trigger a build
I know "adding Maven nature" is an Eclipse term.
Actually I want to add SOME dependencies from maven repository by editing pom.xml file. Is it possible? I want to remain a directory structure and other JAR tracking of a project intact.
The project is of jMonkey SDK.
in netbeans there are no natures. Either the project is a maven project (by having a pom.xml file in project directory) or it's not. No matter what type, projects are just opened.
if your project is both ant based project (having nbproject/project.xml file and build script) and contains pom.xml, then the ant project takes priority and will be opened as ant project. No way to mix then. to load as maven project you will have to delete ant project related files and restart the IDE.
add minimal pom.xml file
close project
re import it to netbeans as maven project
or create a new minimal maven project and delete source and resource directories and place your project stsructure and
configure pom.xml to match with your directory structure
by specifying resources & source directories in pom.xml
I am trying to add java code from a Maven project (called docx4java) which I checked out from svn to an existing Eclipse project (called DocumentManager). I have tried the normal way, that I thought would work, i.e.:
Right Click on eclipse project>Properties>Java Build Paths> Projects > Add (here I add the Maven project) and >Libraries (here I specify Native Library location e.g. docx4/trunk/docx4/src/) but I still can't get the 'Maven' classes to be recognised in eclipse. I get the message
import docx4j.src.main.java.org.docx4j.convert.out.flatOpcXml.FlatOpcXmlCreator cannot be resolved
I have tried adding a test project that was compiled in Eclipse and that works fine, Eclipse seems to recognise it i.e. import org.me.TestProject works fine.
How can I get the code from the Maven project docx4java to work in the Eclipse compiled project DocumentManager?
You can generate eclipse poject files (which you can just import into your Workspace) using the maven eclipse plugin
Take a look at these ecplise plugins for a more direct integration of maven into eclipse
You should create a eclipse project for docx4java as #Attila has commented. Once that is done, you should have two projects on your workspace: docx4java and DocumentManager. At this point, what you are doing now (adding a project reference to the Java Build Paths) should work.
It seems that the source path is not configured correctly, this is why the compiler cannot find your "Maven classes".
docx4java.src.main.java...
Maven has a different directory structure and you have to tell Eclipse where to find your sources.
For a "vanilla" eclipse project, remove the standard eclipse build path src and add the maven source path src/main/java (or whereever you added the code), the compiler should correctly pick up your sources.
Note that you still have to add all jars mentioned in the dependencies section of the maven pom.xml file. Otherwise it won't compile, even if it finds your added java classes.
(Addendum: I would recommend to use maven in your existing project as well.)
I am building my jar abc.jar. At the same time I am also building the abc-sources.jar.
I am having a project xyz which is dependent on abc.jar. So I am adding abc.jar in the classpath. But when I am trying to debug and see the source code of abc.jar through reference libraries of xyz project I always get source not attached so I have to also include abc-sources.jar file in the classpath of xyz in order to debug through the source of abc.
I guess is there something wrong with my eclipse workspace or is there another way of compiling abc.jar to get the source code or is it that my eclipse needs another plugin?
Thanks!!
If you use m2e or m2eclipse, right-click the project and select Maven > Download Artifact Sources
Or activate it permanently by selecting Window > Preferences > Maven > Download Artifact Sources from the Menu Bar
If you use the maven-eclipse-plugin, do it like this:
mvn eclipse:eclipse -DdownloadSources=true
Lets say I have two maven projects: moduleA and moduleB.
moduleA has a dependency to moduleB in it's pom.xml.
I use IntelliJ Idea, and I have 'Maven Projects' tool window, where I have both these maven projects.
And it is possible to run maven plugin goals from there: I open 'Maven Projects' -> moduleA -> Plugins -> jetty -> jetty:run.
Java is run, moduleB is in classpath, but it is in the Maven local repository!
So that, if I change something in moduleB sources and execute jetty:run from Idea, I will not see code changes until moduleB is installed with mvn install.
Is there any solution in Idea to deal without mvn install, for instance to run somehow maven goals with idea-module classpath?
I suggest to use Jetty Integration IDEA plugin to run standalone jetty
http://github.com/codebrewer/intellij-idea-jetty-integration-plugin
if you still want to use jetty:run, you could tell IDEA to do mvn install for moduleB:
Run -> Edit Configurations -> select youy maven run config -> Configuration tab -> Before launch (at the bottom) -> Run Maven Goal
That IDEA plugin is not developed anymore because IntelliJ now includes its own Jetty runconfig thing.
Here's what worked for me with a Maven multi-module project:
In File, Project Structure, Modules I have all modules compile to the same output path ("Use module compile output path"). I chose the "...WEB-INF\classes" path within the folder of the Jetty Deployment folder.
Then I also have to tell IDEA to not clear output directories when compiling. Otherwise each module that compiles (one after another) clears the classes from the previous one. Settings, Compiler, uncheck "Clear output directory on rebuild".
Also, I had to put all my external (maven) dependency jars into the "...WEB-INF\lib" folder initially.
Yes, it's hacky, but works. If someone has a better, cleaner solution I'd be interested to know.