how to solve /bin/sh: protoc: command not found? - java

I have installed protobuf 2.5.0 in my CentOs,
when i execute the command protoc --version, it yields
libprotoc 2.5.0
as output.
but Once I have pulled code from git and when I try to compile it using Maven3, the proto module throws error saying,
protoc failed error: /bin/sh: protoc: command not found
I refereed many blogs and also did try to change my bashrc path as follows,
export JAVA_HOME=/opt/java/jdk1.7.0_67
export PATH=$PATH:/opt/java/jdk1.7.0_67/bin
export PATH=$PATH:/usr/local/lib
but if I execute,
sudo yum install protobuf-compiler
it installs protobuf2.3 compiler and this particular error gets solved. But since my pom file has protobuf 2.5.0, java abstract method error arises during the next compilation. I'm stuck on how to proceed. I've spend many hrs in it, so any help is much appreciated.
my pom file for the proto module,
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>GradPower</artifactId>
<groupId>org.screative.gardpower</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>proto</groupId>
<artifactId>proto</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.5.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.google.protobuf.tools</groupId>
<artifactId>maven-protoc-plugin</artifactId>
<version>0.1.10</version>
<configuration>
<protocExecutable>protoc</protocExecutable>
<protoSourceRoot>${project.basedir}/src/main/proto/</protoSourceRoot>
<languageSpecifications>
<LanguageSpecification>
<language>JAVA</language>
<outputDirectory>
${project.basedir}/target/generated-sources/protoc
</outputDirectory>
</LanguageSpecification>
</languageSpecifications>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument></compilerArgument>
</configuration>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>dtrott</id>
<url>http://maven.davidtrott.com/repository</url>
</pluginRepository>
</pluginRepositories>
</project>
Thanks in advance.
EDIT:
I solved it. I copied protoc file from /usr/local/lib to /usr/bin
and it solved it. A silly mistake :P

You should run 'sudo ldconfig' to finish the installation.
I guessed you set LD_LIBRARY_PATH to add /usr/local/lib in your environment setting. And it doesn't take effect when building project with maven/sbt and other build tools.

Answer extracted from the Question (written by OP):
I solved it. I copied protoc file from /usr/local/lib to /usr/bin
and it solved it.

Related

Compiling mysql dependincy with maven Spigot

I personally prefer to keep my coding problem off of here unless I think I'm stumped. I'm trying to add the mysql java dependency to my project (I'm coding a Minecraft-Spigot 1.12.2 plugin).
I've been coding MySQL for years but I've never had to use it with Java until now so I'm following this tutorial: https://www.spigotmc.org/wiki/connecting-to-databases-mysql/
Which redirected me to this page: https://mvnrepository.com/artifact/mysql/mysql-connector-java/8.0.26
Naturally adding a Maven dep is easy enough you just copy and paste it! Beyond that, I'm not very in tune with the inner workings of the system.
Whenever I compile (it does in-fact compile without throwing any fits) and upload it to my servers I get this error: java.lang.NoClassDefFoundError: com/mysql/cj/jdbc/MysqlDataSource. Now, I know that this has to do with the class being undefined or something. So obviously, I searched the error code. A lot of the problems I saw didn't seem to apply to me.
I double checked and I DO see mysql-connector-java inside of my "External Libraries" section in my IDE (InteliJ IDEA)
I also saw some people sending this link: How can I create an executable JAR with dependencies using Maven?
Which, the answer didn't seem to help me out either (unless I missed something).
My hope is that by sending my file someone can help me out here?
I've seen some people mention that it could be a problem with a classpath? How exactly can I go about fixing that (if it is the problem). I couldn't seem to find anything to help me with that problem (tho in this case classpath is a little over my head. Def want to read up on it more in the future).
Here's my pom.xml any helpful assistance is appreciated!
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>example</artifactId>
<version>1.12.2-SNAPSHOT</version>
<packaging>jar</packaging>
<name>example</name>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/repository/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.6.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.25</version>
</dependency>
</dependencies>
</project>
Did you use the right SNAPSHOT jar? Because that should work for you and
jar tf <the snapshot>.jar | find "com/mysql/cj/jdbc/MysqlDataSource"
on Windows or
jar tf <the snapshot>.jar | grep "com/mysql/cj/jdbc/MysqlDataSource"
on *nix should find that 'missing' class in the jar

Plugin 'org.apache.maven.plugins:maven-compiler-plugin:3.7.0' not found

I have just started with java dev. I am given a task of doing object serialization of avro format. I have broken my head trying different methods. The different IDEs and different tools, none of which have I been able to use to solve the issue, moreover they have made everything more complex and frustrating. I tried following a tutorial which didnt use an IDE per say but that was also unsuccessful as the Serialize.java class wasnt compiling. I'm presently trying to achieve the task using maven plugins and dependencies. I have just made a new Maven project on Intellij. This is my pom.xml where I have pasted the dependencies and plugins for avro format:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>avroTrial2</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>1.10.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.10.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
</goals>
<configuration>
<sourceDirectory>${project.basedir}/src/main/avro/</sourceDirectory>
<outputDirectory>${project.basedir}/src/main/java/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
</project>
The second plugin shows an error, I have done the maven syncing on intellij and thats how the error from first plugin was rectified. Now the error being shown is : "Plugin 'org.apache.maven.plugins:maven-compiler-plugin:' not found". I need to deal with this error first before I can go and get stuck on some avro error after this.
This might be the reason behind it. The configuration part in the maven compiler plugin section and the properties basically do the same thing. You have configured twice and with different versions. It should be either one of them and in general should match with the java version you are using (more details could be found here.
This is not matching
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
with
<properties>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
and only use one of them.
I have encountered same problem so what I did to resolve it is:
Navigated to File->Settings in IntelliJ
Select Plugin from left bar and then I unchecked Maven plugin
Restarted the IDE
Again clicked on Plugin and checked Maven
Restarted the IDE

unable to satisfy dependency from com.lmax.disruptor 3.2.0 to package sun.misc 0.0.0

I am developing an eclipse plugin which needs an com.lmax.disruptor.It imports sun.misc. I have this in my p2 repository but when I maven build my plugin I am getting this error "unable to satisfy dependency from com.lmax.disruptor 3.2.0 to package sun.misc 0.0.0."
I have gone through the sites Resolve a dependency on package sun.misc with Tycho they are saying to create a plugin fragment but when I tried to create it and added export page as sun.misc, It is throwing an error like "package sun.misc doesnot exsist in the plugin".
How can solve this issue please help me with this.? Instead of creating new plugin fragment,is there is any possible way i can add in my plugin itself ?
Thanks,
As mentioned in oberlies' answer in the question you link to, you need to build a system bundle fragment, which exposes, i.e., exports, the sun.misc package. I don't know of any other way. However, this is easier than could be expected.
You do this by creating an OSGi MANIFEST.MF that exports sun.misc, and then bundle it into a fragment. This is done via Maven as follows.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>your.group</groupId>
<version>1.0.0</version>
<artifactId>your.group.fragment.sun.misc</artifactId>
<packaging>jar</packaging>
<name>System Bundle Fragment exporting sun.misc</name>
<description>This bundle extends the System Bundle export list with the sun.misc package such that OSGi bundles may refer to Sun's misc implementation without the OSGi framework itself to provide it in a non-portable way.</description>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<forceCreation>true</forceCreation>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifestEntries>
<Export-Package>sun.misc</Export-Package>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.5.4</version>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
<configuration>
<instructions>
<Bundle-Category>your.group</Bundle-Category>
<Fragment-Host>system.bundle; extension:=framework</Fragment-Host>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
Run mvn clean install on this POM. Now you need to make the fragment consumable for Tycho, i.e., you need to make it available via a p2 Software Site.
Thankfully there is a great Maven plugin which can help with that: reficio's p2-maven-plugin. You can use it to basically wrap any mavenized JAR into an OSGi bundle and then provide it via a p2 site.
Set up the respective POM as follows.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sun-misc-p2</groupId>
<artifactId>site</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.reficio</groupId>
<artifactId>p2-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<artifacts>
<!-- specify your depencies here -->
<!-- groupId:artifactId:version -->
<artifact><id>com.lmax:disruptor:3.3.2</id></artifact>
<artifact><id>your.group:your.group.fragment.sun.misc:1.0.0</id></artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.5.v20120716</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppSourceDirectory>${basedir}/target/repository/</webAppSourceDirectory>
<webApp>
<contextPath>/site</contextPath>
</webApp>
</configuration>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>reficio</id>
<url>http://repo.reficio.org/maven/</url>
</pluginRepository>
</pluginRepositories>
</project>
Note that I use this plugin to provide the LMAX Disruptor (version 3.3.2, the latest one at the time of writing, is thankfully available from Maven Central).
Run mvn p2:site on the POM. This will create a p2 site containing the sun.misc fragment at {project-folder}/target/repository.
This p2 repository - and with it the sun.misc fragment - can now be added to your target platform, and hence used in your Tycho build.
This should fix it, and - to answer your question if "there is any possible way [you] can add in [your] plugin itself" - this is the only possible way to do it (I know of).
The sources are also available at https://github.com/newcodeontheblock/eclipse-rcp-with-async-logging. The whole procedure is also described in more detail in this - my - blog post about using async Log4j 2 loggers in an Eclipse RCP.

How to manually publish JAR to maven central?

I have created an open source project that I'd like to publish to maven central so that the users can use the library by simply referencing it in their pom. Like so:
<dependency>
<groupId>in.ksharma</groupId>
<artifactId>log4j-weblayout</artifactId>
<version>0.0.1-BETA</version>
</dependency>
I've found several online tutorials, but some of them are out of date, some recommend automating the entire process and thereby overtly complicate it.
For example one tutorial recommended creating SSH keys for your github account and having maven automatically create a git tag whenever pushing to maven central. Though this is useful it is not necessary to get started.
Another example, trying to release it directly through maven also gives some kind of error:
mvn release:clean release:prepare release:perform -B -e | tee maven-central-deploy.log
Gives:
svn: E155007:
'/home/kshitiz/Documents/workspaces/ggts/log4j-weblayout/pom.xml' is
not a working copy
When you're doing something for the first time it often helps to do it manually first and then automate it.
What is the most basic, bare-bones way to put a JAR in maven central?
1) Create your Jira account : Signup Sonatype
2) Create a new project ticket (to claim your workspace) : Create new project ticket
3) Generate a PGP Signature
gpg2 --gen-key
....
gpg: key YOUR_KEY_ID marked as ultimately trusted
...
4) Distributing your public key
gpg2 --keyserver hkp://pool.sks-keyservers.net --send-keys YOUR_KEY_ID
Distribute your key to multiple servers to speed up the synchronization process (pgp.mit.edu, keyserver.ubuntu.com...)
5) Update your ~.m2/settings.xml
<settings>
<servers>
<server>
<id>ossrh</id>
<username>jira_username</username>
<password>jira_password</password>
</server>
</servers>
<profiles>
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.executable>gpg2</gpg.executable>
<gpg.passphrase>your_key_passphrase</gpg.passphrase>
</properties>
</profile>
</profiles>
</settings>
6) Update your project pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>9</version>
</parent>
<groupId>xxx.xxx</groupId>
<artifactId>xxx</artifactId>
<version>0.1</version>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</project>
7) Run Maven
Maven will ask you for your passphrase
mvn clean deploy
8) Comment your Jira ticket
This will trigger the synchronization with central for your group id.
I have promoted my first release. Thanks.
Resources :
OSSRH Guide
Deploy with Maven
PGP Signatures
This answer assumes that you have a maven based project and that it is in a package-able state. mvn package should run without any errors.
When publishing to maven central you'll need to use a group id that would identify all artifacts uploaded by you. Something like in.ksharma. You'll also need to sign your artifacts so that the users are able to verify that they're actually coming from you.
So first go to sonatype jira and create an account, and then create a jira issue to have your group id approved. Something like this.
Now generate a gpg keypair for signing your artifacts:
$ gpg --gen-key
Define this key in ~/.m2/settings.xml:
<profiles>
<profile>
<id>sonatype-oss-release</id>
<properties>
<gpg.keyname>B63EFB4D</gpg.keyname>
<gpg.passphrase>****</gpg.passphrase>
<gpg.defaultKeyring>true</gpg.defaultKeyring>
<gpg.useagent>true</gpg.useagent>
<gpg.lockMode>never</gpg.lockMode>
<gpg.homedir>/home/kshitiz/.gnupg</gpg.homedir>
</properties>
</profile>
</profiles>
Modify your project's pom file and append -SNAPSHOT to your version.
So 0.0.1-BETA becomes 0.0.1-BETA-SNAPSHOT. Otherwise maven would complain:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-release-plugin:2.4.2:prepare
(default-cli) on project log4j-weblayout: You don't have a SNAPSHOT
project in the reactor projects list. -> [Help 1]
Also add:
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>9</version>
</parent>
This parent pom provides you with some ready made functionality like configuring the maven-gpg-plugin to sign your JAR.
Now run mvn release:clean release:prepare to generate your artifacts and gpg signature. It will give you something like:
log4j-weblayout-0.0.1-BETA-javadoc.jar.asc
log4j-weblayout-0.0.1-BETA-sources.jar.asc
log4j-weblayout-0.0.1-BETA.pom.asc
log4j-weblayout-0.0.1-BETA.pom
log4j-weblayout-0.0.1-BETA.jar.asc
log4j-weblayout-0.0.1-BETA-javadoc.jar
log4j-weblayout-0.0.1-BETA-sources.jar
log4j-weblayout-0.0.1-BETA.jar
Now package these into a single JAR:
jar -cvf bundle.jar log4j-weblayout-0.0.1-BETA*
Go to Sonatype Nexus and login with your credentials. Go to staging upload and upload your bundle.
Then go to staging repositories section, select your repository and click release (More help here). Comment on the jira issue that you have released the artifact and wait some time.
Now your users can search and use the artifact from the central repository:

Maven Plugin Build fails when Lambdas are used

I wrote a maven plugin/mojo to generate some code. The plugin works well, and is built in Java JDK 1.8.
I am seeing an odd bit of behavior though: It builds, installs, etc just fine if I use pre-1.8 syntax, but as soon as I use a Java 8 Lambda expression, I get the following error when executing mvn clean install:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-plugin-plugin:3.2:descriptor (default-descriptor) on project my-maven-plugin: Execution default-descriptor of goal org.apache.maven.plugins:maven-plugin-plugin:3.2:descriptor failed: 13557 -> [Help 1]
Here's my pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.my.group.id</groupId>
<artifactId>my-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>1.0-SNAPSHOT</version>
<name>My Maven Mojo</name>
<url>http://maven.apache.org</url>
<properties>
<org.springframework.version>4.0.1.RELEASE</org.springframework.version>
<joda-time.version>2.3</joda-time.version>
</properties>
<dependencies>
<!-- several dependencies -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- The following manual call to the maven-plugin plugin is necessary to get around a bug in maven 3.1.1.
If the build server gets updated to 3.2.2+ we can remove this -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.2</version>
<configuration>
<!-- see http://jira.codehaus.org/browse/MNG-5346 -->
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
<executions>
<execution>
<id>mojo-descriptor</id>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>inin-release</id>
<name>ININ Release Repository</name>
<url>http://nexus.infrastructure.inintca.com/nexus/content/repositories/inin-release</url>
</repository>
<snapshotRepository>
<id>inin-snapshot</id>
<name>ININ Snapshot Repository</name>
<url>http://nexus.infrastructure.inintca.com/nexus/content/repositories/inin-snapshot</url>
</snapshotRepository>
</distributionManagement>
</project>
The issue appears in this case when I attempt to use a lambda to define a FileFilter rather than the traditional anonymous inner class.
This works:
List<File> controllerFiles = Arrays.asList(packageDirFile.listFiles(new FileFilter()
{
#Override
public boolean accept(File file)
{
return file.isFile() && file.getName().endsWith(".java");
}
}));
While this produces the aforementioned error:
List<File>
controllerFiles =
Arrays.asList(packageDirFile.listFiles(file -> file.isFile() &&
file.getName().endsWith(".java")));
Obviously given that I have a workaround this isn't critical, but the lambda is much cleaner than the anonymous inner class IMO and given that I'm working in Java 8 I'd much prefer to use it. Anybody have any tips, particularly given that I've already set skipErrorNoDescriptorsFound to true?
The note on MPLUGIN-273 says lambdas work if the build is using maven-plugin-plugin version 3.3. The error message shown references maven-plugin-plugin version 3.2 . Make sure you're using the correct version of the plugin and see if that fixes the issue.
I just realized I answered my own question. In my second comment there's a link to a Maven Jira issue, in which somebody commented that upping the maven-plugin-plugin version to 3.3 from 3.2 fixes the issue, and after trying it I discovered the same. So this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.2</version>
...
</plugin>
becomes
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.3</version>
...
</plugin>
And the problem goes away.

Categories

Resources