How to include maven-based project into my non-maven project - java

I have a non-maven app engine project. I need to include the following library/project into it: https://github.com/UltimaPhoenix/luceneappengine. Without using maven at all, how do I make this work? I need step by step details. I have been trying and my code will not even compile. I am using eclipse.
Looking at the pom.xml I have figured that I need to download luceneappengine, which I did at http://search.maven.org/#search%7Cga%7C1%7Cluceneappengine. Do I need any other jars?

First of all, download Maven to be able to build the project. After that, just use "mvn install" to produce the *.jar of luceneappengine (the result will be stored in the "target" folder of the project). However, it will probably need some extra dependencies. To obtain them, use "mvn dependency:copy-dependencies -DoutputDirectory=$TARGET_DIRECTORY". This command will download all the required jars into the specified $TARGET_DIRECTORY.

Related

GWT maven build eclipse

I had a GWT app, and I wanted to automate its build and deploy system, since I do it manually. But I did not find a way how to build the app from command line, so it can than be automated. I had to click the Google button, then compile GWT project and then click Compile.
I found out that it is possible to create a GWT maven project and that it should then be possible to compile my project from commandline with mvn gwt:compile.
So I created a new project using this plugin. Copied my sources from the old project to this new one.
Now the structure is like this:
/src
---/main
------/java -> here are all my sources including my Project.gwt.xml file.
------/webapp
---/test
pom.xml
Now I have 2 problems.
1. I thought that I add dependencies to the pom.xml, and then when I build the app, it will create the jars and I can use those libraries in my GWT app. I guess 'mvn clean install' should do this, but so far I'm getting compile errors.
2. I did not get mvn clean install to work, so I added all the jars manually again... And then yes! I was able to build the app using the plugin GWT button! So I was thinking that now I can use 'mvn gwt:compile', but it fails with:
Unable to find: "com/company/project/Project.gwt.xml" on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
EDIT:
So I fixed my <moduleName> element in pom.xml, so now it finds the Project.gwt.xml. I'm trying to run:
mvn clean install gwt:compile
But I am getting compile errors. I think, it tries to build my project without the actual dependecies because it tells few classes don't exist, but those classes are part of an external library. (specifically this one). But I have it in the dependencies, so I don't know what more to do.
<dependency>
<groupId>com.github.tdesjardins</groupId>
<artifactId>gwt-ol3</artifactId>
<version>3.0.0</version>
</dependency>
Also in eclipse I had to manually add the jars to my project, so that was why it worked there and not in the command line. So I would also like to ask how to tell eclipse to get those jars and include them to the project, because otherwise eclipse is missing those dependencies and displays many errors.
First I had a problem with <moduleName> in my pom.xml was missing com.company.project prefix before the actual module name.
Then I had errors in my Java files, which was caused by RELEASE version of GWT-OpenLayers 3 library missing some of the features that I previously used by building the JAR from the GitHub repository.

Adding a local jar into mvn clean package result

I'm building a SonarQube plugin and I need to use Maven to achieve it, I must use the goals clean package to create the jar file that acts as the plugin. My problem is that I need to load either a local jar file, which didn't worked as I tried using: <systemPath>${project.basedir}/lib/epsilon-1.3-core.jar</systemPath> to load it as a dependency and Maven wasn't able to resolve it or I must load three external projects which are at my workspace but I don't know how to tell maven to include them.
Could someone help me to do this? I'd really appreciate it! Using my own Maven repo (with Nexus for example) isn't an option.
I had to do a local maven repository loading the plugins of Epsilon as jar files, it's a temp solution while the Epsilon Team setup a maven repo.

Running a Maven project with many dependencies

I'm hacking on a Maven-based project with a lot of dependencies; the project is normally meant to be developed in Eclipse but I need to work on it from the command line.
How to build+execute the project in a sane way? Something like mvn run, but of course Maven is not meant for running Java projects (for some reason).
The problem is specifying all the dependencies on java's commandline, I don't even know how to autogenerate that. I can currently deal with it using the assembly:single maven plugin (using the jar-with-dependencies descriptor) which will package the dependencies to a single .jar for me.
However, there really is a lot of dependencies and the assembly phase can take about two minutes, greatly disrupting my hack-test cycles so I'm looking for other ways to run the project with minimum build overhead - any recommendations, please?
Note: One possibility is running it in Eclipse once and capturing the java commandline. However, that's just a one-time hack, not a general solution in case I change pom.xml later or come to another project from the suite without Eclipse access anymore.
Have a look at the maven exec plugin
mvn exec:java -Dexec.mainClass="com.example.Main"
if you do this frequently, you can of course configure it via plugin configuration.
Regarding finding out project dependencies - you can use maven dependency plugin
http://maven.apache.org/plugins/maven-dependency-plugin/list-mojo.html
If you want to put them into file it'd be smth like
mvn dependency:list > dependencies.txt
See this question: How can I create an executable JAR with dependencies using Maven?. You can use the dependency-plugin to generate all dependencies in a separate directory before the package phase and then include that in the classpath of the manifest.
I see three solution to this:
onejar-maven-plugin - faster than assemlby with jar-with-dependencies descriptor
With onejar-maven-plugin, you'll (...) get a nice clean super jar with the dependency jars inside.
Spring Boot Maven Plugin - but this is dedicated to Spring projects
Maven Assembly Plugin with custom descriptor. This custom descriptor should grab all dependencies into lib folder, maven-jar-plugin should set Class-Path in Manifest.fm according to this new location. After this you can simply execute your program or zip your jar with lib folder as distribution.
After this is possible to run your program on your computer or any other with one command:
java -jar myjar.jar

Trying to compile Maven with clean parameter and got exception

Trying to compile Maven with clean parameter:
C:> mvn clean
and got the exception below:
Cannot execute mojo: clean. it requires a project with an existing pom.xml, but the buid is not using one.
can anyone tell me how I can associate my existing project to maven.
Maven uses a file called pom.xml to build. It should be located in the root of your project.
Maven works on the basis that your project conforms to the Maven way of doing things and so I would recommend reading the Maven Getting Started Guide to familiarize with the standards before starting to use Maven.
I think you need to read up on a bit of documentation. Basically it is the pom.xml file it is complaining about that defines how maven should handle your project.
This explains how you can use maven to generate an example project.
This goes in more depth and also provides some links to other resources.
suppose your project is in 'C:\MyProject' where you can see a pom.xml file, open command prompt, go to C:\MyProject and type 'mvn clean' as follows:
> cd C:\MyProject
> mvn clean
The project you are compiling is not a maven project.

How to add external jar files to maven

How do I add external jar files to maven web app project using Eclipse M2 Plugin?
The most correct way is probably to install them to the repo.
However, for an alternate, see the top answer to:
Can I add jars to maven 2 build classpath without installing them?
You want to use mvn install:install-file. See here for the instructions in the Maven guide:
http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

Categories

Resources