I'm new to maven and I'm having some issues building some code. A colleague uses the following command to build one of our projects:
mvn clean install –Drevision=5.0.0-local-SNAPSHOT –P bld
This works on his machine but not on mine. I get
[ERROR] Unknown lifecycle phase "▒Drevision=5.0.0-local-SNAPSHOT".
Any idea what is could be causing this? I use Maven version 3.6.3 with java 1.8.0_92. Also how do I make a run configuration on Eclipse for the command line above? Do I just just remove "mvn" and add the rest to the "Goals" field?
I guess that the - at the beginning of -Drevision=... is not a real - but some other dash.
Try not to copy/paste, but enter it directly.
howlger already answered the part about Eclipse.
The Issue
I am unable to compile Java code for an imported Eclipse project on IntelliJ build 182.4505.22 on Java 9 and 10. The following error is displayed when compiling the module, or any individual file:
Error:(1, 1) java: cannot access edu.wit.cs.comp2000
zip END header not found
Details
The structure of the project is as follows:
The full compile-time output is as follows:
Already Attempted
I have reviewed posts here and here, which do not provide any relevant details.
I have attempted compiling on both Java 9 and 10, which makes no difference.
I have written a main method into LinkedBag and attempted to run that independent of JUnit, which results in the same error.
IntelliJ is not correctly displaying the testing icons in my test class, so I suspect that JUnit (or lack of JUnit) is the cause of the issue, however I am unsure how to proceed. Compiling works for other projects (without JUnit tests) just fine.
Updates
The code seems to compile and test as expected on Java 1.8 without issue. Switching to Java 9 or 10 causes the above issue every time. I am beginning to suspect that one of my instructor's dependencies requires Java 1.8 specifically, however I would still like to use newer versions of Java if anyone might have a solution.
As mentioned above, just delete the corrupted cache and restart Intellij.
Running gradle in the commandline can help knowing what you should delete. For instance:
$ ./gradlew --version
Could not unzip /home/cesarc/.gradle/wrapper/dists/gradle-5.6.2-all/9st6wgf78h16so49nn74lgtbb/gradle-5.6.2-all.zip to /home/cesarc/.gradle/wrapper/dists/gradle-5.6.2-all/9st6wgf78h16so49nn74lgtbb.
Reason: error in opening zip file
and after deleting the folder /home/cesarc/.gradle/wrapper/dists/gradle-5.6.2-all/9st6wgf78h16so49nn74lgtbb the problem was solved:
$ ./gradlew --version
Downloading https://services.gradle.org/distributions/gradle-5.6.2-all.zip
......
We had this issue when internet connection dropped while Idea was downloading project dependencies. We solved it by deleting the corrupted file from cache. Cache location depends on your build tool, e. g. for Maven it's in ~/.mvn, for Gradle it's in ~/.gradle.
In my case, it was: /.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.41/tomcat-embed-core-9.0.41.jar
I just removed it and I was able to compile my code.
Just pay attention to the .jar file in your case it's giving an error. Just remove it and you are good to go.
I Had Similar issue in my mac.I just deleted .m2 repository and did maven clean install again worked.
Instead of deleting your whole maven repository you can scan through it locally to find the bad jar file using GNU utils
find <maven-repository-dir> -type f -name "*.jar" -exec zip -T {} \; grep -v OK
I got this error
[ERROR] error reading /Users/username/.m2/repository/io/confluent/common-config/5.5.1/common-config-5.5.1.jar; zip END header not found
I don't know why the jar was corrupted but the error went away when I replaced the jar with my colleagues jar file. Fixing the error temporarily.
In my case, the gradle version of the project was 6.2.2 and the 6.4.1(system default gradle) path was provided in the Intellij gradle settings.
This issue appeared suddenly though. I was working on this project for a long time without any issues. I am not quite sure as to what triggered this issue. The gradle default version package was fine as the gradle build was fine from command line. :)
Referred to suggestions from here
Any one of the below solved the issue on my system:
Provide the path to project gradle version, in gradle settings.
or
Change the 'distributionUrl' value in your gradle-wrapper.properties to have 'all' instead of 'bin'. And also make sure you have gradle-wrapper.properties configured in your intellij gradle settings.
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip
This can also occurs when you use a dependency that requires to be of type pom (to transitively add all dependencies, useful for BOMs) but without specifying it.
For example if you have a Spring Boot project and use that starter :
<dependency>
<groupId>org.zkoss.zkspringboot</groupId>
<artifactId>zkspringboot-starter</artifactId>
<version>${zkspringboot.version}</version>
</dependency>
Then mvn clean package will give you the following error :
Error: java: cannot access com.example.myproject
And running the app will result in the following error :
java: error reading ...\.m2\repository\org\zkoss\zkspringboot\zkspringboot-starter\2.3.0\zkspringboot-starter-2.3.0.jar;
zip END header not found
because it should not perform any packaging.
Adding the pom packaging type fixes the problem, so that it keeps the artifact simply as a descriptor of dependency versions :
<dependency>
<groupId>org.zkoss.zkspringboot</groupId>
<artifactId>zkspringboot-starter</artifactId>
<version>${zkspringboot.version}</version>
<type>pom</type>
</dependency>
Tweak file watching settings did the trick for me.
For Ubuntu/Mac Run these 2 commands.
sudo echo "fs.inotify.max_user_watches = 524288" | sudo tee /etc/sysctl.d/40-idea.conf
sudo sysctl -p --system
I had a similar issue when I used the dependency thymeleaf-extras-springsecurity4 from org.thymeleaf.extras in a spring boot application.
Updating the dependency to the latest version helped.
I am trying to build Eclipse BIRT (Oxygen/4.7.0 Release). But I am having difficulties and unable to proceed.
Steps I used:
Install Apache Maven 3.3.3 - since the build requires this version
Cloned the birt repository from Github
Checked out BIRT_4_7_0_Release_201706222054 tag
Executed mvn -DskipTests package in the root folder
Repositories on my local machine:
I have a clean m2 local repository (nothing in the repository)
I do use Eclipse Oomph to install various IDE (not projects) so bundle pools are present on my machine
Environment:
I am using JDK 1.8 (build 144) on macOS (10.11.6).
Result:
Cannot resolve project dependencies:
[ERROR] Software being installed: org.eclipse.birt.designer 4.7.0.qualifier
[ERROR] Missing requirement: org.eclipse.birt.feature.group 4.7.0.qualifier requires 'org.eclipse.gef.feature.group 3.2.0' but it could not be found
[ERROR] Cannot satisfy dependency: org.eclipse.birt.designer 4.7.0.qualifier depends on: org.eclipse.birt.feature.group 0.0.0
[ERROR]
Miscellaneous:
I also tried building for neon but that fails because the release milestones have moved and resolution fails (even after I change the release milestones URL).
Any help would be much appreciated. Thanks!
There are two separate issues in the build.
Firstly, it seems that the latest release tagged BIRT_4_7_0_Release_201706222054 has URLs and a feature that are out-of-date (as of the date of this answer). Building this revision will fail.
The solution is to build revision:
Update repository URL post Oxygen (1b32db99608d028b2cfabf65aa4a34a2c7ff3359).
Another option would be to cherrypick the following three fixes (all changes) on top of the release revision BIRT_4_7_0_Release_201706222054. This avoids all other changes that were made post Oxygen Release.
1b32db99608d028b2cfabf65aa4a34a2c7ff3359
92f2f74916bf6e2fa961285dcc0f5eaa7d2c50e2
eb8c612fc0ed0547601b5d1f9221755a44730abc
The second problem is Maven related. The top-level POM.xml requires definition of a toolchains. This needs to be defined in ~/.m2/toolchains.xml file or specified on the command-line with --global-toolchains. you can read about this in the Maven documentation here.
Lastly, the build requires Maven 3.3.3 as per Ben Gamble here. It did cause me a problem initially because I had 3.5.0 (prior to posting the question; mentioning this here for completeness).
Hope this will help anyone having similar problems.
I'm trying to use the scala-maven-plugin:3.1.0 with Java 1.5. However my maven build is failing with an incompatibility error.
Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.1.0:compile (scala-compile-first) on project proj: Execution scala-compile-first of goal net.alchim31.maven:scala-maven-plugin:3.1.0:compile failed: Unable to load the mojo 'compile' in the plugin 'net.alchim31.maven:scala-maven-plugin:3.1.0' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: Bad version number in .class file
There is also an unsupported class version warning
WARNING: Error injecting: scala_maven.ScalaCompileMojo
java.lang.UnsupportedClassVersionError: Bad version number in .class file
The documentation for the plugin says that it requires Java 1.5 so i dont see a problem there. I'm using Java 1.5 locally and also for my maven build.
Any suggestions to where the problem is? I cant see where another version of Java could be used to compile any of my classes so I'm guessing its an incompatibility in one of the dependencies i have but I've had no luck finding it. I'm also importing the following dependency
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.9.0-1</artifactId>
<version>2.0.M5</version>
</dependency>
Answer as posted by #om-nom-nom
As far as I know, scala version scalatest was compiled against (2.9.x) require at least 1.6 version of Java platform.
I recently tried to use maven-release-plugin since it is apparently the recommended way of building and packages releases in the Maven universe.
However I wanted to use this within Eclipse, as the rest of my development workflow is Eclipse based. I normally run Maven commands via the m2eclipse plugin provided as part of Eclipse Juno (4.2)
I noticed a few oddities when I tried to run "release:prepare" within Eclipse:
Some extra files were created in the root project directory - "pom.xml.releaseBackup" and "release.properties". Do they really belong there? Have I got the release directories set up correctly? I wouldn't really consider these temporary artifacts as part of my source code tree......
The pom.xml gets manually overwritten with the updated release number. Eclipse warns you and is happy to reload the updated version - but is this generally safe?
The prepare ultimately fails giving the error [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.0:prepare (default-cli) on project clisk: Failed to invoke Maven build. Error configuring command-line. Reason: Maven executable not found at: C:\Users\Mike\git\clisk\EMBEDDED\bin\mvn.bat -> [Help 1] - presumably because I am using the built-in Maven excetable provided by m2eclipse rather than the command line. I guess I could install command line maven as well.... but is that sensible or will it just cause more problems?
Given these kind of issues, Is there a way to get maven-release-plugin to work smoothly within Eclipse, or should I just give up and continue to do releases manually?
I have been using release plugin, but only from command line.
Re. 1. The backup files that release plugin creates are needed if something goes wrong in time of preparing the release. You can always rollback the prepared release using release:rollback command. When you do release:perform they will be deleted.
Re. 2. The plugin changes the version number from snapshot version for example: 0.0.1-SNAPSHOT: to release version: 0.0.1. Then after release:perform release version is moved to the maven repository and release plugin changes version again to 0.0.2-SNAPSHOT. Now you can use you full released (tested) version in your testing or production enviornment and snapshot version for developping purposes.
Re. 3. I don't know what is causing the problem, but I don't see the problem by using release plugin from command line.
Also mvn 3.3.3 installs a mvn.cmd file, instead of a mvn.bat file in Windows.
You should copy mvn.cmd to mvn.bat
Well i know this link is OLD , but to help some on who reffers this link for the issue 3.
Install maven separately on to local Box and give the path of the installation under Windows->Preferences--> maven--> Installation. Also you have to define the same in the run configuration within the Eclipse.
Attached is a link that explains the same.
http://maven.40175.n5.nabble.com/Build-Failure-prepare-release-td510949.html
You might be able to overcome the error you mention by installing command line Maven and configure Eclipse to use that rather than the embedded one by choosing Window -> Preferences -> Maven -> Installations, but I agree with the advice of making your releases outside Eclipse.