irkb
irkb

Reputation: 369

java.nio.file.NoSuchFileException: /target/classes/META-INF/annotations/hudson.Extension when building Jenkins plugin

I have found a plugin for using StatsD with Jenkins (https://github.com/joemiller/jenkins-statsd-plugin) - however the HPI needs building because it is not available in Jenkins plugin repository nor is it aailable to download.

I followed the official instructions at https://wiki.jenkins.io/display/JENKINS/Plugin+tutorial, but the $ mvn package always exits with [ERROR] java.nio.file.NoSuchFileException: ~/src/jenkins-statsd-plugin/target/classes/META-INF/annotations/hudson.Extension.

I have tried using java 6, 7, 8 and 10 but to no avail.

I wonder if anybody else has come up against this problem building Jenkins plugins and what they're solution was?

Upvotes: 3

Views: 6846

Answers (3)

Shubham Arya
Shubham Arya

Reputation: 135

This will definitely get resolved by using java 1.8.* JDK.

Upvotes: 1

‌‌R‌‌‌.
‌‌R‌‌‌.

Reputation: 2954

I would like to post here my findings from various sources that worked for me as the accepted answer alone was not sufficient.

  • I had to downgrade my Java version back to 11 from 13. I used this quick solution, which doesn't require you having JDK and Maven installed locally.

  • Moreover, deleting target/classes/META-INF/ directory before executing mvn install again was necessary.

  • Lastly, passing -Djenkins.version parameter to Maven is required so you need to do something like mvn -Djenkins.version=2.164 install

Upvotes: 5

irkb
irkb

Reputation: 369

I fixed this problem by setting JAVA_HOME to point to Oracle’s version of Java 8. It appears maven uses the JAVA_HOME environment variable, not your $PATH.

Edit: For extra context, Jenv was responsible for the version of Java in my $PATH.

Upvotes: 16

Related Questions