让我的ANT问题建立OS升级后的工作 [英] Problems getting my ANT builds to work after OS upgrade

查看:143
本文介绍了让我的ANT问题建立OS升级后的工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近升级从Mint12我的系统Mint14并有严重的问题,有让我的老项目,在新系统上很好地工作。总结这一切:


  • GOT Mint14很好地工作,并安装了我所有的必备软件(Eclipse中,ANT等)

  • 从我的备份磁盘恢复我的文件

  • 设置了甲骨文JDK作为默认的Java版本

  • 经过我的项目的新副本从SVN

  • 更新了构建文件的所有路径,以反映新USER_ID

这一切都很好,但我的Ant构建似乎已经搞砸了,不知何故,这样,当我尝试建立我的项目,我收到以下错误:

 〜/ new_workspace / MY_PROJECT $蚂蚁DIST
构建文件:/home/my_userid/new_workspace/my_project/build.xml
  [的taskdef]无法加载从资源网/ SF / antcontrib / antlib.xml定义。它不能被发现。在里面:编译:
    [javac的] /home/my_userid/new_workspace/my_project/build.xml:246:警告:includeantruntime没有设置,默认为build.sysclasspath =最后;设置为false可重复的构建静态的:距:
      [SVN]<状态>开始...
      [SVN]的svn:此客户端版本太旧,工作副本的/ home / my_userid / new_workspace / MY_PROJECT'工作;请取得更新的Subversion客户端
      [SVN]的svn:此客户端版本太旧,工作副本的/ home / my_userid / new_workspace / MY_PROJECT'工作;请取得更新的Subversion客户端
      [SVN]<状态>失败!构建失败
/home/my_userid/new_workspace/my_project/build.xml:104:无法获取的/ home的状态/ my_userid / new_workspace / MY_PROJECT总时间:0秒

我拿着通知书太旧有工作拷贝......但是当我检查的svn --version 我看到它是1.7.5应一切都好。注意,在服务器上SVN版本的未同时改变。一种理论是,该项目(通过Eclipse签出,使用Subclipse 1.6)不与版本ANT工作通过命令行使用,但在这种情况下,客户端版本是不是太旧了,而是太新了!?难道是值得向下分级颠覆?

否则什么事情是问题,我该怎么解决呢?是否有其他共同的问题,我应该检查,以确保该项目工程,因为它应该(可能发行版升级/迁移过程中发生的)? (下面是构建文件中的相关内容)


此位定义了svn绑定

 <路径ID =svnant.classpath>
    <文件集DIR =/家/ my_userid /赵军阳张志利/ lib目录>
      <包括姓名=svnant.jar/>
      <包括姓名=svnClientAdapter.jar/>
      <包括姓名=svnjavahl.jar/>
      <! - <包括姓名=svnkit.jar/>试过这很好,但没有喜悦 - >
    < /文件集>
  < /路径>

在DIST目标的相关位:

 <目标名称=DIST
          依赖=编译,静描述=编译和构建jar文件>    < MKDIR DIR =$ {} DIST/>
    < buildnumber文件=project-version.properties/>
    <属性名=version.number值=$ {major.version} $ {minor.version} $ {} micro.version。/>
    <&SVN GT;
      <状态路径=。
              lastChangedRevisionProperty =rev.number/>
     <信息目标=。 />
    < / SVN>
    ...


解决方案

我看到的第一个问题:

  [的taskdef]无法加载从资源网/ SF / antcontrib / antlib.xml定义。它不能被发现。

这是告诉我,你有一个<的taskdef> 任务一些地方在你的的build.xml 文件,而且它不再能找到失踪的可选Ant的罐子。

我的理论:在旧版本的Ant在 $ ANT_HOME / lib目录,你安装了蚂蚁的Contrib罐子。因为这个目录是在Ant的 $ CLASSPATH 默认情况下,你没有在你的&LT指定它;的taskdef> 任务线,所以它看起来是这样的:

 <的taskdef资源=网/ SF / antcontrib / antcontrib.properties/>

我总是建议你总是把这些可选任务jar文件到您的项目。这样一来,任何人都无权的安装的这些罐子,以便为他们的工作,因为他们的项目是早已:


  • 请一个目录 /家庭/ my_userid / new_workspace / MY_PROJECT /的antlib / AC ,所以你的项目将有一个目录的antlib / AC 在里面。

  • 在这个目录,下载并安装<一href=\"http://sourceforge.net/projects/ant-contrib/files/ant-contrib/1.0b3/ant-contrib-1.0b3-bin.tar.gz/download\"相对=nofollow>蚂蚁的contrib-1.03.jar

  • 现在,改变你的&LT;的taskdef方式&gt; 来包括这个jar在它的类路径

这应该是这样的:

 &LT;属性名=antlib.dir值=$ {BASEDIR} /的antlib/&GT;
&LT;属性名=蚁contrib.libVALUE =$ {} antlib.dir / AC/&GT;&LT;的taskdef资源=/ NET /平方英尺/ antcontrib / antlib.xml&GT;
    &LT;&类路径GT;
        &LT;文件集DIR =$ {蚁contrib.lib /&GT;
    &LT; /类路径&GT;
&LT; /&的taskdef GT;

添加的antlib / AC /蚂蚁的contrib-1.03b.jar 您poroject。这样一来,如果有人来检查你的项目,它建立即使他们没有下载和安装蚂蚁contrib请罐到他们的机器。

请注意我用 ant.xml ,而不是 antcontrib.properties 。这使我获得了&lt;用于/&GT; 任务,而不是旧的&LT;的foreach&GT; 任务。整个事情是这样的蚂蚁安装的Contrib 页面上解释说。


现在其他错误:

 距离:
      [SVN]&LT;状态&gt;开始...
      [SVN]的svn:此客户端版本太旧,工作副本的/ home / my_userid / new_workspace / MY_PROJECT'工作;请取得更新的Subversion客户端
      [SVN]的svn:此客户端版本太旧,工作副本的/ home / my_userid / new_workspace / MY_PROJECT'工作;请取得更新的Subversion客户端
      [SVN]&LT;状态&gt;失败!

首先,真正的问题是,颠覆您的客户端版本实际上就是太新而非太旧。蚂蚁内部颠覆正在使用的可能要老1.6版本Subversion工作dirctory的 svnjavahl.jar 客户端。同时,你已经签出了Subvfersion客户端的版本使用 1.7版本。 Eclipse可以通过安装JavaHL,SVNKit,甚至使用命令行客户端做的Subversion检出。

看看你签出目录的目录结构,看看如果这些声名狼藉的的.svn 目录分散在每个目录或只是在根目录下。如果的.svn 目录只是你的工作目录的根目录下,你有颠覆的1.7.x版本做结账和你的Subversion罐子蚂蚁是用欲望年长1.2〜1.6.x的工作目录的版本。如果你看到散落在你的工作目录的的.svn 目录,那么你的初始结账时使用旧的工作目录版本和Ant是使用新版本。

所以,这里是在任何情况下的解决方案:删除整个颠覆,从提交的东西你的的build.xml 文件。首先,它是一个 构建文件,然后不应该做任何形式的在你的版本控制系统的变化。这是不好的形式。唯一的变化,应在用户希望他们是因为他们执行的build.xml文件不假思索做的,而不是

所有的二,你不应该存储你的资料库而衍生的输出。只有存储源,而不是东西,这而得。相反,使用一个构建系统如詹金斯来处理整个构建和分销业务为您服务。

保存在版本控制的分布没有做任何好处。你可以不看历史分布和理解发生了哪些变化。你不能做的分布的两个版本之间的差异,看到的变化。你能说的最好的是,它是一个方便的地方找到它。问题是,每次分配你做一个新版本的时间采取了很多的房间,过了一段时间,你没有任何更多其中的大部分。在Subversion中,有没有简单的方法来删除它们,所以他们刚开始占用了大量的空间。

让我们说你有一个100MB的温和的分布,你保存你的每日构建。假设每年200构建(没有建立在周末或假期),您要添加的2Gb的空间,每年你的资料库。

通过詹金斯,可以存储你的发行版里面的詹金斯建立和詹金斯甚至会删除旧的,不重要的分布自动为您。分配现在与用它构建有关,你可以看到不同的基础之上。

但是,如果这些分布jar文件的其他项目需要什么?使用依赖管理系统,如常春藤和本地仓库一样的的Nexus Artifactory的来管理它。

直接从詹金斯任务;

即使你不想去那么远,你仍然可以拉使用&LT需要的jar;获取/过夜。詹金斯提供您的最后一个良好的神器环节,而这可能会在你的构建系统来拉你想要的罐子中。

希望这有助于。

I recently upgraded my system from Mint12 to Mint14 and had severe issues with getting my old projects to work nicely on the new system. To summarize it all:

  • Got Mint14 to work nicely and installed all my essential software (Eclipse, ANT etc)
  • Restored my files from my backup disk
  • Set up Oracle JDK as the default java version
  • Checked out a fresh copy of my project from SVN
  • Updated all paths in the build file to reflect the new user_id

That's all good but my ant build seems to have been messed up, somehow, such that when I try to build my project I get the following error:

~/new_workspace/my_project $ ant dist
Buildfile: /home/my_userid/new_workspace/my_project/build.xml
  [taskdef] Could not load definitions from resource net/sf/antcontrib/antlib.xml. It could not be found.

init:

compile:
    [javac] /home/my_userid/new_workspace/my_project/build.xml:246: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

static:

dist:
      [svn] <Status> started ...
      [svn] svn: This client is too old to work with working copy '/home/my_userid/new_workspace/my_project'; please get a newer Subversion client
      [svn] svn: This client is too old to work with working copy '/home/my_userid/new_workspace/my_project'; please get a newer Subversion client
      [svn] <Status> failed !

BUILD FAILED
/home/my_userid/new_workspace/my_project/build.xml:104: Can't get status of /home/my_userid/new_workspace/my_project

Total time: 0 seconds

I took notice of the "too old to work with working copy..." but when I check svn --version I see that it's 1.7.5 which should be alright. Note that the SVN version on the server has not changed meanwhile. A theory is that the project (checked out via Eclipse, using Subclipse 1.6) doesn't work with the version ANT uses via command line, but in that case the client version is not too old, but rather too new!? Would it be worth "down-grading" Subversion?

Otherwise what could to be the problem and how can I solve it? Are there other common issues (that might occur during distro upgrade/migration) which I should check in order to make sure the project works as it should? (Below are the relevant bits of the build file)


This bit defines the svn bindings

  <path id="svnant.classpath">
    <fileset dir="/home/my_userid/.ant/lib">
      <include name="svnant.jar" />
      <include name="svnClientAdapter.jar" />
      <include name="svnjavahl.jar" />
      <!-- <include name="svnkit.jar" /> tried this as well but no joy -->
    </fileset>
  </path>

The relevant bit in the "dist" target:

  <target name="dist"
          depends="compile,static" description="Compiles and builds jar files">

    <mkdir dir="${dist}"/>
    <buildnumber file="project-version.properties"/>
    <property name="version.number" value="${major.version}.${minor.version}.${micro.version}"/>
    <svn>
      <status path="."
              lastChangedRevisionProperty="rev.number" />
     <info target="." />
    </svn>
    ...

解决方案

I see the first problem:

[taskdef] Could not load definitions from resource net/sf/antcontrib/antlib.xml. It could not be found.

This is telling me that you have a <taskdef> task some where in your build.xml file, and that it can no longer find the missing optional Ant jar.

My theory: In your old Ant version under $ANT_HOME/lib, you installed the Ant-Contrib jar. Since this directory is in Ant's $CLASSPATH by default, you didn't have to specify it in your <taskdef> task line, so it looks like this:

<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>

I always recommend that you always put these optional task jars into your project. This way, no one has to install these jars in order for them to work since they're already in the project:

  • Make a directory /home/my_userid/new_workspace/my_project/antlib/ac, so your project will have a directory antlib/ac in it.
  • In this directory, download and install ant-contrib-1.03.jar
  • Now change your <taskdef> to include this jar in its classpath.

It should look like this:

<property name="antlib.dir"       value="${basedir}/antlib"/>
<property name="ant-contrib.lib"  value="${antlib.dir}/ac"/>

<taskdef resource="/net/sf/antcontrib/antlib.xml">
    <classpath>
        <fileset dir="${ant-contrib.lib/>
    </classpath>
</taskdef>

Add antlib/ac/ant-contrib-1.03b.jar to your poroject. This way, if someone checks out your project, it builds even if they didn't download and install the ant-contrib jar into their machine.

Note I'm using ant.xml and not antcontrib.properties. This gives me access to the <for/> task instead of the older <foreach> task. The whole thing is explained on this Ant-Contrib Installation page.


Now the other error:

dist:
      [svn] <Status> started ...
      [svn] svn: This client is too old to work with working copy '/home/my_userid/new_workspace/my_project'; please get a newer Subversion client
      [svn] svn: This client is too old to work with working copy '/home/my_userid/new_workspace/my_project'; please get a newer Subversion client
      [svn] <Status> failed !

First, the real issue is that your client version of Subversion is actually too new and not too old. Subversion inside of Ant is using the svnjavahl.jar client which probably wants the old 1.6 version of the Subversion working dirctory. Meanwhile, the version of the Subvfersion client you have checked out is using the newer 1.7 version. Eclipse can do Subversion checkouts by installing JavaHL, SVNKit, or even using the command line client.

Take a look at the directory structure of your checked out directory and see if those infamous .svn directories are scattered in each directory or just in the root directory. If the .svn directory is only under the root directory of your working directory, you have a 1.7.x version of Subversion doing the checkout and your Subversion jar that Ant is using wants the older 1.2 to 1.6.x version of the working directory. If you do see those .svn directories scattered throughout your working directory, then your initial checkout is using the old working directory version and Ant is using the new version.

So, here is the solution in any case: Remove the whole Subversion commit stuff from your build.xml file. First of all, it's a build file, and should not be doing any sort of changes in your version control system. That's bad form. Changes should only be done when the user wants them to, and not because they executed the build.xml file without thinking.

Second of all, you should not be storing derived build output in your repository. Only store the source, and not stuff that's derived. Instead, use a build system like Jenkins to handle the whole build and distribution business for you.

Saving distributions in version control isn't doing you any good. You can't look at the distribution history and understand what changes were made. You can't do a diff between two versions of the distribution and see the changes. The best you can say is that it's a convenient place to find it. The problem is that distributions take a lot of room every time you do a new version, and after a while, you don't most of them any more. In Subversion, there's no easy way to remove them, so they just start taking up a ton of space.

Let's say you have a modest distribution of 100Mb that you're storing for your daily builds. Assume 200 builds per year (no builds on Weekends or holidays) and you're adding 2Gb of space to your repository per year.

With Jenkins, you can store your distributions inside the Jenkins builds, and Jenkins will even remove older, unimportant distributions automatically for you. The distribution is now associated with the build that used it, and you can see the differences between the builds.

But, what if these distributions are jar files that other projects need? Use a dependency management system like Ivy and a local Maven repository like Nexus or Artifactory to manage it.

Even if you don't want to go that far, you could still pull the required jars using the <get/> task directly from Jenkins. Jenkins supplies you with the last good artifact link, and this could be used in your build system to pull the jars you want.

Hope this helps.

这篇关于让我的ANT问题建立OS升级后的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆