I integrated maven in eclipse . then i imported a existing maven project using import wizard. i got the following error please help me out - eclipse

Project build error: Non-resolvable parent POM for org.alfresco.maven:alfresco-sdk-parent:1.1.1: Failure to transfer org.alfresco.maven:alfresco-lifecycle-aggregator:pom:1.1.1 from https://artifacts.alfresco.com/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of alfresco-public has elapsed or updates are forced. Original error: Could not transfer artifact org.alfresco.maven:alfresco-lifecycle-aggregator:pom:1.1.1 from/to alfresco-public (https://artifacts.alfresco.com/nexus/content/groups/public): No response received after 60000here
error point first line of the code which is
File Name Pom.xml
I am using Eclipse Kepler
//Eclipse shows error in first line
<?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>fosspro</groupId>
<artifactId>fosspro_aid</artifactId>
<version>1.0-SNAPSHOT</version>
<name>fosspro_aid AMP project</name>
<packaging>amp</packaging>
<description>Manages the lifecycle of the fosspro_aid AMP (Alfresco Module Package)</description>
<parent>
<groupId>org.alfresco.maven</groupId>
<artifactId>alfresco-sdk-parent</artifactId>
<version>1.1.1</version>
</parent>
Please Help me Out

You may need to add the repository in your pom (inside project)...
<repositories>
<repository>
<id>alfresco-public</id>
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
</repository>
<!-- You may not need the snapshots? -->
<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>
...or if you prefer, in the settings.xml of your Maven configuration.
I assume that the issue is as follow: the repository address is defined in the pom of the SDK, but in order to access the pom of the SDK, Eclipse needs to know the address of the repository.

Maven fails to access https://artifacts.alfresco.com/nexus/content/groups/public/, so it's not an issue with your setup it seems that there are issues connecting to Alfresco's Nexus to fetch the dependencies.
It seems unresponsive for me at this very minute, try again in a few minutes.

Related

Maven/Eclipse does not copy my tests resources to the target/test-classes directory

When I try to debug my unit tests with Eclipse, my resources are not found (getResourceAsStream returns null) because maven/Eclipse? does not copy them to the target/test-classes. Why are the test classes build but resources not copied?
I did post the answer to this question with the question.
I am using Eclipse 2022-09 with m2e 2.0.1... Maven 3.8.5, maven-resources-plugin 3.2.0.
the 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>MyArticactId</artifactId>
<packaging>jar</packaging>
<name>MyName</name>
<parent>
<groupId>MyGropupId</groupId>
<artifactId>ParentArtifactId</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
<dependencies>
...
</dependencies>
</project>
Learned the hard way that Eclipse compiled the test classes to the target/test-classes directory but did not copy the resources if maven.test.skip is set to true.
<maven.test.skip>true</maven.test.skip>
I have to set maven.test.skip to false to be able to debug tests that require resources. It would have been easier to identify the configuration problem had Eclipse not generated the test class files (the same way Maven does not).
ref: https://bugs.eclipse.org/bugs/show_bug.cgi?id=407636

External JARs with Drools Workbench do not resolve on compilation

Summary
I have a drools workbench server that I want to push data model jars to from maven. I can push jars to it, but when I do, the artefacts do not resolve. If I try to upload the artefacts manually through the drools UI, I get other maven errors.
Details
I have a drools installation of drools and KIE 7.24 (and 23) (https://hub.docker.com/r/jboss/jbpm-server-full/) running in a local docker container. I want to push data models to workbench. My pom.xml of the project containing the facts looks like
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<properties>
<maven.compiler.release>11</maven.compiler.release>
</properties>
<groupId>decisions</groupId>
<artifactId>fact</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>kjar</packaging>
<name>Facts</name>
<description>Facts</description>
<build>
<plugins>
<plugin>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
<version>7.24.0.Final</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>workbench</id>
<url>http://localhost:8080/business-central/maven2</url>
</repository>
</distributionManagement>
</project>
A mvn deploy on the host succeeds and builds. When I log into the drools container, I can verify that all the files are in $DROOLS_HOME/bin/repositories/kia/global and when I bring up the artifacts screen, they are visible in the list.
When I try to add them as a project dependency, I get warnings from drools
07:49:16,790 WARN [org.appformer.maven.integration.MavenRepository] (default task-50) Unable to resolve artifact: decisions:fact:1.0.0
07:49:16,791 ERROR [org.kie.scanner.MavenClassLoaderResolver] (default task-50) Dependency artifact not found for: decisions:fact:1.0.0
Everything in the drools workbench maven repositories looks perfectly ok, but no matter what I do, the artifact will not resolve.
If I try to upload it manually to the artifact store using the workbench admin repository tool, I get a huge stack trace from drools:
08:14:06,447 ERROR [io.undertow.request] (default task-56) UT005023: Exception handling request to /business-central/maven2: java.lang.RuntimeException: org.eclipse.aether.deployment.DeploymentException: Failed to retrieve remote metadata com.lendi.decisions:fact:1.0.0-SNAPSHOT/maven-metadata.xml: Could not transfer metadata com.lendi.decisions:fact:1.0.0-SNAPSHOT/maven-metadata.xml from/to workbench (http://localhost:8080/business-central/maven2): Unauthorized (401)
at org.guvnor.m2repo.backend.server.repositories.DistributionManagementArtifactRepository.deploy(DistributionManagementArtifactRepository.java:145)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:38)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:106)
at org.guvnor.m2repo.backend.server.repositories.ArtifactRepository$475362908$Proxy$_$$_WeldClientProxy.deploy(Unknown Source)
at org.guvnor.m2repo.backend.server.GuvnorM2Repository.lambda$deployArtifact$4(GuvnorM2Repository.java:300)
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
Neither the drools manual or any references seem to have advice.

When automating Eclipse's "Export as Feature", Maven/Tycho doesn't see my plugin

I have a plugin and a feature project in my workspace. When I export the feature manually via File > Export As > Feature everything works well. I'm trying to write an automatic plugin building and exporting script to get rid of this chore. I converted feature project to Maven project and filled pom.xml with:
<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>MyProject</groupId>
<artifactId>NMGDBPluginFeature</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
<properties>
<tycho-version>0.22.0</tycho-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>eclipse-luna</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/luna</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
However script throws:
[ERROR] Cannot resolve project dependencies:
[ERROR] Software being installed: NMGDBPluginFeature.feature.group 1.0.0.qualifier
[ERROR] Missing requirement: NMGDBPluginFeature.feature.group 1.0.0.qualifier requires 'GDBFifoBlocks [1.0.0.gdbfifoblocks]' but it could not be found
How could that happen? I thought pom.xml uses feature.xml of project, doesn't it? What is a proper configuration?
So far, your configuration looks good. However you currently only have an automated build for your feature, but not the for the plugin. Unlike the Eclipse export wizard, eclipse-feature only processes the feature.xml - and it expects that the referenced plugins are built elsewhere.
So what you need to do is to set up a Maven reactor which includes both an eclipse-feature and an eclipse-plugin project. Here is how you do this:
Make your current pom.xml the parent POM: Change the packaging to pom, adapt the artifactId to something which makes sense (e.g. MyProject.parent), and move the pom.xml into a new general project in your workspace.
Add a pom.xml in the root of the feature project:
<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>MyProject</groupId>
<artifactId>MyProject.parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>relative/path/to/parent/project</relativePath>
</parent>
<artifactId>NMGDBPluginFeature</artifactId>
<packaging>eclipse-feature</packaging>
</project>
Add another pom.xml in the root of the plugin project, which is the same as the one above except for the artifactId - this needs to be the same as the plugin's Bundle-SymbolicName - and the packaging which needs to be eclipse-plugin.
Include the plugin and feature projects in the Maven reactor by adding a <modules> section in the parent POM with the paths to these projects:
<modules>
<module>relative/path/to/plugin/project</module>
<module>relative/path/to/feature/project</module>
</modules>
Note that the paths need to be adapted so that they are correct for the project locations on disk (which may be different to what is shown in the Eclipse workspace). The paths need to be relative, so they probably start with ../.
Now you can trigger a Maven build on your parent POM, and the feature should be able to resolve the reference to your plugin. In Eclipse, you can trigger the Maven build from the context menu of the pom.xml file. Or, if you also convert the parent project to a Maven project, the you can also run Maven builds from the context menu of the project root.

maven "Please verify you invoked Maven from the correct directory" error in eclipse

I created a java project in eclipse. The project location is /home/vikas/code/primeNumberWorkSpace/primeNumber.
I linked the source and pom files from other locations (/home/vikas/code/primNumber/src/ and /home/vikas/code/primeNumber/pom.xml)
When i issue 'clean install' command from the eclipse, it gives the following error,
[ERROR] The goal you specified requires a project to execute but there
is no POM in this directory
(/home/vikas/code/primeNumberWorkSpace/primeNumber). Please verify you
invoked Maven from the correct directory. -> [Help 1]
How to resolve this.
the pom file is:
<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>main.java.com.simpragma.primenumber</groupId>
<artifactId>prime-number</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Maven Quick Start Archetype</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
</build>
</project>
You might have tried setting the AutoRun registry key for Command Processor to change where cmd.exe has its starting location...
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor\AutoRun
Check this value, as a CD in this autorun will change the default location of all cmd.exe that are run on the system. Which is wonderful, but it apparently breaks something in maven workflow.
Deleted my AutoRun value and this issue went away for me.
I was also having this issue with maven projects within MuleSoft Anypoint Studio 6.4.4, which is based on Eclipse 4.5.2. By removing the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor\AutoRun value the issue went away.
Thanks for your answer Dave Horner.

How to upload maven plugin to Nexus repository?

I want to upload my custom maven plugin to nexus repository.
My problem is that when I upload my plugin to nexus via web IU like ordinary dependency, maven can't find it:
Plugin com.huawei:maven-project-version-plugin:1.0 or one of its
dependencies could not be resolved: Failed to read artifact descriptor
for com.huawei:maven-project-version-plugin:jar:1.0: Failure to find
com.mycompany:maven-project-version-plugin:pom:1.0 in
http://localhost:8081/nexus/content/groups/public was cached in the
local repository, resolution will not be reattempted until the update
interval of nexus has elapsed or updates are forced -> [Help 1]
But when I am install my plugin to maven local repositiry (not nexus) via command line all is fine.
So, what is the difference between installing custom maven plugin and installing "non plugin" artefacts? Are there any tricks?
My settings.xml:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
The problem was solved. Well, I don't know how, but today all is work. I think the problem was in Nexus cache. I just deleted my hosted repository and created it again. Perhaps, there are less radical methods, but I don't know them =) Delete artifact and then just "expire cache" not help in my case.
Well, the answer of my question: There is no any different between installation plugin and non plugin artifact in Nexus, except one. If you select GAV Definition: GAV parameters, you must select "maven-plugin" in combobox "Packaging".
I think there is no need to write step by step instruction, it is very simple. Just select your hosted repository -> Artifact Upload tab and fill required fields.
Also to add that you must also upload the pom of your Maven plugin. If you don't Nexus will auto generate one which is not correct. i.e. it will just be a basic pom consisting of version, artifactID, packaging, and groupID.