最近因为一个项目需要对JBOSS进行补丁升级(Tomcat容器),由于JBOSS使用的是社区版,所以需要自己动手修改及编译源码,以下描述操作过程,有同样需求的同学可以参考一下,如果过程中有错误还请各位批评指正。
1,源代码下载:
按照版本需求下载下应的源码,下载后解压相到相应磁盘;
2,构建,编译源码
本文基于mvn进行源码构建;进入Jboss-->tomcat目录;
1)由于本人下载的是较旧版本Jboss,首先修改mvn库中的settings.xml文件;
需要注意:
http://repository.jboss.org/maven2/
This URL has been disabled (June 2011) in order to reduce the load on the JBoss repository and encourage users to migrate to the Nexus URLs
所以setting中修改为:
<id>public</id>
<repositories>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<repository>
<id>JBoss Deprecated</id>
<name>JBoss Deprecated</name>
<url>http://repository.jboss.org/nexus/content/repositories/deprecated</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
.............
<activeProfile>public</activeProfile>
官方地址:https://community.jboss.org/wiki/MavenSettings
2)tomcat中pom.xml增加,执行mvn install:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0</version>
<configuration>
<rules>
<banDuplicateClasses>
<findAllDuplicates>true</findAllDuplicates>
</banDuplicateClasses>
</rules>
<fail>false</fail>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>extra-enforcer-rules</artifactId>
<version>1.0-alpha-1</version>
</dependency>
</dependencies>
</plugin>
这是由于mvn install过程中出现错误:
Execution enforce-plugin-versions of goal org.apache.maven.plugins:maven-enforcer-plugin :1.0-alpha-4:enforce failed. NullPointerException
3)导入eclipse,修改相应的源文件,执行mvn clean package
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
4)tomcat->taget目录中出现jboss-as-tomcat-*.jar,则说明编译打包成功;
以上操作就是编译tomcat源码的过程。
来源:oschina
链接:https://my.oschina.net/u/1775006/blog/266312