Protoc Version 3.2 java files - maven

I have compiled my Protoc file using protoc 3.2 compiler. When i try to use it with maven dependency shown below, POM file is giving me error and all of the dependencies were not resolved. Wondering what is the right version of grpc-all i should be using that is compatible with Java code generated with protoc compiler 3.2.0
My pom file looks like:
<dependencies>
<!-- https://mvnrepository.com/artifact/io.grpc/grpc-all -->
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-all</artifactId>
<version>1.3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
Also, the error i am getting is,

Turn out to be Maven issue,
Maven clean
Maven install fix that for me.

Related

How to fix maven plugin errors on jenkins?

I'm setting up a maven project on Jenkins, and I tried to build it, but I got errors on
Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:3.1.0:clean (default-clean) on project BankSystem: Failed to clean project: Failed to delete /Users/lilyli/Documents/IntelliJ-wrokspace/BankSystem/target/surefire-reports/TEST-com.lily.project.AppTest.xml -> [Help 1]
I tried to update the pom.xml file by adding dependencies about
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
</dependency>
and I also attached java JDK version on the plugin:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
Can I get any hints to debug it?
This is not a Maven problem. Please remove the unnecessary dependencies you added.
Instead, the file cannot be deleted. It might be used by another program that is still running or the user in Jenkins might not have the rights to do it.

Lombok with Netbeans/Maven Annotations are not Recognized/Working

I tried to update my existing Lombok version 1.16.16 to 1.18.2 in Netbeans 8.2 (maven multi-module project).
Unfortunately, all versions higher than 1.16.18 are not working. No annotation is recognized and I get compile errors in the IDE. The pure maven build is working.
You have to configure the maven compiler plugin. Add the following snippet to the build section of your pom (at best to your parent pom or to each project which is using Lombok).
If you already have a configuration of the build plugin in your pom make sure to add the <annotationProcessorPaths> section.
This will ensure that Lombok is available during the compiling process to manipulate the AST.
pom.xml - snippet
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.2</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
...

Error when using groovy-eclipse-plugin and #Grab

Getting the following error when running mvn clean compile on a new system. It works fine on my local (windows) environment.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project visa-threatintel: Compilation failure: Compilation failure:
[ERROR] /path/to/Class.groovy:[2,2] 1. ERROR in /path/to/Class.groovy (at line 2)
[ERROR] #Grab(group="javax.mail", module="mail", version="1.5.0-b01", type="jar"),
[ERROR] ^^^
[ERROR] Groovy:Ambiguous method overloading for method org.apache.ivy.core.settings.IvySettings#load.
Both local and new system use Maven 3.2.5 and the POM is identical. Relevant excerpts below:
<groovy.version>2.2.1</groovy.version>
<ivy.version>2.4.0</ivy.version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<extensions>true</extensions>
<configuration>
<!-- http://maven.apache.org/plugins/maven-compiler-plugin/ -->
<source>1.6</source>
<target>1.6</target>
<compilerId>groovy-eclipse-compiler</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.9.0-01</version>
</dependency>
<!-- 2.2.1 version isn't available as a release, so it needs to be acquired
from the codehaus nexus repository -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>${groovy.version}-01-SNAPSHOT</version>
</dependency>
<!-- to allow #Grab annotations -->
<dependency>
<groupId>org.apache.ivy</groupId>
<artifactId>ivy</artifactId>
<version>${ivy.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/groovy</source>
</sources>
</configuration>
</execution>
I tried changing groovy version to 2.4.3 but got the same error. Anyone seen anything like this before?
Having just encountered a similar issue, I found that I had two issues:
Maven deps that failed a download
A maven dependency (maven-assembly-plugin) had failed a download.
Deleting the .lastUpdated files in your local m2 repository:
#> find ~/.m2/repository -name *.lastUpdated
~/.m2/repository/org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-5/maven-assembly-plugin-2.2-beta-5.pom.lastUpdated
#> find ~/.m2/repository -name *.lastUpdated -delete
grapeConfig.xml & repository ssl certificate
Also your ~/.groovy/grapeConfig.xml file needs to be configured to tell groovy where to pull the dependencies from - in my case it was from a corporate nexus repository, which also meant i had to install the https certificate in the JRE cacerts file.
How to test
One suggestion to test you have everything set up correctly would be to call grape install on a test dependency and that will give you a clearer sense of what is wrong (grape is distributed as part of the groovy binaries, so include it on your path, or fully qualify its path):
grape install javax.mail mail 1.5.0-b01

flexmojos ignoring configuration?

I am trying to build out a SWC file from a Flex library, and no matter what I do, flexmojos (3.6.1) seems to build a "config.xml" file in the bin/classes folder that is empty, and uses that for configuration, completely ignoring everything I put into the plugin > configuration element. I've tried it running command line, through m2e, and through Jenkins and I get the same problem every time. I'm stuck and I don't know what I'm doing wrong.
Here is the build portion of my POM.
<sourceDirectory>${basedir}/src</sourceDirectory>
<directory>${basedir}/bin</directory>
<plugins>
<plugin>
<groupId>org.sonatype.flexmojos</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<version>3.6.1</version>
<extensions>true</extensions>
<dependencies>
<dependency>
<groupId>com.adobe.flex</groupId>
<artifactId>compiler</artifactId>
<version>${flex.version}</version>
<type>pom</type>
</dependency>
</dependencies>
<configuration>
<computeDigest>false</computeDigest>
<allowSourcePathOverlap>true</allowSourcePathOverlap>
<debug>false</debug>
<warnings>
<no-constructor>false</no-constructor>
</warnings>
</configuration>
</plugin>
</plugins>
Turns out I was running an older compile-swc target. When I flipped over to the new target I was fine. the m2e Eclipse plugin did not provide me the choice to select the latest target in their build configuration settings.

Maven Install: "Annotations are not supported in -source 1.3"

When running mvn install on my project, i see it fail due to the following errors:
C:\Repositories\blah\src\test\java\com\xxx\qm\testrunner\test\ATest.java:[11,5] annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
#Test
C:\Repositories\blah\src\test\java\com\xxx\qm\common\test\BTest.java:[11,5] annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
#Test
My Maven dependency includes jUnit 4.8, however and has no reference to 1.3 anything.
What would cause these errors? Please advise
You need to specify the source version of your maven project through the use of the maven-compiler-plugin. Add the following to your pom build element and set the appropriate java source and target levels.
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
http://maven.apache.org/plugins/maven-compiler-plugin/
A shorter version:
<project>
<properties>
<maven.compiler.source>1.5</maven.compiler.source>
<maven.compiler.target>1.5</maven.compiler.target>
</properties>
....
You are most likely using OpenJDK where the source level is 1.3 when not explicitly set - as opposed to Oracle JDK where the source level is 1.5.
Since most modern Java projects target newer code than Java 5 you most likely need to set this anyway.
Also note that if you need a lower target than source (e.g. for compiling with Java 6 but deploying to Java 5) you can do this by using the Eclipse compiler instead of Javac.
Bu default, the maven tries to compile using Java 1.3 version. I hope most of them hit this error because of missing to tell maven that "Hey Maven, Dont use 1.3 and use "whatever_version_I_give"
This can be mentioned in pom.xml as below :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
In my above example, I have used 1.7. Please replace with whatever version you wish to.
Add this in your pom
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<!-- put your configurations here -->
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

Resources