Maven plugin could not find artifact when using remote server - eclipse

I'm trying to write my own maven plugin. When I manually mvn install the plugin project, I can use it without a problem, but I'm having a problem retrieving it from our remote maven repository. This error occurs if I delete the com/company/my-plugin from my .m2/repository directory and then try to do mvn install.
[WARNING] The POM for com.company:my-plugin:jar:0.0.1-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.472s
[INFO] Finished at: Wed Jun 19 16:15:29 EDT 2013
[INFO] Final Memory: 4M/122M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin com.company:my-plugin:0.0.1-SNAPSHOT or one of its dependencies could not be resolved: Failed to read artifact descriptor for com.company:my-plugin:jar:0.0.1-SNAPSHOT: Could not find artifact com.company:my-plugin:pom:0.0.1-SNAPSHOT -> [Help 1]
The only reference to the plugin in the pom is in the build/plugins section:
<plugin>
<groupId>com.company</groupId>
<artifactId>my-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<configuration>
<sourceFiles>
<sourceFile>infile.foo</sourceFile>
</sourceFiles>
<outputFile>outpath/myfile.foo</outputFile>
</configuration>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>my-goal</goal>
</goals>
</execution>
</executions>
</plugin>
I've confirmed that the project exists in our remote repository and that other dependencies in that repository are resolving. The other dependencies are not plugins, however.
Is there additional configuration I need to specify to resolve a plugin dependency? Is there an approach I can use to help me figure out what's causing this problem more specifically?

Turns out I needed to separately specify the location of plugin repositories in the pom (in addition to specifying the remote repository normally). I was missing the following block:
<pluginRepositories>
<pluginRepository>
<id>my-plugin-repo</id>
<url>https://nexus.company.com:8443/path/to/repository/</url>
</pluginRepository>
</pluginRepositories>

"[WARNING] The POM for com.company:my-plugin:jar:0.0.1-SNAPSHOT is missing, no dependency information available"
Are you sure if the pom.xml for this plugin project exists in the plugin remote repository you are trying to pull from? If no, i probably think that should be the problem.

Related

Load values from external file into pom.xml

I am trying to read some parameters in a pom.xml from an external file. I am using properties-maven-plugin, but I don't really mind any other solution to read values from an external file as a variable in pom.
Here is my plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<goals>
<goal>read-project-properties</goal>
</goals>
<phase>initialize</phase>
<configuration>
<!--<files>
<file>${apps.basedir}/apps/flywayvariables.properties</file>
<file>/home/gokul/git/sampleproject/apps/flywayvariables.properties</file>
</files>-->
<urls>
<url>file:///${apps.basedir}/apps/flywayvariables.properties</url>
</urls>
</configuration>
</execution>
</executions>
</plugin>
Here is where I am trying to use it:
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>7.0.1</version>
<configuration>
<sqlMigrationSeparator>__</sqlMigrationSeparator>
<locations>
<location>filesystem:${apps.basedir}/apps/flyway</location>
</locations>
<url>jdbc:postgresql://localhost:9000/postgres</url>
<user>${dbuser}</user>
<flyway.user>${dbuser}</flyway.user>
<flyway.password>${dbpassword}</flyway.password>
<password>${dbpassword}</password>
</configuration>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.16</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>migrate</id>
<goals>
<goal>migrate</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
</plugin>
And here is my properties file:
<properties>
<dbuser>postgres</dbuser>
<dbpassword>test1234</dbpassword>
</properties>
When I run mvn -X initialize, I get the following error:
[DEBUG] Configuring mojo org.codehaus.mojo:properties-maven-plugin:1.0.0:read-project-properties from plugin realm ClassRealm[plugin>org.codehaus.mojo:properties-maven-plugin:1.0.0, parent: sun.misc.Launcher$AppClassLoader#5c647e05]
[DEBUG] Configuring mojo 'org.codehaus.mojo:properties-maven-plugin:1.0.0:read-project-properties' with basic configurator -->
[DEBUG] (f) project = MavenProject: com.example.company:sampleapplication # /home/gokul/git/sampleproject/apps/pom.xml
[DEBUG] (f) quiet = false
[DEBUG] (s) urls = [file:////home/gokul/git/sampleproject/apps/flywayvariables.properties]
[DEBUG] -- end configuration --
[DEBUG] Loading properties from URL file:////home/gokul/git/sampleproject/apps/flywayvariables.properties
[INFO]
[INFO] --- flyway-maven-plugin:7.0.1:migrate (migrate) # apps ---
...
...
...
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.422 s (Wall Clock)
[INFO] Finished at: 2020-10-13T01:18:40+02:00
[INFO] Final Memory: 33M/1237M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:7.0.1:migrate (migrate) on project apps: org.flywaydb.core.internal.exception.FlywaySqlException:
[ERROR] Unable to obtain connection from database (jdbc:postgresql://localhost:9000/postgres) for user 'null': The server requested password-based authentication, but no password was provided.
[ERROR] ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[ERROR] SQL State : 08004
[ERROR] Error Code : 0
[ERROR] Message : The server requested password-based authentication, but no password was provided.
I can see that the plugins are executed in the order I would want and yet the property is not loaded. The file path and permissions shouldn't be an issue since I created the properties file with the same user account as I am executing the maven project. No password was provided error changes to authentication failed error when I input the password manually and only keep the $dbuser as a variable. I have tried changing the names of the variables too, in vain. In the properties-maven-plugin configuration, I tried supplying files instead of urls, but it did not make any difference to maven.
Unfortunately none of the solutions in this question helps me.
Tried the following maven goals:
initialize
verify
validate
install
properties:read-project-properties initialize
I am pretty sure you need to write the properties file in the traditional fashion like
dbuser=postgres
dbpassword=test1234
I do not know why the properties plugin does not work, but Flyway itself supports multiple methods for storing these settings outside of the pom. See the Flyway maven documentation for more details.
Below is some snippets from the link:
Configuration Files
Flyway will search for and automatically load the <user-home>/flyway.conf config file if present.
It is also possible to point Flyway at one or more additional config files. This is achieved by supplying the System property flyway.configFiles as follows:
mvn -Dflyway.configFiles=path/to/myAlternativeConfig.conf flyway:migrate
See https://flywaydb.org/documentation/maven/#config-files for more information.
Maven Settings
Alternatively for storing the database user and password, Maven settings.xml files can also be used:
<settings>
<servers>
<server>
<!-- By default Flyway will look for the server with the id 'flyway-db' -->
<!-- This can be customized by configuring the 'serverId' property -->
<id>flyway-db</id>
<username>myUser</username>
<password>mySecretPwd</password>
</server>
</servers>
</settings>

Creating Windows Executable for OpenJFX 11 Project in Eclipse with Maven Integration

I'm switching over from Java 8 (Oracle JDK) to OpenJDK 11 and OpenJFX 11. I've successfully gotten my project to work in Eclipse through Maven via the clean javafx:run command using the maven-compiler-plugin however I am having issues building a runnable jar and windows executable. I do not need a linux or mac runnable as this project is just an internal product and we only use windows.
I have already tried several plugins such as the maven-shade-plugin and also tried running mvm package to no avail. I've tried this Build executable JAR with JavaFX11 from maven and this How to deploy a JavaFX 11 Desktop application with a JRE.
In the past I could just build a executable jar through Eclipse's "Export Runnable Jar" option and then creating an executable through launch4j, however this does not seem to work anymore and I understand this probably due to the modular structure of OpenJDk 9+.
I have all the JavaFX dependencies added as well as the JAXB ones that I needed and it runs in the IDE when I build it (although I can't get it to run as a Java Application Run Configuration once I made it run in Maven Run Configuration.
Here are my plugins:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<mainClass>com.tapestry.testertools.ApplicationMainFrame</mainClass>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.tapestry.testertools.ApplicationMainFrame</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Here is the error message when i attempt to run mvn clean package
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.325 s
[INFO] Finished at: 2019-09-20T09:19:35-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project testertools: Fatal error compiling: invalid flag: --module-path -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

my configuration of scala-maven-plugin with multi-module project doesn't let me do 'mvn compile' in a sub directory

We are using the scala-maven-plugin for our mixed Java/Scala project. Works nicely in general, but we have found that with a multi-module project we can't figure out how to do a'mvn compile' in a subdirectory.
I am unable to post my full source code to IP restrictions, but in my search for other projects that might
have solved this issue I only managed to come up with other projects with the exact same problem. Here is one
for example: https://github.com/buildlackey/scala-multimodule-sample-project.git
The above project has three submodules beneath the directory that holds the root pom.xml: cats, dogs and web-application.
If you git clone the above url, then cd to 'scala-multimodule-sample-project', you will see it build.
Now if I cd into the sub-module 'dogs' and do a 'mvn compile', I see the message:
[INFO] No sources to compile
But there are sources to compile ! The plugin is just not finding them.
This is the same thing that happens on my multi-module project. I can't post the whole source for our stuff.. But here
is the relevant configuration from our top level pom.xml :
<build>
<sourceDirectory>${basedir}/src/main/scala</sourceDirectory>
<testSourceDirectory>${basedir}/src/test/scala</testSourceDirectory>
<!-- Compiling scala code -->
<plugin>
<!-- see http://davidb.github.com/scala-maven-plugin -->
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<id>scala-compile</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
According to the documentation for the plug-in (http://davidb.github.io/scala-maven-plugin/add-source-mojo.html)
there are are optional parameters that can be passed to the add-source goal: namely, sourceDir and testSourceDir
However, I could not figure out how to pass these. Maybe those parameters are the key to success here ?
Finally, one kind of silly work-around that proved successful is to copy the same configuration for scala-maven-plugin into each submodule directory where I want to do a compile restricted to that submodule. Obviously this is a non-DRY, undesirable approach.
I'd be most grateful if anyone could suggest a good solution.
Thanks !
I uploaded a working sample at https://github.com/davidB/scala-maven-plugin/tree/master/samples/prj_multi_modules
The duplicate solution is the common usage.
The DRY alternative is to declare the configuration of the plugin in the <pluginManagement> section, then add under <build><plugins><plugin> the groupId + artifactId for project(s) where you want to enable the plugin. You can add it into modules'pom.xml or into parent's pom.xml inherited by every modules.
You could also use <dependencyManagement> to avoid duplicate dependency's version.
The addSource is to register additional source directory and expose it for IDE and other plugins.
I think you have wrong value for sourceDir in your scala-multimodule-sample-project pom.xml file.
I change sourceDir to the src/main/scala and after mvn compile I have the following output:
...
[INFO] skip non existing resourceDirectory /home/grzesiek/dev/project/temp/scala-multimodule-sample-project/cats/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # cats ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-scala-plugin:2.15.2:compile (default) # cats ---
[INFO] Checking for multiple versions of scala
[INFO] includes = [**/*.java,**/*.scala,]
[INFO] excludes = []
[INFO] /home/grzesiek/dev/project/temp/scala-multimodule-sample-project/cats/src/main/scala:-1: info: compiling
[INFO] Compiling 1 source files to /home/grzesiek/dev/project/temp/scala-multimodule-sample-project/cats/target/classes at 1453711735781
...

Error in pom.xml Maven build

I am getting an error in my pom.xml when trying to build a maven project. The error is here on this plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
This is the error Eclipse shows:
Multiple annotations found at this line:
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:
2.3.2:compile (execution: default-compile, phase: compile)
- CoreException: Could not get the value for parameter compilerId for plugin execution default-compile:
PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not
be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 ():
ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven:maven-toolchain:jar:1.0:
ArtifactResolutionException: Failure to transfer org.apache.maven:maven-toolchain:pom:1.0 from http://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. Original error: Could not transfer artifact org.apache.maven:maven-toolchain:pom:1.0 from/to central (http://
repo.maven.apache.org/maven2): The operation was cancelled.
Seems like the resolution failed.
Run mvn with the -U flag to disregard the cache and re-attempt resolution
(the alt+f5 dialog might help as well)
When I ran into this problem I figured out that it was due to a previous network problem. The local Maven repository avoids immediate reattempts. The best way to solve this was to use the eclipse "Update Maven Project" (ALT+F5) feature end check the option "Force Update of Snapshots/Releases".
This was not working for me , changing maven compiler version to 2.5.1 finally worked for me , hopefully this comes to rescue for anyone still struggling with this dependency
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Update Maven Project by pressing (ALT+F5) and select the option "Force Update of Snapshots/Releases".
Update Maven Project by pressing (ALT+F5) and select the option "Force Update of Snapshots/Releases". works for me also
Got similar issue. Maven update and force update of snapshot didn't work for me.
Did following steps, issue resolved:
Remove project in eclipse.
Delete .Project file and . Settings folder.
Import project as existing maven project again to eclipse.

The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid version could be found

I hit into deployment error for Jboss AS 7.1.1 Final deployment as mentioned at Could not connect to remote://localhost:9999. The connection timed out Jboss 7.1.1 Final. I am trying to use latest version of Jboss Maven plugin '7.4.Final' from '7.1.1.Final'. When I made change in POM configuration I am getting following error for both versions of plug-in. I have confirmed that my .m2 has both of these plug-in versions available.
Is POM meta data corrupt in my case, if so how do I clean it up to get it working?
[INFO] Searching repository for plugin with prefix: 'jboss-as'.
[DEBUG] Loading plugin prefixes from group: org.apache.maven.plugins
[DEBUG] Loading plugin prefixes from group: org.codehaus.mojo
[DEBUG] maven-jboss-as-plugin: using locally installed snapshot
[DEBUG] Artifact not found - using stub model: Unable to determine the latest version
org.apache.maven.plugins:maven-jboss-as-plugin:pom:LATEST
[DEBUG] Using defaults for missing POM org.apache.maven.plugins:maven-jboss-as-plugin:pom:LATEST
[DEBUG] maven-jboss-as-plugin: using locally installed snapshot
[DEBUG] Artifact not found - using stub model: Unable to determine the release version
org.apache.maven.plugins:maven-jboss-as-plugin:pom:RELEASE
[DEBUG] Using defaults for missing POM org.apache.maven.plugins:maven-jboss-as-plugin:pom:RELEASE
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid version could be found
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid version could be found
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1569)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.getMojoDescriptor(DefaultLifecycleExecutor.java:1851)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.segmentTaskListByAggregationNeeds(DefaultLifecycleExecutor.java:462)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:175)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.version.PluginVersionNotFoundException: The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid version could be found
at org.apache.maven.plugin.version.DefaultPluginVersionManager.resolvePluginVersion(DefaultPluginVersionManager.java:229)
at org.apache.maven.plugin.version.DefaultPluginVersionManager.resolvePluginVersion(DefaultPluginVersionManager.java:91)
at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPluginManager.java:179)
at org.apache.maven.plugin.DefaultPluginManager.loadPluginDescriptor(DefaultPluginManager.java:1642)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1540)
... 15 more
UPDATE
POM.xml
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<!-- continue build even test fails -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.4.Final</version>
<configuration>
<filename>${project.build.finalName}.jar</filename>
<username>${userName}</username>
<password>${password}</password>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
The stack trace show us as
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin'
does not exist or no valid version could be found
[INFO] ------------------------------------------------------------------------
It should be org.jboss.as.plugins:jboss-as-maven-plugin instead.
The JBoss Application Server 7: Plugin Documentation told us to configure as the following: -
<project>
...
<build>
<!-- To define the plugin version in your parent POM -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.4.Final</version>
</plugin>
...
</plugins>
</pluginManagement>
<!-- To use the plugin goals in your POM or parent POM -->
<plugins>
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.4.Final</version>
</plugin>
...
</plugins>
</build>
...
</project>
Please review and ensure that the plugin org.jboss.as.plugins:boss-as-maven-plugin is under the <build> in your pom.xml.
I hope this may help.
I was facing similar issue. This issue was due to older version of maven2.2.1.
When moved to newer version3.x of maven it worked.