Improve the build process to include reproducible JARs

Gradle: include license in META-INF directory of jar files (#956)

Closes https://github.com/mozilla/rhino/issues/956

Update the Rhino Shell man page, distribution fixes

1) Ship the man page in Zip/Tar distributions.
2) Include the runtime and engine jars in the distributions.
3) Do not attempt to copy non-existing `build.properties` to distributions.
4) Compress Tar distribution file.
5) Update POM metadata descriptions.
6) Upgrade deprecated jar classifier configurations.
7) Make sure that Git handles the man page as text (`.gitattributes`).

Create reproducible jar files (#1120)

1) Remove Built-Date and Built-Time fields from MANIFEST files.
2) Do not depend on Built-Date in `ImplementationVersion` (reported by @gbrail).
3) Configure archive files to be reproducible.
This commit is contained in:
Carlos Amengual 2021-12-12 18:51:38 +01:00 коммит произвёл Greg Brail
Родитель f75125901e
Коммит 7c10b8275a
4 изменённых файлов: 103 добавлений и 41 удалений

5
.gitattributes поставляемый
Просмотреть файл

@ -19,9 +19,8 @@
*.mk text
*.tests text
*.doctest text
gradlew text
manifest text
LIST text
/man/*.1 text
/gradlew text
*.bmp binary
*.gif binary

Просмотреть файл

@ -150,10 +150,22 @@ idea {
}
}
tasks.withType(AbstractArchiveTask).configureEach {
// Reproducible jar files
preserveFileTimestamps = false
reproducibleFileOrder = true
}
task runtimeJar(type: Jar) {
dependsOn compileJava
archiveBaseName = 'rhino-runtime'
from sourceSets.main.output
from ('LICENSE.txt') {
into 'META-INF'
}
from ('NOTICE.txt') {
into 'META-INF'
}
excludes = ["org/mozilla/javascript/tools", "org/mozilla/javascript/engine/**", "META-INF/services/**"]
manifest {
attributes(
@ -162,8 +174,6 @@ task runtimeJar(type: Jar) {
"Implementation-Title": "Mozilla Rhino",
"Implementation-Vendor": "Mozilla Foundation",
"Implementation-URL": "http://www.mozilla.org/rhino",
"Built-Date": new Date().format("yyyy-MM-dd"),
"Built-Time": new Date().format("HH:mm:ss"),
"Bundle-ManifestVersion": "2",
"Bundle-SymbolicName": "org.mozilla.rhino-runtime",
"Bundle-Version": project.version.replaceAll("-.*", ""),
@ -179,6 +189,9 @@ task engineJar(type: Jar) {
include 'org/mozilla/javascript/engine/**'
include 'META-INF/services/**'
}
from ('LICENSE.txt') {
into 'META-INF'
}
manifest {
attributes(
"Manifest-Version": "1.0",
@ -186,8 +199,6 @@ task engineJar(type: Jar) {
"Implementation-Title": "Mozilla Rhino ScriptEngine",
"Implementation-Vendor": "Mozilla Foundation",
"Implementation-URL": "http://www.mozilla.org/rhino",
"Built-Date": new Date().format("yyyy-MM-dd"),
"Built-Time": new Date().format("HH:mm:ss"),
"Automatic-Module-Name": "org.mozilla.rhino.engine"
)
}
@ -195,8 +206,14 @@ task engineJar(type: Jar) {
jar {
dependsOn runtimeJar, engineJar
from "LICENSE.txt"
from ('LICENSE.txt') {
into 'META-INF'
}
from ('NOTICE.txt') {
into 'META-INF'
}
excludes = ["org/mozilla/javascript/engine/**", "META-INF/services/**"]
// Class ImplementationVersion uses 'Implementation-Title'
manifest {
attributes(
"Manifest-Version": "1.0",
@ -205,8 +222,6 @@ jar {
"Implementation-Title": "Mozilla Rhino",
"Implementation-Vendor": "Mozilla Foundation",
"Implementation-URL": "http://www.mozilla.org/rhino",
"Built-Date": new Date().format("yyyy-MM-dd"),
"Built-Time": new Date().format("HH:mm:ss"),
"Automatic-Module-Name": "org.mozilla.rhino",
"Bundle-ManifestVersion": "2",
"Bundle-SymbolicName": "org.mozilla.rhino",
@ -219,40 +234,54 @@ jar {
javadoc {
options.addBooleanOption("-allow-script-in-comments", true)
options.addStringOption('Xdoclint:html', '-quiet')
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
archiveClassifier = 'javadoc'
from javadoc
}
task runtimeJavadocJar(type: Jar) {
classifier = 'javadoc'
archiveClassifier = 'javadoc'
from javadoc
exclude 'org/mozilla/javascript/tools', 'org/mozilla/javascript/engine'
}
task engineJavadocJar(type: Jar) {
classifier = 'javadoc'
archiveClassifier = 'javadoc'
from javadoc
include 'org/mozilla/javascript/engine/**'
}
task sourceJar(type: Jar) {
from sourceSets.main.allJava
from ('LICENSE.txt') {
into 'META-INF'
}
from ('NOTICE.txt') {
into 'META-INF'
}
}
task runtimeSourceJar(type: Jar) {
classifier 'sources'
archiveClassifier = 'sources'
from sourceSets.main.allJava
exclude 'org/mozilla/javascript/tools', 'org/mozilla/javascript/engine'
from ('LICENSE.txt') {
into 'META-INF'
}
from ('NOTICE.txt') {
into 'META-INF'
}
}
task engineSourceJar(type: Jar) {
classifier 'sources'
archiveClassifier = 'sources'
from sourceSets.main.allJava
include 'org/mozilla/javascript/engine/**'
from ('LICENSE.txt') {
into 'META-INF'
}
}
publishing {
@ -267,8 +296,9 @@ publishing {
root.appendNode('description', """
Rhino is an open-source implementation of JavaScript written entirely in Java.
It is typically embedded into Java applications to provide scripting to end users.
Full jar including tools, excluding the JSR-223 Script Engine wrapper.
""")
root.appendNode("url", "https://developer.mozilla.org/en/Rhino")
root.appendNode("url", "https://mozilla.github.io/rhino/")
def p = root.appendNode("parent")
p.appendNode("groupId", "org.sonatype.oss")
@ -307,10 +337,9 @@ publishing {
def root = asNode()
root.appendNode('description', """
Rhino is an open-source implementation of JavaScript written entirely in Java.
It is typically embedded into Java applications to provide scripting to end users.
Rhino JavaScript runtime jar, excludes tools & JSR-223 Script Engine wrapper.
""")
root.appendNode("url", "https://developer.mozilla.org/en/Rhino")
root.appendNode("url", "https://mozilla.github.io/rhino/")
def p = root.appendNode("parent")
p.appendNode("groupId", "org.sonatype.oss")
@ -342,10 +371,9 @@ publishing {
def root = asNode()
root.appendNode('description', """
Rhino is an open-source implementation of JavaScript written entirely in Java.
It is typically embedded into Java applications to provide scripting to end users.
Rhino Javascript JSR-223 Script Engine wrapper.
""")
root.appendNode("url", "https://developer.mozilla.org/en/Rhino")
root.appendNode("url", "https://mozilla.github.io/rhino/")
def p = root.appendNode("parent")
p.appendNode("groupId", "org.sonatype.oss")
@ -442,7 +470,6 @@ distributions {
main {
contents {
from(sourceSets.main.java) {
exclude 'man'
into 'rhino' + project.version + '/src'
}
from(sourceSets.main.resources) {
@ -455,13 +482,15 @@ distributions {
from(jar.outputs.files) {
into 'rhino' + project.version + '/lib'
}
from(sourceSets.main.allSource) {
include 'man/*.1'
into 'rhino' + project.version
from(runtimeJar.outputs.files) {
into 'rhino' + project.version + '/lib'
}
from(engineJar.outputs.files) {
into 'rhino' + project.version + '/lib'
}
from(file(".")) {
include '*.txt', '*.md', 'build.gradle', 'build.properties', 'gradle.properties',
'gradle/**', 'gradlew'
include '*.txt', '*.md', 'build.gradle', 'gradle.properties',
'gradle/**', 'gradlew', 'man/*.1'
into 'rhino' + project.version
}
into "/"
@ -469,5 +498,10 @@ distributions {
}
}
distTar.dependsOn javadoc, jar
distTar {
dependsOn javadoc, jar
compression = Compression.GZIP
archiveExtension = 'tar.gz'
}
distZip.dependsOn javadoc, jar, sourceJar, runtimeSourceJar

Просмотреть файл

@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH RHINO 1 "February 12, 2005"
.TH RHINO 1 "December 11, 2021"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -37,14 +37,34 @@ to run scripts in batch mode or an interactive environment for exploratory progr
.SH OPTIONS
.IP -debug\fP
Generate debug information. This will set the optimization level to zero.
.IP -e\ \fIscript_source\fP
Executes script_source as a JavaScript script.
.IP -encoding\ \fIcharacterEncoding\fP
Set the character encoding to apply in case it could not be detected.
.IP -f\ \fIscript_filename_or_url\fP
Reads script_filename_or_url content and execute it as a JavaScript script.
.IP -fatal-warnings\fP
Set warnings as errors.
.IP -help,\ -?\fP
Display help.
.IP -modules\ \fImodule\fP
Add a module to the path.
.IP -opt,\ -O\ \fIoptLevel\fP
Optimizes at level optLevel, which must be an integer between 0 and 9.
Optimizes at level optLevel, which must be an integer between 0 and 9.
.IP -require\fP
Use require().
.IP -sandbox\fP
The created require() instances will be sandboxed.
.IP -sealedlib\fP
Use a sealed standard library.
.IP -strict\fP
Set strict mode.
.IP -version\ \fIversionNumber\fP
Specifies the language version to compile with. The string versionNumber must be one of 100, 110, 120, 130, or 140. See JavaScript Language Versions for more information on language versions.
Specifies the language version to compile with. It must be one of 100, 110, 120, 130, 140, 150, 160, 170, 180 or 200.
.IP -w\fP
Report warnings.
.SH PREDEFINED PROPERTIES
@ -79,13 +99,15 @@ creates a synchronized function (in the sense of a Java synchronized method) fro
.IP quit()
Quit shell. The shell will also quit in interactive mode if an end-of-file character is typed at the prompt.
.IP version(\fI[number]\fP)
Get or set JavaScript version number. If no argument is supplied, the current version number is returned. If an argument is supplied, it is expected to be one of 100, 110, 120, 130, or 140 to indicate JavaScript version 1.0, 1.1, 1.2, 1.3, or 1.4 respectively.
Get or set JavaScript version number. If no argument is supplied, the current version number is returned. If an argument is supplied, it is expected to be one of 100, 110, 120, 130, 150, 160, 170, 180 or 200 to indicate JavaScript version 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8 or ECMAScript 6 respectively.
.IP write(\fI[expr\&.\&.\&.]\fP)
Evaluate and print expressions like in "print", but without the trailing newline.
.SH SEE ALSO
The online documentation under
.UR http://www.mozilla.org/rhino/shell.html
.I http://www.mozilla.org/rhino/shell.html
The archived online documentation under
.UR https://web.archive.org/web/20210507045220/https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Shell
.I https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Shell
.UE
.SH AUTHOR
This manual page was written by Wolfgang Baer <WBaer@gmx.de>.
This manual page was created by Wolfgang Baer <WBaer@gmx.de>, see Git history for later modifications.

Просмотреть файл

@ -37,14 +37,21 @@ public class ImplementationVersion {
Manifest mf = new Manifest(is);
Attributes attrs = mf.getMainAttributes();
if ("Mozilla Rhino".equals(attrs.getValue("Implementation-Title"))) {
versionString =
"Rhino " + attrs.getValue("Implementation-Version") + " " +
attrs.getValue("Built-Date").replaceAll("-", " ");
StringBuilder buf = new StringBuilder(23);
buf.append("Rhino ").append(attrs.getValue("Implementation-Version"));
String builtDate = attrs.getValue("Built-Date");
if (builtDate != null) {
builtDate = builtDate.replaceAll("-", " ");
buf.append(' ').append(builtDate);
}
versionString = buf.toString();
return;
}
} catch (IOException e) {
// Ignore this unlikely event
}
}
// We are probably in a IDE
versionString = "Rhino Snapshot";
}
}