correct way to use scm element in pom.xml? - eclipse

I'm having some problem with Maven's scm element and subversion.
I added the following to my pom.xml:
<scm>
<connection>scm:svn:svn+ssh://user#x.y.z/repositorypath</connection
<developerConnection>scm:svn:svn+ssh://user#x.y.z/repositorypath</developerConnection>
<url>scm:svn:svn+ssh://user#x.y.z/repositorypath</url>
</scm>
in order to use svn revision in my JAR files manifest.
But when I run "clean package" on that, I get this:
[ERROR] Provider message:
[ERROR] The svn command failed.
[ERROR] Command output:
[ERROR] svn: The path 'C:\xxxxxx' appears to be part of a Subversion 1.7 or greater
working copy. Please upgrade your Subversion client to use this
working copy.
Still, subversion seems to work great otherwise: I can checkout, update and commit just fine from Eclipse. I also tried running upgrade for my working copy, but it was already upgraded.
Our subversion server is 1.6.11 and my Eclipse uses Subclipse 1.8. Java HL is 1.7.2
So what should I change to get this to work? Also, is there a way to omit the username from the svn+ssh url? So that the pom.xml could be use by all developers?
EDIT:
I should have mentioned that I also added buildnumber-maven-plugin to my pom.xml when I started getting this error. I now looks to me as if that plugin is unable to deal with my subversion version. Oddly it's homepage here claims that the newest is 1.1-SNAPSHOT, while I can't find newer than 1.0 (must I enable using snapshots explicitly somehow?)

You have used the scm element correctly in your pom.xml
One way to avoid having to handle username/password is to configure an anonymous read-only access to your repository to be used for build and similar purposes. Otherwise, the SO references alluded to above gives some directions on how to externalize at least the password, if not the username.
As for the error message, you see this because of difference in the versions of the subversion client used by Eclipse and maven scm plugin.
From the error message, it looks like Eclipse has created (some of) the subversion folders (.svn) in the newer (1.7) format. It looks like maven scm client uses the 1.6 format as per this.
One way to fix the problem is checkout the project using maven scm plugin itself or an older subversion client.

To omit the username, look for the file .ssh/config in your %HOME% directory, add the following two lines to it (leave any existing lines alone):
Host x.y.z
User user

Related

Is there a way to build Scala 2.10.3 from source code?

I know it's a very old thing now, but I need it.
I download scala-sources from the link, unpacking on Ubuntu 20.04. Also I download Ant 1.7.0 and install it. Also I download Apache maven 2.2.1 (or I tried maven 3.5.0) and install it.I also use jdk1.8.0.
I am trying to run "ant" or "ant build" from the scala directory, and something happens, but the build failed for the following reasons:
failed to create task or type scalacfork
Build failed
The following messages also appear at the top:
[taskdef] java.util.zip.ZipException: zip file is empty
(several times)
...
[WARNING] POM for 'biz.aQute:bndlib:pom:1.43.0:compile' is invalid.
...
[taskdef] Could not load definitions from resource scala/tools/ant/sabbus/antlib.xml. It could not be found.
I understand that many things are no longer available now and are definitely not supported, but maybe someone will tell me a way to get the result.
Maybe I can download the necessary data and manually build scala? I'm new to this and don't quite understand what and where I can change. And I can't use a newer version of scala because of work.
I hope for any help. Thank you in advance.
Yes, it is possible. Although it requires some patches in the build process and a few workarounds.
Read the README.rst, it contains some information on how builds are structured
Run git init, git add ., git commit as the build uses some git info (commit hash, etc) during build. It may be not needed for release, but I have not tried.
You need either JDK 1.6 or JDK 1.7. It can't be built on the 1.8 JDK (compilation fails if you remove checks from build.xml). And on 1.7 it says it can't build swing library so you won't be able to build distribution.
Fix the tools/binary-repo-lib.sh and change URLs to https otherwise fetching artifacts will fail. Maybe you have to remove some of the curl arguments to see what happens, maybe it won't be required.
Run pull-binary-libs.sh
Fix build.xml to use https protocol. This is based on the Official usage documentation. You have to define repository before the first artifact:dependencies task in the file (I did that in the same block).
<artifact:remoteRepository id="central" url="https://repo1.maven.org/maven2" />
Then you have to tell every artifact:dependency task to use that repo by adding the remoteRepository element, the tasks should look like
<artifact:dependencies pathId="extra.tasks.classpath" filesetId="extra.tasks.fileset">
<dependency groupId="biz.aQute" artifactId="bnd" version="1.50.0"/>
<remoteRepository refid="central"/>
</artifact:dependencies>
I think this was enough for me to build it using ant build on JDK 1.7 (apparently, swing libs were not built).
But probably the easier way would be to just download prebuild Scala version or tell your build tool to use the Scala version you want.

Maven fixing broken dependencies

I just checked out maven based java project from svn to local box in eclipse where maven 3.0.2 is available. However while reviewing class path configuration many of dependencies are broken such as org.restlet-2.0.15.jar. Strange part is C:/Users/daeyoung/.m2/repository has that broken jar file but .lastUpdated is appended. After reading many posts from WWW, the way I understood to fix the problem is delete *.lastUpdated file then re-download it from central repo.
But when I reviewed pom.xml file there is no mention of repository (strange...) and as soon as I delete *.lastUpdated file, it comes back (e.g. org.restlet-2.0.15.jar.lastUpdated).
I am new to Maven.
I'd appreciate if someone can guide me to a right direction to fix this problem.
[update]
I created following user settings.xml file under /Users/daeyoung/.m2/ directory. I thought at least that would take care of downloading org.restlet package.
However when I ran mvn command (literally mvn) inside of project folder, system was saying..
I don't want to modify pom.xml file but rather via user settings.xml I thought I could connect to maven restlet repo and download specified target package but I am not sure what I am missing in here. I think contents of settings.xml is not correct.
I just want to say thanks to all who have given me advice. First I was not well equipped to understand the advice but more I looked at the problem/read about maven articles. It was clear what needs to be done to fix the problem.
Bottom line is I manually downloaded dependencies to ${user_name}/.m2/repository for missing jars. I configured ${MAVEN_HOME}/conf/settings.xml to point to local repository then I ran mvn validate/clean/package sequentially from eclipse via m2e plugin (or I could have done same thing from command line).

Get a Hudson build with Maven

I have moved to Maven recently, and since it works fine for resources up to date in some repositories, it's not obvious for non-maven ones.
I have something very simple to achieve (in the idea), but that I am unable to express so far:
I need to compile my code with a jar that can be found here:
https://hudson.eclipse.org/hudson/view/WTP/job/cbi-wtp-wst.xsl.psychopath/ws/sourceediting/plugins/org.eclipse.wst.xml.xpath2.processor/target/
What do I have to put in my pom.xml to make Maven downloading the .jar + the java source + the javadoc, and eventually the other dependencies (actually IBM ICU, Xerces, JavaCup) that are mentionned in the supplied MANIFEST ?
I have read lots of documents, including those with a plugin called Tycho, but nothing helpfull for that simple task.
Thanks for your help.
Maven only works well if all artifacts needed for a build are contained in the local or a configured remote repository. So you have to do the following jobs:
Find out if eclipse plugins are deployed in a Maven2-style repository, and what the URL of that repository is.
Then find out which version of that plugin (artifact) you need.
Maven allows you to configure what will be copied locally: jar file, sources and api doc if you want to.
Maven should then be responsible to download as well all needed artifacts for the plugin you want to use.
After looking at the contents of the URL you gave us (especially the file p2content.xml), it looks like there should be a repository. I searched for the maven repository for org.eclipse.wst.xml.xpath2 and found the URL http://maven.eclipse.org/nexus/content/repositories/testing/org/eclipse/wst/org.eclipse.wst.xml.xpath2/1.1.0/org.eclipse.wst.xml.xpath2-1.1.0.pom
So the repository you are searching for is located at http://maven.eclipse.org/nexus. Just open it, search for example for xpath2, and Nexus, the repository software used there will you show the available artifacts. Depending on what was deployed to that repository, it may contain only the library, or have even sources and JavaDoc bundled with it. For the example above (xpath2), there seems to be only the POM itself and the library (the jar). If you take as example junit, you will find all versions and variants, even with sources.jar and javadoc.jar.
After you have found the needed artifact, you can include it in the dependency section of your POM. And you have to add http://maven.eclipse.org/nexus as a remote repository in the configuration of your Maven installation.
The question and its answer Get source JARs from Maven repository explain how to fetch sources and JavaDoc (if they are available).
You need a maven repository which contains this artifacts (i don't know, if Eclipse hosts a repository for their projects). You can also deploy manually the artifacts to a local repository on your computer.

Where can I obtain the maven-source-plugin?

I checked out an open-source project from SourceForge's SVN source control using the Eclipse Maven plugin. After it checks out, I get this error in the pom.xml file:
Error resolving version for plugin
'org.apache.maven.plugins:maven-source-plugin' from the repositories
[local (C:\Documents and Settings\thomas.owens\.m2\repository),
central (http://repo1.maven.org/maven2)]: Plugin not found in any
plugin repository
I'm fairly new to Maven, but I followed the installation instructions for Apache Maven and the Eclipse plugin. It seems weird that this plugin would not be found in the central plugin repository for Maven or my local repository, when I can clearly see a directory located at C:\Documents and Settings\thomas.owens\.m2\repository\org\apache\maven\plugins\maven-source-plugin that contains a single resolver-status.properties file.
Any thoughts as to why this plugin might not be found and where I can find it?
The problem that I was encountering was not an issue with the maven-source-plugin, but incorrect proxy settings that was preventing the connection to the repositories. The answers to this question on the use of Maven with a proxy helped me to find the mistake and correct it.
That plugin is in the central repository.
Perhaps you just need to run with -U to update:
mvn -U clean install
Or in Eclipse: right-click on the project, select Maven-> Update Dependencies, (perhaps) Maven-> Update Project Configuration
Check if you are able to see Maven in Eclipse, Window > Preferences.
If so, select Maven and go to installations and check if the folder, in where maven was installed, is properly set. Then, set your setting.xml file, it should be in /(maven installation folder)/conf/
Then, right click in your project go to Maven > Update Maven Dependencies.
Did it help?
Which project?
Perhaps there is a bug in their pom.
Or perhaps they require a 'standardized' develop environment with specific environment variables set, or a specific setting in user.home/.m2/settings.xml

How to cheat the SVN client version used to checkout a working copy

I am working with on a project managed with Subversion.
I am using the Subclipse plugin for that : (v1.6.16)
He is the one that did the checkout for me.
Now, I need to run some command line stuff on Maven (the Release plugin BTW), that calls a command line version of SVN.
For that, I have downloaded the SlikSVN Windows package (the last version v1.6.13).
However, Maven is complaining (with good reason I would say) that my subversion client is too old for my working copy.
Here is the message I get :
[INFO] Unable to commit files Provider
message: The svn command failed.
Command output: svn: This client is
too old to work with working copy
'D:\Users\raphael\eclipse-workspace\base-lib';
please get a newer Subversion client
I guess that 1.6.13 to 1.6.16 might be some very minor changes.
Where does SVN actually store the version number he used for the checkout ?
I would like to trick him into thinking I actually used a 1.6.13 client.
Thanks in advance for your help.
Raphaƫl
Double-check that your SlikSVN 1.6.13 client is actually in the PATH. My guess is you have a copy of Subversion 1.4 or 1.5 in the PATH, and that is what's screwing up the operation for Maven.
As far as I know, working copy formats do not change within a major version. You don't want to trick svn, you just need to make sure the right version is available for Maven (Any version of 1.6 should do - it shouldn't be particular about 1.6.13 vs 1.6.11)
It sounds that you misconfigured the Subclipse Plugin not to use the newest release. Take a look into the configuration. Windows -> Preferences -> Team -> SVN -> SVN Interface (be sure to set this to SVNKit 1.3.X). This might be the problem.
Have you called
svn --version
on command line ? There you get the information about the version of the installed SVN client.
I think, you cannot achieve this because the SVN version gets actually sent by client (i.e. the output of svn --version and is not stored anywhere outside the program.