1

I am trying to recompile a jar targeting a different java version using Maven. I have installed Maven properly and only changed target and source to 7 inside pom.xml file.

Below is the directory of the project I want to built to a jar:

C:.
|   pom.xml
|   sonar-project.properties
|   
+---.sonar
|   \---.sonartmp
|       \---caches
+---src
|   +---main
|   |   +---java
|   |   |   \---(folder with source java files)
|   |   |                       
|   |   \---resources
|   |           logback.xml
|   |           
|   \---test
|       \---(folder with java files)
|                               
\---target
    |   OLDJAR.jar
    |   
    +---classes
    |   |   .netbeans_automatic_build
    |   |   logback.xml
    |   |   
    |   \---(folder with class files)
    |                       
    +---generated-sources
    |   +---annotations
    |   \---test-annotations
    +---javadoc-bundle-options
    |       javadoc-options-javadoc-resources.xml
    |       package-list
    |       
    +---maven-archiver
    |       pom.properties
    |       
    +---site
    |   \---(folder with Htmls)
    |                               
    \---test-classes
        |   .netbeans_automatic_build
        |   
        \---(class files)

So, this is how the directory of the library's source looks like. This means that they are already a maven project. They also have OLDJAR.jar under target folder. When I run mvn package, no new jar is created and when I delete OLDJAR.jar and try mvn package, it fails. Any ideas on how I should rebuild this project?

Thanks...

Voila
  • 310
  • 2
  • 14
  • use this command `mvn clean install` , it will clear the old jar and build your project again. just take a look on this https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html – Thanigai Arasu Nov 18 '15 at 13:20
  • @ThanigaiArasu no need to install - package should be sufficient. – assylias Nov 18 '15 at 13:26
  • @ThanigaiArasu mvn clean runs says that the target folder is removed but it is still there afterwards along with the oldjar... – Voila Nov 18 '15 at 17:19
  • OK it seems that I had the issue mentioned [here](http://stackoverflow.com/questions/1615352/why-doesnt-mavens-mvn-clean-ever-work-the-first-time) – Voila Nov 18 '15 at 17:33

1 Answers1

0

Try using mvn clean install -U. The flag (-U) will forcibly update the dependencies in your project.

Idos
  • 15,053
  • 14
  • 60
  • 75