maven: does not download extension written by myself - maven

I am not so deep into maven but had to write an extension.
I successfully deployed and it is present.
https://www.simuline.eu/RepositoryMaven/eu/simuline/qMngmnt/0.0.3/
Also the version fits.
But nevertheless, when trying to use,
Unresolvable build extension: Plugin eu.simuline:qMngmnt:0.0.3 or one of its dependencies could not be resolved:
eu.simuline:qMngmnt:jar:0.0.3 was not found in https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced
In my pom i have:
<repositories>
<repository>
<id>publicRepoAtSimuline</id>
<name>repo at simuline</name>
<url>https://www.simuline.eu/RepositoryMaven</url>
</repository>
</repositories>
and I use it at the following places:
<build>
<extensions>
<extension>
<groupId>eu.simuline</groupId>
<artifactId>qMngmnt</artifactId>
<version>0.0.3</version>
</extension>
...
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<!-- 8.15 has security issue ans seemingly line lengths are wrong -->
<version>10.1</version><!-- TBD: make 8.30, 9.1, 10.1 work -->
</dependency>
<dependency>
<groupId>eu.simuline</groupId>
<artifactId>qMngmnt</artifactId>
<version>0.0.3</version>
</dependency>
</dependencies>
...
<dependencies>
<dependency><!-- TBD: clarify: for spotbugs: necessary? -->
<groupId>eu.simuline</groupId>
<artifactId>qMngmnt</artifactId>
<version>0.0.3</version>
<!--scope>provided</scope-->
</dependency>
Interesting: if i build a new version, qMngmnt-0.0.4-SNAPSHOT
then of course it is locally installed, and all works fine.
So I have the impression, download never worked but i did not realize so far.
What is wrong?
By the way: I use another artifact as an artifact item
but neither as a dependency nor as an extension and it works just fine.

Related

How to add craftbukkit to minecraft 1.19.3 plugin as dependency?

I am trying to update a plugin [in 1.18.2] that I haven't written myself to minecraft 1.19.3.
However I am struggling with figuring out how to add craftbukkit as a dependency. I use maven and it seems to be unfindable for 1.19.3 in the mvnrepository.com. Further investigation led me to buildtools, which I ran and it did give me several folders and jar files, one of which is craftbukkit, spigot and bukkit.
However trying to add those jar files as dependencies also gave me errors of referencing to a non-existing file. Even though the file does exist in the resource folder of the project.
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.19.3-R0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>/GUIMarketplaceDirectory-master/src/main/resources/craftbukkit-1.19.3.jar</systemPath>
</dependency>
I also tried changing the path to start at my very source folder, but this didn't work. Any help would be appreciated.
I'm not sure you can add CraftBukkit as a dependency. It needs to be either bukkit, or spigot, since CraftBukkit is a server mod, not the plugin API. Here is code for a Spigot import.
<repositories>
<!-- This adds the Spigot Maven repository to the build -->
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!--This adds the Spigot API artifact to the build -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>

Prevent maven-shade-plugin from exposing <system> dependency?

Thanks to a separate thread, I realized my project's uber-jar had a bug. I create the uber-jar using maven-shade-plugin because I need the more advanced transformer capabilities to merge several ServiceLoader definitions.
So, the issue is that my project has a system-scope compile-time dependency on tools.jar, locating tools.jar on the local machine relative to the value of the java.home sysprop. The bug is that I didn't realize this dependency was:
leaking into the dependency-reduced pom.xml of the uber-jar, and
even worse, the pattern ${java.home} in the dependency definition was being resolved and hard-coded into the uber-jar's POM. This second part was particularly embarrassing as it reveals the JDK location of the build machine (see line 50 here).
To workaround this problem, I conditionally disabled the profile which created the dependency. All details below are in the <activation> section:
Before:
<profile>
<id>internal.tools-jar</id>
<activation>
<file>
<exists>${java.home}/../lib/tools.jar</exists>
</file>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.8.0</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
After:
<profile>
<id>internal.tools-jar</id>
<activation>
<jdk>1.8</jdk>
<file>
<missing>src/main/java/systems/manifold/Dummy.java</missing> <!-- this file is only present in the uber-jar module, therefore exclude if present -->
</file>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.8.0</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
So, after all that, my question is: is this the best way to prevent this system-scoped dependency from leaking into the uber-jar's dependency-reduced pom.xml?
Thanks in advance,
Kyle
Updated 2018-02-16:
Unfortunately the following configuration in the shade plugin doesn't prevent the system-scope dependency from leaking:
<artifactSet>
<excludes>
<exclude>*</exclude>
</excludes>
</artifactSet>
to the shade plugin's configuration but the resolved system scope dependency still shows up in the POM. Puzzling!

Compilation error in building maven project

we are trying to build and deploy a maven artifact into our Nexus Repository Manager from Jenkins, But we are facing compilation error during the build.
This is the error that we are getting.!
ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile
(default-compile) on project studentapp: Compilation failure ERROR] No
compiler is provided in this environment. Perhaps you are running on a
JRE rather than a JDK? [ERROR] COMPILATION ERROR : [INFO]
------------------------------------------------------------- [ERROR] No compiler is provided in this environment. Perhaps you are running
on a JRE rather than a JDK?
This is our pom.xml file.
<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.jdevs</groupId>
<artifactId>studentapp</artifactId>
<version>2.5-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>deployment</id>
<name>Internal Releases</name>
<url>http://rig.eastus.cloudapp.azure.com:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>deployment</id>
<name>Internal Snapshot Releases</name>
<url>http://rig.eastus.cloudapp.azure.com:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-webdav</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>org.sonatype.sisu</groupId>
<artifactId>sisu-guice</artifactId>
<version>2.1.7</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.5.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Reconfigure your Jenkins . From home page goto Manage Plugins and then goto Global Tool Configuration. Reintialize JAVA_HOME field with the correct path to JDK folder.
you need to have JDK install paths defined in your Jenkins configuration. Also if you are using master slave configuration you need to make sure that the particular has the same JDK installed (on the same location) as defined in Jenkins configuration.
Same goes for ANT and Maven installations also.
At least two other sources indicate that, with remote agents, you need to create an environment variable in the node configuration for java.home pointing to the JAVA_HOME directory (not simply %JAVA_HOME% or similar).
Navigate to: Jenkins > Manage Jenkins > Manage Nodes and click the configure icon next to your remote Node. From there, scroll down to Node Properties, tick the box for Environment Variables and define java.home for name and the path to your JDK for the value, e.g. c:\Program Files\Java\jdk1.8.0_181
This was what I eventually needed to do, even after all system environment variables were found to be correct on the build agent server and both java -version and javac -version were correctly reporting.
I realize the OP doesn't specify Master or Remote, but hopefully this is helpful to someone who stumbles upon this Q & A.
This source provided the first clue but no explanation: https://www.pgs-soft.com/blog/oops-jenkins-slave-maven-not-working/
I'm unable to track down the other mention of this fix I found while googling.

Error maven install

Help me find the reason.
Content 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>biz.justtrust</groupId>
<artifactId>smssender</artifactId>
<version>1.0-SNAPSHOT</version>
<name>smssender AMP project</name>
<packaging>amp</packaging>
<description>Manages the lifecycle of the smssender AMP (Alfresco Module Package)</description>
<parent>
<groupId>org.alfresco.maven</groupId>
<artifactId>alfresco-sdk-parent</artifactId>
<version>1.1.1</version>
</parent>
<!--
| SDK properties have sensible defaults in the SDK parent,
| but you can override the properties below to use another version.
| For more available properties see the alfresco-sdk-parent POM.
-->
<properties>
<!-- Defines the alfresco edition to compile against. Allowed values are [org.alfresco|org.alfresco.enterprise]-->
<alfresco.groupId>org.alfresco</alfresco.groupId>
<!-- Defines the alfresco version to compile against -->
<alfresco.version>4.2.f</alfresco.version>
<app.log.root.level>WARN</app.log.root.level>
<alfresco.data.location>alf_data_dev</alfresco.data.location>
<!-- Defines the target WAR artifactId to run this amp, only used with the -Pamp-to-war switch
. | Allowed values: alfresco | share. Defaults to a repository AMP, but could point to your foundation WAR -->
<alfresco.client.war>alfresco</alfresco.client.war>
<!-- Defines the target WAR groupId to run this amp, only used with the -Pamp-to-war switch
. | Could be org.alfresco | org.alfresco.enterprise or your corporate groupId -->
<alfresco.client.war.groupId>org.alfresco</alfresco.client.war.groupId>
<!-- Defines the target WAR version to run this amp, only used with the -Pamp-to-war switch -->
<alfresco.client.war.version>4.2.f</alfresco.client.war.version>
<!-- This controls which properties will be picked in src/test/properties for embedded run -->
<env>local</env>
</properties>
<!-- Here we realize the connection with the Alfresco selected platform
(e.g.version and edition) -->
<dependencyManagement>
<dependencies>
<!-- This will import the dependencyManagement for all artifacts in the selected Alfresco version/edition
(see http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies)
NOTE: You still need to define dependencies in your POM, but you can omit version as it's enforced by this dependencyManagement. NOTE: It defaults
to the latest version this SDK pom has been tested with, but alfresco version can/should be overridden in your project's pom -->
<dependency>
<groupId>${alfresco.groupId}</groupId>
<artifactId>alfresco-platform-distribution</artifactId>
<version>${alfresco.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!-- Following dependencies are needed for compiling Java code in src/main/java;
<scope>provided</scope> is inherited for each of the following;
for more info, please refer to alfresco-platform-distribution POM -->
<dependencies>
<dependency>
<groupId>${alfresco.groupId}</groupId>
<artifactId>alfresco-repository</artifactId>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.smslib</groupId>
<artifactId>smslib</artifactId>
<version>3.5.4</version>
</dependency>
<dependency>
<groupId>org.rxtx</groupId>
<artifactId>rxtxcomm</artifactId>
<version>2.2pre2</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/RXTXcomm.jar</systemPath>
</dependency>
<!-- https://mvnrepository.com/artifact/org.scream3r/jssc -->
<dependency>
<groupId>org.scream3r</groupId>
<artifactId>jssc</artifactId>
<version>2.8.0</version>
</dependency>
</dependencies>
<!-- This repository is only needed to retrieve Alfresco parent POM.
NOTE: This can be removed when/if Alfresco will be on Maven Central
NOTE: The repository to be used for Alfresco Enterprise artifacts is
https://artifacts.alfresco.com/nexus/content/groups/private/. Please check
with Alfresco Support to get credentials to add to your ~/.m2/settings.xml
if you are a Enterprise customer or Partner
-->
<repositories>
<repository>
<id>alfresco-public</id>
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
</repository>
<repository>
<id>smslib</id>
<url>http://smslib.org/maven2/v3</url>
</repository>
<repository>
<id>alfresco-public-snapshots</id>
<url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
</snapshots>
</repository>
</repositories>
<build>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.alfresco.maven.plugin
</groupId>
<artifactId>
alfresco-maven-plugin
</artifactId>
<versionRange>
[1.1.1,)
</versionRange>
<goals>
<goal>set-version</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Output console
[INFO] Building smssender AMP project 1.0-SNAPSHOT
[INFO] ---------------------------------------------
[INFO] Downloading: http://smslib.org/maven2/v3/org/jvnet/staxex/stax-ex/maven-metadata.xml
[WARNING] Could not transfer metadata org.jvnet.staxex:stax-ex/maven-metadata.xml from/to smslib (http://smslib.org/maven2/v3): smslib.org: С именем узла не связано ни одного адреса
[WARNING] Failure to transfer org.jvnet.staxex:stax-ex/maven-metadata.xml from http://smslib.org/maven2/v3 was cached in the local repository, resolution will not be reattempted until the update interval of smslib has elapsed or updates are forced. Original error: Could not transfer metadata org.jvnet.staxex:stax-ex/maven-metadata.xml from/to smslib (http://smslib.org/maven2/v3): smslib.org: С именем узла не связано ни одного адреса
[INFO] Downloading: http://smslib.org/maven2/v3/org/smslib/smslib/3.5.4/smslib-3.5.4.pom
[INFO] BUILD FAILURE
[ERROR] Failed to execute goal on project smssender: Could not resolve dependencies for project biz.justtrust:smssender:amp:1.0-SNAPSHOT: Failed to collect dependencies at org.smslib:smslib:jar:3.5.4: Failed to read artifact descriptor for org.smslib:smslib:jar:3.5.4: Could not transfer artifact org.smslib:smslib:pom:3.5.4 from/to smslib (http://smslib.org/maven2/v3): smslib.org: Unknown host smslib.org
You error shows "Unknown host smslib.org". And you also defined your repository as
<repository>
<id>smslib</id>
<url>http://smslib.org/maven2/v3</url>
</repository>
Please check if you could reach smslib.org.

Using "provided" classpath in tomcat7-maven-plugin goals

I have some dependencies in my webapp that I've marked as provided because I expect them to be provided by an appserver (maybe a production environment provides these dependencies at the specified versions). How do I simulate that when I'm running tests or in development on my localhost using for example the tomcat7-maven-plugin goals like run?
I can't see any way to do it without manually copying jars around. I can see how to use the test classpath - is there something wrong with what I'm trying to do?
OK, I've found a way of getting this to work - it's reasonable but there's a duplication of dependency information and a magic profile... I feel that the tomcat7-maven-plugin should provide a means of making provided dependencies available in the container when running.
Add a profile that is activated when the tomcat plugin runs, and add the dependencies that have provided scope with compile scope to that profile, eg.
... in project pom ...
<dependencies>
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>my-provided-artifact</artifactId>
<version>1.2.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
...
<profiles>
<profile>
<!-- profile activated as cli param when tomcat7 plugin runs -->
<id>tomcat</id>
<dependencies>
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>my-provided-artifact</artifactId>
<version>1.2.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
</profile>
</profiles>
I use, for example, this:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<path>/myApp</path>
</configuration>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>
</dependencies>
</plugin>
and then also include the dependency again later with provided.

Resources