One of the pom file was lost , why maven install still suceess? - java

Today I found that after I delete a pom file like a.pom and leave an a.jar file exist, Mvn install can still success. but the result jar lost some dependency descriped in a.pom . So I wonder what's the releastionship between a.jar and a.pom file? Is every maven module after installing has an a.jar and a.pom file ?
also I found that there already an a.pom file inside a.jar ,why there still an a.pom file outside a.jar. what's the difference?
Cause I am new to maven , maybe there is something basic knowledge in maven I dont know.
thanks for answering.

Related

Edit minecraft pluggin from jar and

My friend asked me if I can make some changes to pluggins he send me. I tried googeling them to find the sorcecode somewhere. Sadly it seems that they are not open scource.
So I started decompiling the jar(s) and made the changes in the .class files with IntelliJ.
Now is my question how I can compile it back to a .jar file. Normaly I used maven to build the plugins. But because it isn't a maven project this doesn't work.
I tried creating the jar with:
jar cvf plugin.jar .
but this gives me the error Cannot find main class

Maven dependency compile error : package does not exist

Maven dependency compile error : package does not exist
I have maven parent project which has dependency with another child project's jar file.
Child's jar file is build and success. When building parent again, I got "package does not exist" error.
When I extract the jar file using 7-zip which is present in 'target' location, those packages and its files does exist. I extracted the jar file using 'jar command'as well, files are present. But, when I open the same jar file using Beyond compare 3, those packages are missing.
Somehow maven and Beyond compare unable to identify the packages or is it different problems with maven and beyond compare? I am not sure. After breaking head for two days, no clue about it.
I am using Eclipse Kepler IDE and there are no compilation errors in the project.
Below is the maven version
Below is the artifact code
<groupId>net.pi.run.cut</groupId>
<artifactId>run.cut.receive.mba</artifactId>
<version>7.8.3</version>
<packaging>jar</packaging>
and the dependency code
<dependency>
<groupId>net.pi.run.cut</groupId>
<artifactId>run.cut.receive.mba</artifactId>
<version>7.8.3</version>
</dependency>
Old 7.8.1 version is working fine. Jar has all content.
Below is the img from beyond compare tool, where it doesn't identify the package and its files. P.S. I m necessarily scrapping the folder names with purpose.
Below is the image sample from 7-zip
All your suggestions are welcome.

Add library into jar of project

My problem is with a project where I use the POI library. It's from apache and allows you to work with excel,word, ... .
I had to add some jar files to my library and it runs perfect.
The problem is when I put my JAR file somewhere else.
It gives me the errors it can't find the librarys.
Is there a way I can put my librarys into the 1 jar?
I already tried to add my lib folder as source package but that didn't help.
there is a Maven plugin for Eclipse called M2Eclipse, which will read a POM and construct a classpath out of jars it finds in the local repository and any remote repositories you've configured. It behaves largely like Maven does in terms of finding the latest version for a given jar (if you've specified a version range in your POM).
You can also have a look on this
http://fredpuls.com/site/softwaredevelopment/java/deploy/five_strategies_for_managing_j.htm
You want to make a 'shaded' or 'uber' jar, which has all of its dependencies included
There is a maven plugin for building a shaded jar.
https://maven.apache.org/plugins/maven-shade-plugin/
For me the fastest/ easiest solution was to just open my project in eclips and export is a runable JAR then it adds the librarys to the JAR.
NetBeans builds your application into the project's dist folder. There is also a readme file in it, that tells you, you should distribute the contents of that folder...
Edit
Remove the lib folder, that is shown on the second image, from your sources.

Github Project in Eclipse is not shown as JavaProject

I exported my Project to Github and checked it out in eclipse. This process worked - however it seems like eclipse does not recognize my.java files as javacode. It does not try to compile anything.
I do have a .project file and a .classpath file in the repository. Why doesn't it work. //reference removed
This is how it currently looks like. I am not sure whats causing this problem, but it might be that i got the main folder as project and the actual project inside this folder (nested). How can I fix this if this is the problem?
Thank you :)
You Should not check-in .project, .classpath files and .settings folder. As eclipse will only generate these files for you.
Try deleting these files from your git repository and then again clone it , it should work.
let me know if you face any issue.
You need to commit your folder structure starting from :
/DragonsEdgeRefactored/
Since your project is already a Git repo, you can move the contents accordingly and commit the changes accordingly. I recommend using a GUI Git client like SourceTree or GitKraken.

How to build project from maven pom file

I have a maven pom file for an open source project. This pom file has all the info like what other jars it depends on etc. I installed maven. Created a dir samprj and copied the pom file into that dir. Cd into that dir and ran mvn command without any arguments but I got bunch of errors. I am absolutely new to maven so I think I am missing something. I tried also from Eclipse ( Import project -- exisitng maven project) but that also does not work except eclipse creates a project that has just that file pom.xml. I expect something that first it will download the jar for the project and then download all dependent jars and config files but nothing there.
So given a pom file how do I build the project from it?
mvn install should get you going
I have a maven pom file for an open source project. This pom file has all the info like what other jars it depends on etc. I installed maven. Created a dir samprj and copied the pom file into that dir ...
It sounds like you only have the project's POM file. This is not sufficient. You need to checkout the complete source tree for the project. Having done that, change directory to the directory containing the POM file and run mvn install.
Also, don't copy the POM to a different directory. Maven expects to find all of the source files relative to the POM file location.
FOLLOW UP
Thanks for advice. I was not able to use the command mvn install as it gave errors.
Probably because you hadn't checked out the source.
I don't know how to check the source tree of the project ...
Use a subversion client (the svn command for example), or one of the Eclipse subversion plugins.
If this was a properly documented project, there would be clear instructions on what version control and build tools you needed, how to checkout the source code and how to build it.
... as I thought POM itself should have this information to automatically checkout if the source is not check out.
It doesn't necessarily, though in this particular case it does.
Anyway I was able use Eclipse to build the project without errors.
(Other readers can read #icyrock.com's answer for links to the m2eclipse plugin and documentation.)
The only problem is the dependent jars were downloaded but hidden deep paths in .m2 repository folder on my linux box.
But I would like these dependent jars to be relative to dir where POM file is.
Sorry, but that is not the way Maven works.
The ~/.m2/repository directory is a fundamental part of Maven. It is not a problem. It is a feature. (Don't fight it!)
If you want to open this within Eclipse, you need to install m2eclipse:
http://www.eclipse.org/m2e/
and then import the project as a Maven project as described here:
http://books.sonatype.com/m2eclipse-book/reference/creating-sect-importing-projects.html
Try out their getting started guide. It has a lot of good examples:
http://maven.apache.org/guides/getting-started/

Categories

Resources