You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

get-m2.xml 3.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?xml version="1.0"?>
  2. <!--
  3. =======================================================================
  4. Build file to fetch maven2 tasks; extracted from (Ant's) fetch.xml
  5. Copyright (c) 2005-2006 The Apache Software Foundation. All rights
  6. reserved.
  7. =======================================================================
  8. -->
  9. <project name="get-m2" default="get-m2" basedir=".">
  10. <description>
  11. This build file downloads the Maven2 Ant tasks,
  12. and installs them in the location specified by the m2.dest.dir property.
  13. You may need to set proxy settings. On Java1.5, Ant tries to get
  14. this from the OS, unless you use the -noproxy option.
  15. Proxies can be configured manually setting the JVM proxy values in the
  16. ANT_OPTS environment variable.
  17. For example, to set the proxy up in the tcsh shell, the command would be
  18. something like:
  19. For csh/tcsh:
  20. setenv ANT_OPTS "-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080"
  21. For bash:
  22. export ANT_OPTS="-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080"
  23. For Windows, set the environment variable in the appropriate dialog box
  24. and open a new console. or, by hand
  25. set ANT_OPTS = -Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080
  26. </description>
  27. <property file="get-m2.properties" />
  28. <property name="m2.antlib.resource"
  29. value="org/apache/maven/artifact/ant/antlib.xml" />
  30. <property name="m2.antlib.uri"
  31. value="antlib:org.apache.maven.artifact.ant" />
  32. <macrodef name="require">
  33. <attribute name="property" />
  34. <sequential>
  35. <fail unless="@{property}">$${@{property}} not specified</fail>
  36. </sequential>
  37. </macrodef>
  38. <target name="probe-m2">
  39. <require property="m2.dest.dir" />
  40. <require property="m2.jar.name" />
  41. <!-- Look for M2 ant tasks in our classpath-->
  42. <property name="m2.artifact" location="${m2.dest.dir}/${m2.jar.name}" />
  43. <available property="m2.antlib.found" resource="${m2.antlib.resource}" />
  44. <condition property="m2.antlib.typefound">
  45. <typefound name="${m2.antlib.uri}:artifact" />
  46. </condition>
  47. <available property="m2.artifact.found" file="${m2.artifact}" type="file" />
  48. </target>
  49. <target name="download-m2" depends="probe-m2" unless="m2.artifact.found">
  50. <require property="m2.antlib.url" />
  51. <echo>Downloading to ${m2.dest.dir}</echo>
  52. <mkdir dir="${m2.dest.dir}" />
  53. <!-- fetch M2 ant tasks into our repository, if it is not there-->
  54. <get src="${m2.antlib.url}"
  55. dest="${m2.artifact}"
  56. verbose="true"
  57. usetimestamp="false" />
  58. </target>
  59. <target name="dont-validate-m2-checksum" depends="probe-m2"
  60. if="m2.artifact.found">
  61. <property name="checksum.equal" value="true" />
  62. </target>
  63. <target name="validate-m2-checksum"
  64. depends="download-m2,dont-validate-m2-checksum"
  65. if="m2.sha1.checksum" unless="m2.artifact.found">
  66. <checksum file="${m2.artifact}"
  67. algorithm="SHA"
  68. property="${m2.sha1.checksum}"
  69. verifyProperty="checksum.equal" />
  70. </target>
  71. <target name="checksum-mismatch" depends="validate-m2-checksum"
  72. if="m2.sha1.checksum" unless="checksum.equal">
  73. <delete file="${m2.artifact}" />
  74. <fail>
  75. Failed to verify the downloaded file ${m2.antlib.url}" against the checksum
  76. coded into libraries.properties.
  77. The local copy has been deleted, for security reasons
  78. </fail>
  79. </target>
  80. <target name="checksum-match" depends="checksum-mismatch"
  81. unless="m2.antlib.found">
  82. <taskdef classpath="${m2.artifact}" resource="${m2.antlib.resource}"
  83. uri="${m2.antlib.uri}" />
  84. </target>
  85. <target name="get-m2" depends="checksum-match"
  86. description="Download the Maven2 Ant tasks" />
  87. </project>