SOLR-7227: Don't create the WAR file at all

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1693143 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2015-07-28 19:04:21 +00:00
parent c01f6b745b
commit 3e406606ed
7 changed files with 86 additions and 164 deletions

View File

@ -168,88 +168,68 @@ LICENSE_FILE_NAME = 'META-INF/LICENSE.txt'
def checkJARMetaData(desc, jarFile, svnRevision, version):
s = None
notice = None
license = None
# support expanded WAR directory or JAR file
if isinstance(jarFile, str) and os.path.isdir(jarFile):
with zipfile.ZipFile(jarFile, 'r') as z:
for name in (MANIFEST_FILE_NAME, NOTICE_FILE_NAME, LICENSE_FILE_NAME):
if not os.path.isfile(jarFile + '/' + name):
raise RuntimeError('%s is missing %s' % (desc, name))
s = open(jarFile + '/' + MANIFEST_FILE_NAME,encoding='UTF-8').read()
notice = open(jarFile + '/' + NOTICE_FILE_NAME,encoding='UTF-8').read()
license = open(jarFile + '/' + LICENSE_FILE_NAME,encoding='UTF-8').read()
else:
with zipfile.ZipFile(jarFile, 'r') as z:
for name in (MANIFEST_FILE_NAME, NOTICE_FILE_NAME, LICENSE_FILE_NAME):
try:
# The Python docs state a KeyError is raised ... so this None
# check is just defensive:
if z.getinfo(name) is None:
raise RuntimeError('%s is missing %s' % (desc, name))
except KeyError:
try:
# The Python docs state a KeyError is raised ... so this None
# check is just defensive:
if z.getinfo(name) is None:
raise RuntimeError('%s is missing %s' % (desc, name))
s = decodeUTF8(z.read(MANIFEST_FILE_NAME))
notice = decodeUTF8(z.read(NOTICE_FILE_NAME))
license = decodeUTF8(z.read(LICENSE_FILE_NAME))
except KeyError:
raise RuntimeError('%s is missing %s' % (desc, name))
s = decodeUTF8(z.read(MANIFEST_FILE_NAME))
for verify in (
'Specification-Vendor: The Apache Software Foundation',
'Implementation-Vendor: The Apache Software Foundation',
# Make sure 1.8 compiler was used to build release bits:
'X-Compile-Source-JDK: 1.8',
# Make sure 1.8 ant was used to build release bits: (this will match 1.8+)
'Ant-Version: Apache Ant 1.8',
# Make sure .class files are 1.8 format:
'X-Compile-Target-JDK: 1.8',
'Specification-Version: %s' % version,
# Make sure the release was compiled with 1.8:
'Created-By: 1.8'):
if s.find(verify) == -1:
raise RuntimeError('%s is missing "%s" inside its META-INF/MANIFEST.MF' % \
(desc, verify))
for verify in (
'Specification-Vendor: The Apache Software Foundation',
'Implementation-Vendor: The Apache Software Foundation',
# Make sure 1.8 compiler was used to build release bits:
'X-Compile-Source-JDK: 1.8',
# Make sure 1.8 ant was used to build release bits: (this will match 1.8+)
'Ant-Version: Apache Ant 1.8',
# Make sure .class files are 1.8 format:
'X-Compile-Target-JDK: 1.8',
'Specification-Version: %s' % version,
# Make sure the release was compiled with 1.8:
'Created-By: 1.8'):
if s.find(verify) == -1:
raise RuntimeError('%s is missing "%s" inside its META-INF/MANIFEST.MF' % \
(desc, verify))
if svnRevision != 'skip':
# Make sure this matches the version and svn revision we think we are releasing:
verifyRevision = 'Implementation-Version: %s %s ' % (version, svnRevision)
if s.find(verifyRevision) == -1:
raise RuntimeError('%s is missing "%s" inside its META-INF/MANIFEST.MF (wrong svn revision?)' % \
if svnRevision != 'skip':
# Make sure this matches the version and svn revision we think we are releasing:
verifyRevision = 'Implementation-Version: %s %s ' % (version, svnRevision)
if s.find(verifyRevision) == -1:
raise RuntimeError('%s is missing "%s" inside its META-INF/MANIFEST.MF (wrong svn revision?)' % \
(desc, verifyRevision))
idx = desc.find('inside WAR file')
if idx != -1:
desc2 = desc[:idx]
else:
desc2 = desc
notice = decodeUTF8(z.read(NOTICE_FILE_NAME))
license = decodeUTF8(z.read(LICENSE_FILE_NAME))
justFileName = os.path.split(desc2)[1]
if justFileName.lower().find('solr') != -1 or justFileName.lower().find('webapp') != -1:
if SOLR_LICENSE is None:
raise RuntimeError('BUG in smokeTestRelease!')
if SOLR_NOTICE is None:
raise RuntimeError('BUG in smokeTestRelease!')
if notice != SOLR_NOTICE:
raise RuntimeError('%s: %s contents doesn\'t match main NOTICE.txt' % \
(desc, NOTICE_FILE_NAME))
if license != SOLR_LICENSE:
raise RuntimeError('%s: %s contents doesn\'t match main LICENSE.txt' % \
(desc, LICENSE_FILE_NAME))
else:
if LUCENE_LICENSE is None:
raise RuntimeError('BUG in smokeTestRelease!')
if LUCENE_NOTICE is None:
raise RuntimeError('BUG in smokeTestRelease!')
if notice != LUCENE_NOTICE:
raise RuntimeError('%s: %s contents doesn\'t match main NOTICE.txt' % \
(desc, NOTICE_FILE_NAME))
if license != LUCENE_LICENSE:
raise RuntimeError('%s: %s contents doesn\'t match main LICENSE.txt' % \
(desc, LICENSE_FILE_NAME))
justFileName = os.path.split(desc)[1]
if justFileName.lower().find('solr') != -1:
if SOLR_LICENSE is None:
raise RuntimeError('BUG in smokeTestRelease!')
if SOLR_NOTICE is None:
raise RuntimeError('BUG in smokeTestRelease!')
if notice != SOLR_NOTICE:
raise RuntimeError('%s: %s contents doesn\'t match main NOTICE.txt' % \
(desc, NOTICE_FILE_NAME))
if license != SOLR_LICENSE:
raise RuntimeError('%s: %s contents doesn\'t match main LICENSE.txt' % \
(desc, LICENSE_FILE_NAME))
else:
if LUCENE_LICENSE is None:
raise RuntimeError('BUG in smokeTestRelease!')
if LUCENE_NOTICE is None:
raise RuntimeError('BUG in smokeTestRelease!')
if notice != LUCENE_NOTICE:
raise RuntimeError('%s: %s contents doesn\'t match main NOTICE.txt' % \
(desc, NOTICE_FILE_NAME))
if license != LUCENE_LICENSE:
raise RuntimeError('%s: %s contents doesn\'t match main LICENSE.txt' % \
(desc, LICENSE_FILE_NAME))
def normSlashes(path):
return path.replace(os.sep, '/')
@ -291,46 +271,6 @@ def checkAllJARs(topDir, project, svnRevision, version, tmpDir, baseURL):
% (fullPath, luceneDistFilenames[jarFilename]))
def checkSolrWAR(warFileName, svnRevision, version, tmpDir, baseURL):
"""
Crawls for JARs inside the WAR and ensures there are no classes
under java.* or javax.* namespace.
"""
print(' verify WAR metadata/contained JAR identity/no javax.* or java.* classes...')
checkJARMetaData(warFileName, warFileName, svnRevision, version)
distFilenames = dict()
for file in getBinaryDistFiles('lucene', tmpDir, version, baseURL):
distFilenames[os.path.basename(file)] = file
for (dirpath, subdirs, files) in os.walk(warFileName):
for name in files:
if name.endswith('.jar'):
path = os.path.join(dirpath, name)
jarInsideWarContents = open(path, 'rb').read()
noJavaPackageClasses('JAR file %s inside WAR file %s' % (name, warFileName),
io.BytesIO(jarInsideWarContents))
if name.lower().find('lucene') != -1 or name.lower().find('solr') != -1:
checkJARMetaData('JAR file %s inside WAR file %s' % (name, warFileName),
io.BytesIO(jarInsideWarContents),
svnRevision,
version)
if name.lower().find('lucene') != -1:
jarInsideWarFilename = os.path.basename(name)
if jarInsideWarFilename not in distFilenames:
raise RuntimeError('Artifact %s in %s is not present in Lucene binary distribution'
% (name, warFileName))
distJarName = distFilenames[jarInsideWarFilename]
with open(distJarName, "rb", buffering=0) as distJarFile:
distJarContents = distJarFile.readall()
if jarInsideWarContents != distJarContents:
raise RuntimeError('Artifact %s in %s is not identical to %s in Lucene binary distribution'
% (name, warFileName, distJarName))
def checkSigs(project, urlString, version, tmpDir, isSigned):
print(' test basics...')
@ -770,8 +710,6 @@ def verifyUnpacked(java, project, artifact, unpackPath, svnRevision, version, te
checkJavadocpath('%s/docs' % unpackPath)
else:
checkSolrWAR('%s/server/solr-webapp/webapp' % unpackPath, svnRevision, version, tmpDir, baseURL)
print(' copying unpacked distribution for Java 8 ...')
java8UnpackPath = '%s-java8' % unpackPath
if os.path.exists(java8UnpackPath):

View File

@ -366,8 +366,9 @@ Other Changes
* SOLR-7735: Look for solr.xml in Zookeeper by default in SolrCloud mode. If not found, it will be loaded
from $SOLR_HOME/solr.xml as before. Sysprop solr.solrxml.location is now gone. (janhoy)
* SOLR-7227: Ship Solr with the Web application directory exploded into server/solr-webapp,
solr.war is no longer included in the distribution bundles. (Timothy Potter)
* SOLR-7227: Ship Solr with the Web application directory exploded into
server/solr-webapp, solr.war is no longer included in the distribution
bundles. (Timothy Potter, Uwe Schindler)
================== 5.2.1 ==================

View File

@ -42,8 +42,11 @@
<!-- ============================== USER TASKS =============================== -->
<!-- ========================================================================= -->
<target name="server" depends="dist-contrib,server-war"
<target name="server" depends="dist-contrib"
description="Creates a Solr server">
<ant dir="webapp" target="dist" inheritall="false">
<propertyset refid="uptodate.and.compiled.properties"/>
</ant>
<jar destfile="${example}/exampledocs/post.jar"
basedir="${dest}/solr-core/classes/java"
includes="org/apache/solr/util/SimplePostTool*.class">
@ -409,13 +412,6 @@
<contrib-crawl target="dist" failonerror="true" />
</target>
<target name="server-war"
description="Creates the Solr WAR Distribution file.">
<ant dir="webapp" target="server-war" inheritall="false">
<propertyset refid="uptodate.and.compiled.properties"/>
</ant>
</target>
<target name="prepare-release-no-sign" depends="clean, package, generate-maven-artifacts"/>
<target name="prepare-release" depends="prepare-release-no-sign, sign-artifacts"/>
@ -486,7 +482,7 @@
<tarfileset dir="." prefix="${fullnamever}" includes="LICENSE.txt NOTICE.txt"/>
<tarfileset dir="." prefix="${fullnamever}/solr"
excludes="build/** ${package.dir.rel}/** ${dist.rel}/**
server/webapps/*.war example/lib/**
example/lib/**
**/*.jar
lib/README.committers.txt **/data/ **/logs/*
**/*.sh **/bin/ scripts/

View File

@ -488,10 +488,10 @@
<contrib-crawl target="jar-core"/>
</target>
<target name="contribs-add-to-war">
<target name="contribs-add-to-webapp">
<mkdir dir="${dest}/web"/>
<delete dir="${dest}/web" includes="**/*" failonerror="false"/>
<contrib-crawl target="add-to-war"/>
<contrib-crawl target="add-to-webapp"/>
</target>
<!-- Forbidden API Task, customizations for Solr -->

View File

@ -30,7 +30,7 @@
<dirname file="${ant.file}" property="antfile.dir"/>
<available property="contrib.has.webapp" type="dir" file="${antfile.dir}/src/webapp" />
<target name="add-to-war" if="contrib.has.webapp">
<target name="add-to-webapp" if="contrib.has.webapp">
<copy todir="${dest}/web" failonerror="false">
<fileset dir="${antfile.dir}/src/webapp"/>
</copy>

View File

@ -4,4 +4,5 @@
<Set name="contextPath"><Property name="hostContext" default="/solr"/></Set>
<Set name="war"><Property name="jetty.base"/>/solr-webapp/webapp</Set>
<Set name="defaultsDescriptor"><Property name="jetty.base"/>/etc/webdefault.xml</Set>
<Set name="extractWAR">false</Set>
</Configure>

View File

@ -23,13 +23,8 @@
<import file="../common-build.xml"/>
<property name="exclude.from.war" value="*slf4j*,log4j-*" />
<property name="solr.war.suffix" value="" />
<property name="exclude.from.webapp" value="*slf4j*,log4j-*" />
<target name="test" depends="compile-test-solr-core">
<!-- no more JSP -->
</target>
<!-- this module has no javadocs -->
<target name="javadocs"/>
@ -39,36 +34,27 @@
<!-- nothing to compile -->
<target name="compile-core"/>
<target name="compile-test"/>
<target name="test"/>
<target name="server-war"
description="Creates the Solr WAR Distribution file."
depends="test, init-dist, dist-core, dist-solrj, lucene-jars-to-solr">
<build-manifest title="Apache Solr Search Server"
implementation.title="org.apache.solr"/>
<ant dir="${common-solr.dir}" inheritall="false" target="contribs-add-to-war"/>
<mkdir dir="${server.dir}/webapps"/>
<war destfile="${server.dir}/webapps/solr.war"
webxml="web/WEB-INF/web.xml"
manifest="${manifest.file}">
<lib dir="${common-solr.dir}/core/lib" excludes="${exclude.from.war},${common.classpath.excludes}"/>
<lib dir="${common-solr.dir}/solrj/lib" excludes="${exclude.from.war},${common.classpath.excludes}"/>
<lib dir="${lucene-libs}" excludes="${exclude.from.war},${common.classpath.excludes}" />
<lib dir="${dist}" excludes="${exclude.from.war},${common.classpath.excludes}">
<target name="dist"
description="Creates the Webapp folder for distribution."
depends="dist-core, dist-solrj, lucene-jars-to-solr">
<ant dir="${common-solr.dir}" inheritall="false" target="contribs-add-to-webapp"/>
<mkdir dir="${server.dir}/solr-webapp/webapp"/>
<copy todir="${server.dir}/solr-webapp/webapp">
<fileset dir="web" excludes="${exclude.from.webapp}"/>
<fileset dir="${dest}/web" excludes="${exclude.from.war}"/> <!-- contribs' additions -->
</copy>
<mkdir dir="${server.dir}/solr-webapp/webapp/WEB-INF/lib"/>
<copy todir="${server.dir}/solr-webapp/webapp/WEB-INF/lib">
<fileset dir="${common-solr.dir}/core/lib" excludes="${exclude.from.webapp},${common.classpath.excludes}"/>
<fileset dir="${common-solr.dir}/solrj/lib" excludes="${exclude.from.webapp},${common.classpath.excludes}"/>
<fileset dir="${lucene-libs}" excludes="${exclude.from.webapp},${common.classpath.excludes}" />
<fileset dir="${dist}" excludes="${exclude.from.webapp},${common.classpath.excludes}">
<include name="solr-solrj-${version}.jar" />
<include name="solr-core-${version}.jar" />
</lib>
<fileset dir="${dest}/web" excludes="${exclude.from.war}"/> <!-- contribs' additions -->
<fileset dir="web" excludes="${exclude.from.war}"/>
<metainf dir="${common-solr.dir}" includes="LICENSE.txt,NOTICE.txt" excludes="${exclude.from.war}"/>
</war>
<!-- Ship Solr with the WAR already extracted -->
<delete dir="${server.dir}/solr-webapp/webapp"/>
<mkdir dir="${server.dir}/solr-webapp/webapp"/>
<unzip dest="${server.dir}/solr-webapp/webapp" src="${server.dir}/webapps/solr.war"/>
<delete file="${server.dir}/webapps/solr.war"/>
<delete dir="${server.dir}/webapps"/>
</fileset>
</copy>
</target>
<!-- nothing to do -->