I am updating a Spigot (Minecraft) plugin and the newest version of Spigot requires Java 16. In my pom I changed the maven compiler plugin target to 16 and the source is still 1.8. Now I am getting the following errors:
Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade (default) on project Plugin: Error creating shaded jar: Problem shading JAR C:\Users\Trent\workspace\Stocks\Plugin\target\Plugin-1.0-SNAPSHOT.jar entry com/tchristofferson/stocks/commands/StockbrokerCommand.class: java.lang.IllegalArgumentException: Unsupported class file major version 60
pom:
<?xml version="1.0" encoding="UTF-8"?>
4.0.0
<groupId>com.tchristofferson</groupId>
<artifactId>Stocks</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>API</module>
<module>Plugin</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>16</target>
<release>16</release>
</configuration>
</plugin>
</plugins>
</build>
<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>
I had to use this before I could use 3.3.0-SNAPSHOT
<pluginRepositories>
<pluginRepository>
<id>maven-snapshots</id>
<url>https://repository.apache.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepositories>
#wemu was correct that the maven shade plugin doesn't yet support Java 16. To solve the issue I had to use a snapshot version of the maven shade plugin (3.3.0-SNAPSHOT) since 3.2.4 doesn't support Java 16 yet.
To elaborate on the answer #tchristofferson has given, I got it working by setting snapshots to true in my pluginRepository:
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
</pluginRepository>
</pluginRepositories>
If you don't have the above in your pom.xml, just add it somewhere within <project></project>.
And then change the version of the maven-shade-plugin to this:
<version>3.3.0-SNAPSHOT</version>
In my case, the latest version of maven was installed on my machine, and code was intended for the java 11 version. So I have used an older version of maven and the error didn't appear.
FWIW...
You could also override the version of ASM, in order to make this work with maven-shade-plugin 3.2.x, like so:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>9.2</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<version>9.2</version>
</dependency>
</dependencies>
...
</plugin>
References:
https://issues.apache.org/jira/browse/MSHADE-407
Related
Not sure how to fix this.
I want this version of the Kotlin runtime and maven plugin.
These are the bits in my pom.xml:
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-runtime</artifactId>
<version>1.2-M2</version>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>1.2-M2</version>
<executions>
And I added this as a repo:
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>kotlin-bintray</id>
<name>Kotlin Bintray</name>
<url>http://dl.bintray.com/kotlin/kotlin-dev/</url>
</repository>
I get this error:
Failure to find
org.jetbrains.kotlin:kotlin-maven-plugin:jar:1.2-M2 in
https://repo.maven.apache.org/maven2 was cached in the local
repository, resolution will not be reattempted until the update
interval of central has elapsed or updates are
forced
But I don't see anything that might be wrong.
By the way, notice that the runtime jar is found, so the repository section must be correct since this repository is where maven finds it. The maven plugin jar is a different matter for some reason though...
I just fixed. It was something really silly. I found out that for plugins one needs to define a plugin repository section.
<pluginRepositories>
<pluginRepository>
<id>kotlin-bintray</id>
<name>Kotlin Bintray</name>
<url>http://dl.bintray.com/kotlin/kotlin-dev</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
And now it works. I guess I should spend more time learning maven in depth :)
To make sure it downloads fresh from maven central you will need to blow away your local copy, so delete the directory:
~/.m2/repo/org/jetbrains/kotlin/kotlin-maven-plugin
You will also need to add the 3rd party repo to your settings.xml at ~/.m2 see here
<settings>
...
<profiles>
...
<profile>
<id>myprofile</id>
<repositories>
<repository>
<id>my-repo2</id>
<name>your custom repo</name>
<url>https://dl.bintray.com/kotlin/kotlin-dev/</url>
</repository>
</repositories>
</profile>
...
</profiles>
<activeProfiles>
<activeProfile>myprofile</activeProfile>
</activeProfiles>
...
</settings>
At the documentation, we can see how to implement Compiler Plugins
For kotlin-allopen add the followin <configuration> and <pluginOptions> inside the <plugin> tag
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<configuration>
<compilerPlugins>
<!-- Or "spring" for the Spring support -->
<plugin>all-open</plugin>
</compilerPlugins>
<pluginOptions>
<!-- Each annotation is placed on its own line -->
<option>all-open:annotation=com.my.Annotation</option>
<option>all-open:annotation=com.their.AnotherAnnotation</option>
</pluginOptions>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
i just added this line and it worked for me
<version>${kotlin.version}</version>
I am trying to publish my plugin to the pluginrepository on OSS-SonaType. They have already provisioned my namespace for both snapshots and full releases. I am struggling to make my first initial commit to the repo. I can't seem to find the right Maven Configuration to push the plugin to the repo rather than trying to update the repo. Below find my pom.xml, and maven configuration code. Any help would be greatly appreciated!
Pom.xml:
<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.companynamehere.dmweb</groupId>
<artifactId>DMWeb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>DMWeb</name>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.0.2.RELEASE</version>
</dependency>
</dependencies>
<pluginRepositories>
<pluginRepository>
<id>OSS-Repo</id>
<name>oss-repo</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
Maven Config:
Goals: com.companynamehere:DMWeb:validate
Error:
Error resolving version for plugin 'com.companynamehere:DMWeb' from the repositories [local (C:\Users\kylec\.m2\repository), OSS-Repo (https://oss.sonatype.org/content/repositories/snapshots), central (https://repo.maven.apache.org/maven2)]: Plugin not found in any plugin repository -> [Help 1]
I have a artificact deployed in JCenter (oss.jfrog.org) although the deployment did not end without error (see Deploy SNAPSHOT to oss.jfrog.org (JCenter)), the jars are there when I check the Repository browser.
Now I add the dependency in a project for this artifact (library) and adding:
<repositories>
<!-- Release repository -->
<repository>
<id>oss-jfrog-artifactory-releases</id>
<name>oss-jfrog-artifactory-releases</name>
<url>http://oss.jfrog.org/artifactory/oss-release-local</url>
</repository>
<!-- Snapshot repository -->
<repository>
<id>oss-jfrog-artifactory-snapshots</id>
<name>oss-jfrog-artifactory-snapshots</name>
<url>http://oss.jfrog.org/artifactory/oss-snapshot-local</url>
</repository>
</repositories>
When maven started building, it throws this error:
Failed to transfer file: http://oss.jf
rog.org/artifactory/oss-release-local/com/myorg/mylibrary/0.0.1-SNAPSHOT/mylibrary-0.0.1-SNAPSHOT.pom. Return code is: 409, ReasonPhrase:Conflict. -> [Help 1]
for the dependency I added. What could be the problem here?
Try using the virtual repositories
<repositories>
<!-- Release repository -->
<repository>
<id>oss-jfrog-artifactory-releases</id>
<name>oss-jfrog-artifactory-releases</name>
<url>http://oss.jfrog.org/artifactory/libs-release</url>
</repository>
<!-- Snapshot repository -->
<repository>
<id>oss-jfrog-artifactory-snapshots</id>
<name>oss-jfrog-artifactory-snapshots</name>
<url>http://oss.jfrog.org/artifactory/libs-snapshot</url>
</repository>
</repositories>
I have a workaround. No idea why, but in my case adding shade plugin to all modules solved the problem, even an empty one:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<artifactSet>
</artifactSet>
<relocations>
</relocations>
</configuration>
</plugin>
</plugins>
</build>
When i fetched qt jambi jars from maven repository i found that there is no javadocs in it.
Downloading javadocs in maven didn't help.
My pom.xml:
<dependencies>
<dependency>
<groupId>net.sf.qtjambi</groupId>
<artifactId>qtjambi</artifactId>
<version>4.6.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.sf.qtjambi</groupId>
<artifactId>qtjambi-maven-plugin</artifactId>
<configuration>
<!-- Specifies where sources are. This parameter is MANDATORY -->
<sourcesDir>src/main/java</sourcesDir>
<!-- following parameters aren't mandatory, they use defaults as specified
here if not specified <translationsDir>src/main/resources/translations</translationsDir>
<destinationDir>target/generated-sources/qtjambi</destinationDir> -->
<!-- cause -noobsolete switch for lupdate -->
<noObsoleteTranslations>true</noObsoleteTranslations>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>qtjambi</id>
<name>qtjambi</name>
<url>http://qtjambi.sourceforge.net/maven2/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>qtjambi</id>
<name>qtjambi</name>
<url>http://qtjambi.sourceforge.net/maven2/</url>
</pluginRepository>
</pluginRepositories>
I've tried to download jar manually, but there is still no javadoc in it.
http://repository.qt-jambi.org/nexus/content/repositories/releases-before-2011/net/sf/qtjambi/qtjambi-maven-plugin/4.6.3.1/ should contains qtjambi-maven-plugin-4.6.3.1-javadoc.jar. It's not there, so file a request at that project that they upload there javadocs as well.
I am going through this guide:
https://spring.io/guides/gs/rest-service/
I use Maven for building, so I've fetched the pom.xml linked in the official Spring guide:
https://github.com/spring-guides/gs-rest-service/blob/master/initial/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>
<groupId>org.springframework</groupId>
<artifactId>gs-rest-service</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>
<properties>
<start-class>hello.Application</start-class>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-build</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/libs-snapshot</url>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>spring-repo</id>
<name>Spring Repository</name>
<url>http://repo.spring.io/release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/libs-snapshot</url>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</project>
I get the following error when running mvn install
[ERROR] Error resolving version for plugin
org.springframework.boot:spring-boot-maven-build' from the
repositories [local (C:\Users\Laszlo_Szucs.m2\repository),
spring-snapshots (repo.spring.io/libs-snapshot), central
repo.maven.apache.org/maven2)]: Plugin not found in any plugin
repository -> [Help 1]
How do I know which version to provide in the pom.xml for this?
Check whether http://repo.spring.io/libs-snapshot is in pom.xml. If not, Add http://repo.spring.io/libs-snapshot to maven repository.
<repository>
<id>spring-repo</id>
<name>Spring Repository</name>
<url>http://repo.spring.io/release</url>
</repository>
And upgrade the maven to 3.0.5 above.
In my case, removing the ~/.m2/repository/org/springframework/boot folder and then cleaning the project resolved the issue. After this issue, I also faced another issue in which STS complained that my maven project was not updated. However, right clicking on the issues in the Markers area and selecting Quick Fix popped up a window which prompted me to update the maven projects. Selecting the projects and clicking the update button in this window resolved the issue.
I specified d goals as "spring-boot:run" (without quote) it works for me
procedure: right click on myproject>run as >run configurations >click on mavenbuild>goals(specify goal name)>run