Sorry for this question, but I couldn't find anything similiar to this in the web, so here we go:
I am trying to install jersey as follows :
mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-webapp-DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false-DgroupId=com.example -DartifactId=simple-service-webapp -Dpackage=com.example-DarchetypeVersion=2.22.1
It's from their website for an example project. This starts to execute, so JAVA_HOME and mvn are set up properly. But as soon as the console states "Generating Project in Batch mode", it fails with a "Build Failure", Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin.... The desired archetype does not exist. I can upload a screenshot of the console log if needed.
From this url I could correctly generate the archetype whith the following step.
1-First I create an empty maven project
then I modified the pom file like this
<groupId>fr.toto</groupId>
<artifactId>tata</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<repositories>
<repository>
<id>snapshot-repository.java.net</id>
<name>Java.net Snapshot Repository for Maven</name>
<url>https://maven.java.net/content/repositories/snapshots/</url>
<layout>default</layout>
</repository>
</repositories>
Then I run the following command inside the root dir of the empty project I created at step 1 :
mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-grizzly2 \
-DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false \
-DgroupId=fr.cnamts -DartifactId=tata -Dpackage=fr.cnamts \
-DarchetypeVersion=2.22.1
And voilĂ it works!
Related
I am correctly deploying my JAR file using the command line below, however I would like to create a pom.xml file and invoke mvn deploy or something similar to deploy this package to github packages.
Is this possible? How can I do it?
mvn deploy:deploy-file -DgroupId=com.soma -DartifactId=my-module \
-Dversion=1.0.0 -Dpackaging=jar -Dfile=my-module.jar \
-DrepositoryId=github \
-Durl=https://maven.pkg.github.com/$USER/my-artifacts
In other words, I prefer to use Maven to automate my workflow over bash shell.
I appreciate any help.
The following minimal pom.xml should work by executing mvn deploy with
the following caveats:
Replace $USER with your actual GitHub user ID
Put your JAR in target/my-module-1.0.0-SNAPSHOT.jar
Make sure your ${user.home}/.m2/settings.xml has a <server/> entry
with your GitHub user and token
<?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>com.soma</groupId>
<artifactId>my-module</artifactId>
<version>1.0.0</version>
<distributionManagement>
<downloadUrl>https://maven.pkg.github.com/$USER/${project.groupId}/</downloadUrl>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/$USER/${project.groupId}/</url>
</repository>
</distributionManagement>
</project>
This should be straightforward if you already have a Maven build for the
project.
(I have run into problems with GitHub throttling requests when trying to
deploy multimodule projects or quickly redeploying an artifact.)
I am trying to upload a Maven artifact I haven't built to my Organization's GitHub package registry. I am using the deploy:deploy-file Maven plugin in order to do so. Here is the command I have been using:
mvn deploy:deploy-file
-Dfile=[THE JAR FILE]
-Durl=https://maven.pkg.github.com/[ORG]
-Dregistry=https://maven.pkg.github.com/[ORG]
-DgroupId=[GID]
-DartifactId=[ARTIFACTID]
-Dversion=[VERSION]
-DgeneratePom=false
-Dtoken=[MY GITHUB TOKEN]
As a result I am receiving 401 errors from Github.
I have made sure that:
I have sufficient permissions inside of my Organization (currently Owner).
The token i am using is valid and has the appropriated scopes: I put all of them on to test.
Also, the github package page states:
<!-- Just a single step: Deploy using a GitHub token -->
$ mvn deploy -Dregistry=https://maven.pkg.github.com/[org] -Dtoken=GH_TOKEN
Why can't I find any information in Maven documentation about registry or token parameters?
Can I upload this file to the organization's registry without any kind of XML configuration file, using only the cli?
Thanks in advance.
I had success with this:
mvn deploy:deploy-file -Dfile=./[JAR].jar
-DpomFile=./pom.xml
-DrepositoryId=github
-Durl=https://maven.pkg.github.com/[OWNER]/[REPO]
-Dtoken=GH_TOKEN
And a settings.xml in my maven home directory:
<settings>
<servers>
<server>
<id>github</id>
<username>[GITHUB USERNAME]</username>
<password>[GENERATED ACCESS TOKEN]</password>
</server>
</servers>
</settings>
And inside my POM:
...
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/[OWNER]/[REPO]</url>
</repository>
</distributionManagement>
...
To workaround the repo issue - since I didn't want each package to be published to a different repo, I created a repo named packages and published the packages from all the other repos to it, using the same config as in the other two answers.
Url should have a repository name as well.
In one of my projects I have this in pom.xml
<distributionManagement>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/stirante/lol-client-java-api</url>
</repository>
</distributionManagement>
Still new to Docker and trying to get a Jetty webservice to run inside a container.
This is my docker file at the moment
Recipe
FROM maven:3.3-jdk-8-alpine
# Install packages
# To find packages to install see - https://pkgs.alpinelinux.org/packages
RUN apk add --no-cache curl tar bash wget apache-ant
RUN apk info
# Do any Maven configuration
ENV MAVEN_HOME /usr/share/maven
VOLUME "$USER_HOME_DIR/.m2"
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
# Copy over project source files to the /tmp folder
COPY . /tmp/project
WORKDIR /tmp/project
# Preinstall any Maven depencencies
RUN mvn install -pl '!deb' -DskipTests
# Default command when running the docker image, can be overriden
CMD cd webapp/ && mvn jetty:run
During the docker build I specify maven install to install all dependencies for the project and build the jars for each module from sources.
However when then run the docker container, it still tries to reinstall all the dependencies and then fails because it cannot find my api.jar file
My project structure is like so
Project structure
service
api
lib
webapp
pom.xml
Error
The following artifacts could not be resolved:
com.foo.service:service-api:jar:1.14-SNAPSHOT
Doing the same steps outside of a container works fine and the jetty service starts ok. Any ideas how to fix?
SNAPSHOT dependencies are checked for updates regularly by Maven - by default on a daily basis. But you can disable this in your settings.xml of Maven. See https://stackoverflow.com/a/3942048/2235015 for an answer in a similar (but inverted) case, and see http://maven.apache.org/ref/3.2.2/maven-settings/settings.html (search for updatePolicy).
Example Repository setting in your settings.xml:
<repository>
<id>snapshots</id>
<url>http://host/nexus/repos/snapshots</url>
<snapshots>
<updatePolicy>never</updatePolicy>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</repository>
I'm having some issues to configure properly my eclipse to work with maven.
I create a new project, this one is correctly build with maven in command line (mvn install), but in Eclipse I got this error:
CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-compiler-plugin:jar:3.1 (): ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven:maven-settings:jar:2.2.1: ArtifactResolutionException: Failure to transfer org.apache.maven:maven-settings:pom:2.2.1 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-settings:pom:2.2.1 from/to central : NullPointerException pom.xml /test line 9 Maven Project Build Lifecycle Mapping Problem
Here is my settings.xml conf :
<proxy>
<active>true</active>
<protocol>http</protocol>
<username>myuser</username>
<password>$mymdp</password>
<host>myhost</host>
<port>8080</port>
<nonProxyHosts>some.host.com</nonProxyHosts>
</proxy>
....
<repository>
<id>central</id>
<name>central repo m2</name>
<url>http://central.maven.org/maven2</url>
</repository>
I choose the correct maven installation (in Preference -> Maven -> Install)
I also direct my user settings on the correct settings.xml (Preferences -> Maven -> User Settings)
But I still got this error in Eclipse and everything goes well with maven command line. Do you have and idea?
You only need to delete one folder it is throwing error for. Just go to your M2 repo and org/apache/maven/plugins/maven-compiler-plugins and delete the folder 2.3.2
Have you tried to remove the proxy username and password? A similar poster encountered that issue:
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-jar-plugin:2.3.2 or one of its dependencies could not be resolved
Failing that I found the following worked:
Delete project in Eclipse (but do not delete the contents on disk)
Delete all files in your Maven repository
Re-download all Maven dependencies:
mvn dependency:resolve
Start up Eclipse
Ensure that Eclipse is configured to use your external Maven installation (Window->Preferences->Maven->Installations)
Re-import the existing project(s) into Eclipse
Ensure that there are no Maven Eclipse plugin errors on the final screen of the project import
I was getting this problem when using IBM RSA 9.6.1 when building a brand new development machine. The problem for me ended up being because of HTTPS on the Global Maven repository. My solution was to create a Maven settings.xml that forced it to use HTTP.
The key to me was that the central repository was empty when I exploded it under Maven Repositories -- > Global Repositories
Using the following settings file worked for me:
<settings>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>insecurecentral</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>insecurecentral</id>
<!--Override the repository (and pluginRepository) "central" from the Maven Super POM -->
<repositories>
<repository>
<id>central</id>
<url>http://repo.maven.apache.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://repo.maven.apache.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>
I got the idea from this stackoverflow question.
The issue has been resolved while installation of the maven settings is provided as External in Eclipse. The navigation settings are Window --> Preferences --> Installations. Select the External as installation Type, provide the Installation home and name and click on Finish. Finally select this as default installations.
I accidentally turned on offline mode.
To disable it: in the Maven tool window, click The Toggle Offline Mode button.
I also got the same issue and not able to create a jar, and I found that in Windows-->Prefernces-->Java-->installed JREs By default JRE was added to the build path of newly
created java project so just changed it to your prefered JDK.
Find your Maven local repository, navigate to maven-compiler-plugin, delete the 3.8.1 folder, so that the Maven will redownload it again.
For example:
C:\Users\mkyong.m2\repository\org\apache\maven\plugins\maven-compiler-plugin
I am using SourceForge for some Open Source projects and I want to automate the deployment of releases to the SourceForge File Release System. I use Maven for my builds and the standard SFTP deployment mechanism doesn't seem to work unless you do some manual preparation work. I have come across some old postings on other forums suggesting that the only approach is to write a Wagon specifically for SourceForge.
Has anybody had any recent experience with this?
I'm not able to test this to confirm, but I believe it is possible without writing any plugins.
You can deploy to SourceForge using SCP, and the maven-deploy-plugin can be configured to use SCP so it should work. You can also deploy your site to SourceForge via SCP.
You would configure the SourceForge server in your settings.xml to use a "combined" username with a comma separator. With these credentials:
SourceForge username: foo
SourceForge user password: secret
SourceForge project name: bar
Path: /home/frs/project/P/PR/PROJECT_UNIX_NAME/
- Substitute your project UNIX name data for /P/PR/PROJECT_UNIX_NAME
The server element would look like this:
<server>
<id>sourceforge</id>
<username>foo,bar</username>
<password>secret</password>
</server>
And the distributionManagement section in your POM would look like this:
<!-- Enabling the use of FTP -->
<distributionManagement>
<repository>
<id>ssh-repository</id>
<url>
scpexe://frs.sourceforge.net:/home/frs/project/P/PR/PROJECT_UNIX_NAME</url>
</repository>
</distributionManagement>
Finally declare that ssh-external is to be used:
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh-external</artifactId>
<version>1.0-alpha-5</version>
</extension>
</extensions>
</build>
If this doesn't work, you may be able to use the recommended approach in the site reference above, i.e. create a shell on shell.sourceforge.net with your username and project group:
ssh -t <username>,<project name>#shell.sf.net create
Then use shell.sourceforge.net (instead of web.sourceforge.net) in your site URL in the diestributionManagement section:
<url>scp://shell.sourceforge.net/home/frs/project/P/PR/PROJECT_UNIX_NAME/</url>
I have uploaded an example to sourceforge.net at: http://sf-mvn-plugins.sourceforge.net/example-1jar-thinlet/
You can check out it via svn - so you can see how to use plugins for upload and download of and to sourceforge.net file system area and web site.
The main points to upload are to use sftp:
Add this similar code to your pom.xml
<distributionManagement>
<!-- use the following if you're not using a snapshot version. -->
<repository>
<id>sourceforge-sf-mvn-plugins</id>
<name>FRS Area</name>
<uniqueVersion>false</uniqueVersion>
<url>sftp://web.sourceforge.net/home/frs/project/s/sf/sf-mvn-plugins/m2-repo</url>
</repository>
<site>
<id>sourceforge-sf-mvn-plugins</id>
<name>Web Area</name>
<url>
sftp://web.sourceforge.net/home/groups/s/sf/sf-mvn-plugins/htdocs/${artifactId}
</url>
</site>
</distributionManagement>
Add similar code to settings.xml
<server>
<id>sourceforge-sf-mvn-plugins-svn</id>
<username>tmichel,sf-mvn-plugins</username>
<password>secret</password>
</server>
<server>
<id>sourceforge-sf-mvn-plugins</id>
<username>user,project</username>
<password>secret</password>
</server>
The main point for download is to use the wagon-http-sourceforge maven plugin - please see at: sf-mvn-plugins.sourceforge.net/wagon-http-sourceforge/FAQ.html
Please add the following code to your pom.xml
<repositories>
<repository>
<id>sourceforge-svn</id>
<name>SF Maven Plugin SVN Repository</name>
<url>http://sf-mvn-plugins.svn.sourceforge.net/svnroot/sf-mvn-plugins/_m2-repo/trunk</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>sourceforge-frs</id>
<name>SF Maven Plugin Repository</name>
<url>http://sourceforge.net/projects/sf-mvn-plugins/files/m2-repo</url>
</pluginRepository>
</pluginRepositories>
<build>
<extensions>
<extension>
<groupId>net.sf.maven.plugins</groupId>
<artifactId>wagon-http-sourceforge</artifactId>
<version>0.4</version>
</extension>
</extensions>
:
</build>
It looks like I am going to have to write this myself.
https://sourceforge.net/projects/wagon-sf/
After trying this a number of times, I finally got it to work -- with sftp not scp. This should work from a unix box (or Mac) -- I'm not sure about sftp clients for Windoze. I am using mvn version 2.2.0 and I don't think I have any special plugins installed. This deploys the various mvn packages to the Files section of my project page.
You'll need to change the following in your settings to get it to work:
user -- replace with your sourceforce username
secret -- replace with your password
ormlite -- replace with your project name
/o/or/ -- replace with the first char and first 2 chars of your project name
In my $HOME/.m2/settings.xml file I have the following for the SF server:
<server>
<id>sourceforge</id>
<password>secret</password>
<filePermissions>775</filePermissions>
<directoryPermissions>775</directoryPermissions>
</server>
I don't specify the username in the settings.xml file because it needs to be username,project and I want to deploy multiple packages to SF. Then, in my pom.xml file for the ormlite package I have the following:
<distributionManagement>
<repository>
<id>sourceforge</id>
<name>SourceForge</name>
<url>sftp://user,ormlite#frs.sourceforge.net:/home/frs/project/o/or/ormlite/releases
</url>
</repository>
<snapshotRepository>
<id>sourceforge</id>
<name>SourceForge</name>
<url>sftp://user,ormlite#frs.sourceforge.net:/home/frs/project/o/or/ormlite/snapshots
</url>
</snapshotRepository>
</distributionManagement>
Obviously the /releases and /snapshots directory suffixes can be changed depending on your file hierarchy.
Where timp = user and webmacro = project
scp url does not work:
scp://timp,webmacro#shell.sourceforge.net:/home/groups/w/we/webmacro/htdocs/maven2/
sftp url works:
sftp://timp,webmacro#web.sourceforge.net:/home/groups/w/we/webmacro/htdocs/maven2
or for project release artifacts:
sftp://timp,webmacro#web.sourceforge.net:/home/frs/project/w/we/webmacro/releases
scp will work to shell.sourceforge.net, but you have to create the shell before use with
ssh -t timp,webmacro#shell.sourceforge.net create
This really did not turn out to be that hard. First up I had the mvn site:deploy working following the instructions at this sourceforge site. Basically you start the sourceforge shell with
ssh -t user,project#shell.sourceforge.net create
That will create the shell at their end with a folder mounted to your project on a path such as (depending on your projects name):
/home/groups/c/ch/chex4j/
In that shell I on the sourceforge server I created a folder for my repo under the project apache folder "htdocs" with
mkdir /home/groups/c/ch/chex4j/htdocs/maven2
In my settings.xml I set the username and password to that shell server so that maven can login:
<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/">
<servers>
<server>
<id>chex4j.sf.net</id>
<username>me,myproject</username>
<password>password</password>
<filePermissions>775</filePermissions>
<directoryPermissions>775</directoryPermissions>
</server>
</servers>
</settings>
In the pom.xml you just need your distibutionManagement section setup to name the server by ID that you set the password for in your settings file:
<distributionManagement>
<site>
<id>chex4j.sf.net</id>
<url>scp://shell.sourceforge.net/home/groups/c/ch/chex4j/htdocs/
</url>
</site>
<repository>
<id>chex4j.sf.net</id>
<name>SourceForge shell repo</name>
<url>scp://shell.sourceforge.net/home/groups/c/ch/chex4j/htdocs/maven2</url>
</repository>
</distributionManagement>
There the repository entry is the one for the mvn deploy command and the site entry is for the mvn site:deploy command. Then all I have to do is start the shell connection to bring up the server side then on my local side just run:
mvn deploy
which uploads the jar, pom and sources and the like onto my sourceforge projects website. If you try to hit the /maven2 folder on your project website sourceforge kindly tell you that directory listing is off by default and how to fix it. To do this on the server shell you create a .htaccess file in your htdocs/maven2 folder containing the following apache options
Options +Indexes
Then bingo, you have a maven repo which looks like:
http://chex4j.sourceforge.net/maven2/net/sf/chex4j/chex4j-core/1.0.0/
Your sf.net shell it shuts down after a number of hours to not hog resources; so you run the "ssh -t ... create" when you want to deploy the site or your build artifacts.
You can browse all my maven project code under sourceforge to see my working settings:
http://chex4j.svn.sourceforge.net/viewvc/chex4j/branches/1.0.x/chex4j-core/
SCP URL does work. But do not use ":" after server name. MVN tries to read the following test as integer (port number).
You do not need to establish tunnels as simbo1905 did.
The Maven SourceForge plug-in does not work with Maven 2. Also I believe this plug-in uses FTP which is no longer supported.
I found that CruiseControl can upload releases to SFEE and also works with Maven and Maven2