There are plenty of similar questions in stackoverflow, like Get source JARs from Maven repository, Maven – Always download sources and javadocs, etc.
Follow the instructions suggested by those answers, Eclipse still can't download source code of jar package, but javadoc has been downloaded.
Does someone can tell me why? I fell quite confused.
I believe that you are using an embedded version of maven.
There are two items you need to check:
Check if the options in Eclipse are selected as screen bellow
The second approach is to select an external installation of maven.
Take a look in the screenshot bellow. I'm using an external installation of maven.
In the second approach maven will read the settings.xml of external installation.
There are few ways you can do it
1. mvn eclipse:eclipse -DdownloadSources
2. mvn dependency:sources
3. or below in pom.xml
<properties>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</properties>
Related
We are using a Maven for a while in our project and want to automate the release process little bit. we came up with the following idea so that the version will be maintained by developers or in SCM instead of in DevOps tool like jenkins/bamboo.
Anyone following below process instead of setting the interpolation value in arguments as "mvn install -Dapp.version=1.0.0-SNAPSHOPT"
The process we like to follow is to supply the Maven project version through an external property file.
let's assume the following partial POM.xml excerpt as example.
<project>
<groupId>com.home.diary</groupId>
<artifactId>journal</artifactId>
<version>${app.version}</version>
<packaging>war</packaging>
</project>
let's assume i have an version.properties file in my SCM with following content
app.version=2.0.0-RELEASE
while running the mvn goal
mvn install
i want the artifact generated as
journal-2.0.0-RELEASE
I tried using plugin properties-maven-plugin from org.codehaus.mojo
as discussed here How to read an external properties file in Maven
but it's not working.
Anyone did this? could you please share your implementation/ideas?
This is not possible.
First of all: Why not just manage the version in the <version> tag itself? It is the easiest thing and fulfils your requirement (the developer manages the version in the SCM).
If you don't want this, you need to supply the version either in the POM itself or through the command line. Reading external properties with something like the properties maven plugin will always happen too late, i.e. after the version tag is already read.
I have a legacy project that I'd like to convert to a Maven project for dependency management.
The problem is, that I have one jar (fop-1.1.jar) that I had to edit. It differs from the one that is publicly available and I only have it locally. But I need it this way.
What I tried to do, following several similar how-to's, it to create a fake Maven repo inside the project (local repo is no good, because several people work on that project and the solution has to be self-contained on Git) and reference this repo from the pom.xml. Sounds like the way to go for me, but it doesn't work. Eclipse show the project repo grayed-out :(
What am I missing?
BTW: this is what I tried to follow: https://devcenter.heroku.com/articles/local-maven-dependencies
Let me suggest another way: When we need to "edit" a jar, we give it a special version number like 1.1-edited instead of 1.1.. Then we can easily upload it to our normal Maven repository and use it. Maven even makes sure that you do not accidentally load both versions in the same project because the edit is only in the version number.
I guess what you need is a private maven server(I guess it exists), and then execute command to deploy jar( before deploy, check your account has privileges)
mvn deploy:deploy-file -Dfile=${jarFilePath} -DgroupId=${groupID} -DartifactId=${artifactId} -Dversion=${version} -Durl=${privateServerURL} -Dpackaging=jar -DrepositoryId=${privateServerURLInYourMavenSettings.xml}
,
after deploy successfully, add maven dependency
<dependency>
<groupId>${groupID}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</dependency>
I want to build the LanguageTool Java project from source. This page gives basic instructions for obtaining the "Maven artifact" with all the sources:
http://languagetool.org/java-api/
I'm an expert Java developer but I've never used Maven before. Can someone please tell me how to get the LanguageTool project and all source code into Eclipse so I can modify and build it?
Thanks in advance...
At the bottom of the page you linked (Language Tool) is another link to the svn repository. That's where you'll get the source code and instructions on how to build the tool yourself.
In general, open source projects will highlight the maven artifact as it allows others to use their code in the easiest way possible. Only a few folks like to build the code themselves so the links to the source repositories are often less conspicuous.
There is no automated way to do this.
Best is to start a basic maven project (manually or through a Maven Archetype, import the sources in the Standard Directory Layout, and start adding dependencies to the pom.xml in order to get it to compile.
Libraries like commons,lucene,... are pretty easy to find in the various maven repositories).
Other libs you will probably have to install yourself in your local repository or remote repository.
There's a maven plugin for eclipse if that is your preferred IDE.
I am trying to build the openNMS in eclipse helios using maven. After importing the source using "import existing maven project" i get the around 10k errors. Also i have some error in pom.xml itself, i thought fixing it could reduce the no of errors. The error in pom.xml is
maven-resources-plugin prior to 2.4 is not supported by m2e. Use maven-resources-plugin version 2.4 or later.
Iam referring to http://www.opennms.org/wiki/Eclipse_and_OpenNMS for building the openNMS
Iam using maven available at http://www.eclipse.org/m2e/download/
It would help if you told us which versions of Eclipse & m2eclipse you are using, and which version of OpenNMS you are trying to build.
If all else fails, you should be able to run the Maven build from the command line. In my experience, command line builds are always more reliable and predictable.
Also make sure that you are using the instructions that match the version of OpenNMS you are trying to build.
I have run the command mvn eclipse:eclipse from cmd line which downloaded the libraries in repository then i tried to import the same source directory into eclipse only to find 10k errors
That's not what I meant.
Get out of eclipse.
Get a command prompt.
Create a new directory somewhere the is not in your eclipse workspace.
Checkout the source code.
From the command prompt run "mvn install".
And you haven't answered the questions I asked above. If you don't want to answer, fine ... but don't expect us to be able to help you.
... and i get the error as Build Failure [INFO] There are test failures.
What has happened is that the unit tests have failed, presumably because something needs to be set up to enable testing. (Perhaps, the tests are trying to talk to a database?)
There are two solutions:
Find out what is causing the tests to fail, and fix it. The surefire reports may give you some clues, and there may be some developer documentation on the test setup.
Turn off the tests by adding -Dmaven.test.skip=true to the mvn command line; see this page.
It would also be a good idea to read the Maven documentation if you haven't done so already.
You cannot combine eclipse:eclipse with the m2eclipse support. You cannot use m2eclipse with a project that uses the old resource plugin.
If you want to use eclipse:eclipse, you must use NOT use the 'maven' import from eclipse. Use just 'import existing project'. If you want to use m2eclipse, don't use eclipse:eclipse.
I had this issue with the PDFBox source, with the parent pom for that project. I put this in the pdfbox/pom.xml (just to get it to compile in eclipse at lease, which is the only thing I wanted):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4</version>
<executions>
<!-- had a process goal here that i removed because it was not compatible -->
</executions>
</plugin>
I'm new to Maven and I've been reading all morning tutorials (amazing tool).
This new Java project I started looking at however doesn't use the default directory structure. Instead of src/main/java for sources it uses something like src/org/myapp.
When I run mvn package on the project (where pom.xml is located) I get a message saying that no Sources have been compiled because it's not able to find them (the source path being different).
Is there a way to specify your own sources path in Maven?
Add sourceDirectory to the build tag in the pom file.
<build>
...
<sourceDirectory>src</sourceDirectory>
...
</build>
Here is the relevant section in the maven docs.
In theory, you can use a non-standard directory structure for your Maven project. In practice, you may find that various Maven plugins and IDE integrations won't work properly. So I'd advise that you reorganize your project directory structure to be what Maven expects ... before you get lots of version control history and other stuff that will make reorganization more painful.
How did you create the project? The idea way to create a new maven project is: mvn archetype:create and then follow the instructions.
Read this for more details
Update to extend by answer based on the URL:
mvn archetype:create -DgroupId=[your project's group id] -DartifactId=[your project's artifact id]