分类
git jvm Shell SpringFramework ubuntu

Building Spring Framework 3.1.x With Ant

内容纲要

Building Spring Framework 3.1.x With Ant

Prerequisites

  1. git 2.17+
  2. Java 6
  3. Ant 1.7+

Building

Environment Configuration

## 设置当前jdk为jdk6
export JAVA_HOME=/usr/lib/jvm/java-6-oracle
export PATH=${JAVA_HOME}/bin:${PATH}
export CLASSPATH=.:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar:${CLASSPATH}

## 确认环境变量正常
env | grep -i java

Clone Project

## clone项目
git clone https://github.com/spring-projects/spring-framework.git
## 进入项目目录
cd spring-framework

Show Branch

## 查看分支
git branch --all
* master
  remotes/origin/3.0.x
  remotes/origin/3.1.x
  remotes/origin/3.2.x
  remotes/origin/4.0.x
  remotes/origin/4.1.x
  remotes/origin/4.2.x
  remotes/origin/4.3.x
  remotes/origin/5.0.x
  remotes/origin/5.1.x
  remotes/origin/HEAD -> origin/3.1.x
  remotes/origin/beanbuilder
  remotes/origin/conversation
  remotes/origin/gh-pages
  remotes/origin/issues/gh-19930
  remotes/origin/master

Ant Building

## 检出 3.1.x 分支
git checkout -b 3.1.x

## 查看当前分支
git branch 
* 3.1.x
  master

## 进入构建脚本目录
cd build-spring-framework

## 开始构建
ANT_OPTS="-server -Xms256m -Xmx512m -XX:PermSize=256M -XX:MaxPermSize=256m" \
ant -v clean clean-integration jar package 2>&1 | \
tee ../../building_`date +%Y%m%d_%H%M%S`.log

Install Maven

## 将构建好的jar包安装到本地Maven仓库
ANT_OPTS="-server -Xms256m -Xmx512m -XX:PermSize=256M -XX:MaxPermSize=256m" \
ant -v install-maven install-maven-central 2>&1 | \
tee ../../install-maven-`date +%Y%m%d_%H%M%S`.log

Q&A

java.lang.OutOfMemoryError: PermGen space

Build Log

Caught an exception while logging the end of the build.  Exception was:
java.lang.OutOfMemoryError: PermGen space
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at org.apache.tools.ant.DefaultLogger.formatTime(DefaultLogger.java:328)
    at org.apache.tools.ant.DefaultLogger.buildFinished(DefaultLogger.java:177)
    at org.apache.tools.ant.Project.fireBuildFinished(Project.java:2112)
    at org.apache.tools.ant.Main.runBuild(Main.java:878)
    at org.apache.tools.ant.Main.startAnt(Main.java:236)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:287)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
There has been an error prior to that:
/opt/workspace/github.com/osp-spring/spring-3.1.x/spring-build/multi-bundle/publish.xml:43: The following error occurred while executing this line:
/opt/workspace/github.com/osp-spring/spring-3.1.x/spring-build/multi-bundle/common.xml:86: The following error occurred while executing this line:
/opt/workspace/github.com/osp-spring/spring-3.1.x/spring-build/common/publish.xml:81: java.lang.OutOfMemoryError: PermGen space
    at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:585)
    at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:404)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
    at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:352)
    at org.apache.tools.ant.Target.execute(Target.java:437)
    at org.apache.tools.ant.Target.performTasks(Target.java:458)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1406)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1377)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1261)
    at org.apache.tools.ant.Main.runBuild(Main.java:857)
    at org.apache.tools.ant.Main.startAnt(Main.java:236)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:287)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
Caused by: /opt/workspace/github.com/osp-spring/spring-3.1.x/spring-build/multi-bundle/common.xml:86: The following error occurred while executing this line:
/opt/workspace/github.com/osp-spring/spring-3.1.x/spring-build/common/publish.xml:81: java.lang.OutOfMemoryError: PermGen space
    at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:585)
    at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:445)
    at org.apache.tools.ant.taskdefs.SubAnt.execute(SubAnt.java:310)
    at org.apache.tools.ant.taskdefs.SubAnt.execute(SubAnt.java:225)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
    at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:352)
    at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:67)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
    at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:352)
    at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:401)
    ... 16 more
Caused by: /opt/workspace/github.com/osp-spring/spring-3.1.x/spring-build/common/publish.xml:81: java.lang.OutOfMemoryError: PermGen space
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116)
    at org.apache.tools.ant.Task.perform(Task.java:352)
    at org.apache.tools.ant.Target.execute(Target.java:437)
    at org.apache.tools.ant.Target.performTasks(Target.java:458)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1406)
    at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:36)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1261)
    at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:442)
    ... 32 more
Caused by: java.lang.OutOfMemoryError: PermGen space
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at org.apache.tools.ant.AntClassLoader.defineClassFromData(AntClassLoader.java:1148)
    at org.apache.tools.ant.AntClassLoader.getClassFromStream(AntClassLoader.java:1316)
    at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1372)
    at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1333)
    at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1088)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at org.codehaus.plexus.component.repository.io.PlexusTools.buildConfiguration(PlexusTools.java:55)
    at org.codehaus.plexus.DefaultPlexusContainer.initializeConfiguration(DefaultPlexusContainer.java:1067)
    at org.codehaus.plexus.DefaultPlexusContainer.initialize(DefaultPlexusContainer.java:636)
    at org.codehaus.plexus.embed.Embedder.start(Embedder.java:216)
    at org.codehaus.plexus.embed.Embedder.start(Embedder.java:183)
    at org.apache.maven.artifact.ant.AbstractArtifactTask.getContainer(AbstractArtifactTask.java:495)
    at org.apache.maven.artifact.ant.AbstractArtifactTask.lookup(AbstractArtifactTask.java:458)
    at org.apache.maven.artifact.ant.AbstractArtifactTask.initSettings(AbstractArtifactTask.java:287)
    at org.apache.maven.artifact.ant.AbstractArtifactTask.execute(AbstractArtifactTask.java:677)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
    at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:352)
    at org.apache.tools.ant.Target.execute(Target.java:437)
    at org.apache.tools.ant.Target.performTasks(Target.java:458)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1406)
    at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:36)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1261)
    at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:442)
    at org.apache.tools.ant.taskdefs.SubAnt.execute(SubAnt.java:310)
    at org.apache.tools.ant.taskdefs.SubAnt.execute(SubAnt.java:225)

Solution

## 添加 ANT_OPTS 变量指定 JVM 参数
ANT_OPTS="-server -Xms256m -Xmx512m -XX:PermSize=256M -XX:MaxPermSize=256m" ant -v 

HotSpot VM Options

Non-Standard Options
## print help on non-standard options
java -X
    -Xmixed           mixed mode execution (default)
    -Xint             interpreted mode execution only
    -Xbootclasspath:<directories and zip/jar files separated by :>
                      set search path for bootstrap classes and resources
    -Xbootclasspath/a:<directories and zip/jar files separated by :>
                      append to end of bootstrap class path
    -Xbootclasspath/p:<directories and zip/jar files separated by :>
                      prepend in front of bootstrap class path
    -Xnoclassgc       disable class garbage collection
    -Xincgc           enable incremental garbage collection
    -Xloggc:<file>    log GC status to a file with time stamps
    -Xbatch           disable background compilation
    -Xms<size>        set initial Java heap size
    -Xmx<size>        set maximum Java heap size
    -Xss<size>        set java thread stack size
    -Xprof            output cpu profiling data
    -Xfuture          enable strictest checks, anticipating future default
    -Xrs              reduce use of OS signals by Java/VM (see documentation)
    -Xcheck:jni       perform additional checks for JNI functions
    -Xshare:off       do not attempt to use shared class data
    -Xshare:auto      use shared class data if possible (default)
    -Xshare:on        require using shared class data, otherwise fail.

The -X options are non-standard and subject to change without notice.
-Xms256m
Specify the initial size, in bytes, of the memory allocation pool. This value must be a multiple of 1024 greater than 1MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is chosen at runtime based on system configuration. For more information, see HotSpot Ergonomics 
Examples:
       -Xms6291456
       -Xms6144k
       -Xms6m
-Xmx512m
Specify the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is chosen at runtime based on system configuration. For more information, see HotSpot Ergonomics 
Examples:
       -Xmx83886080
       -Xmx81920k
       -Xmx80m

On Solaris 7 and Solaris 8 SPARC platforms, the upper limit for this value is approximately 4000m minus overhead amounts. On Solaris 2.6 and x86 platforms, the upper limit is approximately 2000m minus overhead amounts. On Linux platforms, the upper limit is approximately 2000m minus overhead amounts.
Performance Options(Some Useful -XX Options)
-XX:MaxPermSize=256m
    Size of the Permanent Generation.  [5.0 and newer: 64 bit VMs are scaled 30% larger; 1.4 amd64: 96m; 1.3.1 -client: 32m.]

Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found

Build Log

     [java] Executing '/usr/lib/jvm/jdk1.6.0_45/jre/bin/java' with arguments:
     [java] '-Dxslthl.config=file:///opt/workspace/github.com/osp-spring/spring-framework/spring-framework-reference/target/docbook/docbook-xsl-1.74.0/highlighting/xslthl-config.xml'
     [java] '-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl'
     [java] '-Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl'
     [java] '-Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration'
     [java] '-classpath'
     [java] '/opt/workspace/github.com/osp-spring/spring-framework/spring-build/lib/docbook/lib/avalon-framework-api-4.3.jar:/opt/workspace/github.com/osp-spring/spring-framework/spring-build/lib/docbook/lib/avalon-framework-impl-4.3.jar:/opt/workspace/github.com/osp-spring/spring-framework/spring-build/lib/docbook/lib/batik-all-1.6.jar:/opt/workspace/github.com/osp-spring/spring-framework/spring-build/lib/docbook/lib/fop-0.20.5.jar:/opt/workspace/github.com/osp-spring/spring-framework/spring-build/lib/docbook/lib/saxon-6.5.5.jar:/opt/workspace/github.com/osp-spring/spring-framework/spring-build/lib/docbook/lib/xml-resolver-1.1.jar:/opt/workspace/github.com/osp-spring/spring-framework/spring-framework-reference/target/docbook/docbook-xsl-1.74.0/extensions/saxon65.jar:/opt/workspace/github.com/osp-spring/spring-framework/spring-framework-reference/target/docbook/tmp'
     [java] 'com.icl.saxon.StyleSheet'
     [java] '-x'
     [java] 'org.apache.xml.resolver.tools.ResolvingXMLReader'
     [java] '-y'
     [java] 'org.apache.xml.resolver.tools.ResolvingXMLReader'
     [java] '-r'
     [java] 'org.apache.xml.resolver.tools.CatalogResolver'
     [java] '-o'
     [java] '/opt/workspace/github.com/osp-spring/spring-framework/spring-framework-reference/target/docbook/tmp/html-titlepage.xsl'
     [java] '/opt/workspace/github.com/osp-spring/spring-framework/spring-framework-reference/target/docbook/tmp/html-titlepage.xml'
     [java] '/opt/workspace/github.com/osp-spring/spring-framework/spring-framework-reference/target/docbook/docbook-xsl-1.74.0/template/titlepage.xsl'
     [java] 
     [java] The ' characters around the executable and arguments are
     [java] not part of the command.
     [java] Exception in thread "main" javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found
     [java]     at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:134)
     [java]     at org.apache.xml.resolver.Catalog.setupReaders(Unknown Source)
     [java]     at org.apache.xml.resolver.CatalogManager.getPrivateCatalog(Unknown Source)
     [java]     at org.apache.xml.resolver.CatalogManager.getCatalog(Unknown Source)
     [java]     at org.apache.xml.resolver.tools.CatalogResolver.initializeCatalogs(Unknown Source)
     [java]     at org.apache.xml.resolver.tools.CatalogResolver.<init>(Unknown Source)
     [java]     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     [java]     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
     [java]     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
     [java]     at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
     [java]     at java.lang.Class.newInstance0(Class.java:357)
     [java]     at java.lang.Class.newInstance(Class.java:310)
     [java]     at com.icl.saxon.Loader.getInstance(Loader.java:91)
     [java]     at com.icl.saxon.StyleSheet.makeURIResolver(StyleSheet.java:551)
     [java]     at com.icl.saxon.StyleSheet.doMain(StyleSheet.java:164)
     [java]     at com.icl.saxon.StyleSheet.main(StyleSheet.java:47)
      [ant] Exiting /opt/workspace/github.com/osp-spring/spring-framework/spring-build/lib/docbook/build-docbook.xml.
   [subant] Exiting /opt/workspace/github.com/osp-spring/spring-framework/spring-framework-reference/build.xml.
   [subant] Leaving directory: /opt/workspace/github.com/osp-spring/spring-framework/spring-framework-reference

BUILD FAILED

Solution

## 删除不完整的目录,删除成功后重新开始building
rm -rf ../spring-build/lib/docbook

Reference

  1. Building Spring 3
  2. Spring 3.1.x build readme.txt
  3. JAVA -Xms -Xmx -XX:PermSize -XX:MaxPermSize 区别
  4. Java HotSpot VM Options
  5. Frequently Asked Questions about Garbage Collection in the Hotspot TM Java TM Virtual Machine
  6. Tuning Garbage Collection with the 5.0 Java TM Virtual Machine
  7. Standard HotSpot VM Options for Solaris and Linux Operating Environments

声明:
  未经特别说明,本站Blog均采用署名-非商业性使用-禁止演绎 2.5 中国大陆授权。任何违反本协议的行为均属于非法行为。如需非商业性转载,请保留署名。如需商业性转载出版,请直接和联系。

“Building Spring Framework 3.1.x With Ant”上的1条回复

发表评论

邮箱地址不会被公开。 必填项已用*标注