Merge branch 'master-upstream' into better-type-support

This commit is contained in:
Roland Praml 2024-08-22 14:49:07 +02:00
Родитель 46240e29ad cbb0e2f170
Коммит ad74c0baea
4778 изменённых файлов: 16276 добавлений и 11031 удалений

23
.github/dependabot.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,23 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
# Workflow files stored in the default location of `.github/workflows`. (No need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.)
directory: "/"
# Allow dependabot to run on GitHub Actions
open-pull-requests-limit: 1
schedule:
interval: "weekly"
day: "saturday"
time: "12:00"
# Maintain Gradle Dependencies
- package-ecosystem: "gradle"
directory: "/"
# Allow Dependabot to run on code
open-pull-requests-limit: 1
schedule:
interval: "weekly"
day: "saturday"
time: "12:00"

29
.github/workflows/gradle.yml поставляемый
Просмотреть файл

@ -15,37 +15,24 @@ jobs:
# Some tests require more CPU, and all can use multiple CPUs
max-parallel: 1
matrix:
java: [ '8', '11', '17' ]
java: [ '11', '17', '21' ]
name: Rhino Java ${{ matrix.java }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# Need all history or spotless check will fail
fetch-depth: 0
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Check out test262
# We don't actually want all the history for this part
run: git submodule update --init --single-branch
- name: Set up Java
uses: actions/setup-java@v3
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: ${{ matrix.java }}
distribution: 'adopt'
- if: matrix.java == '8'
name: Check everything with Gradle on Java 8
run: ./gradlew check jacocoTestReport
- if: matrix.java != '8'
name: Check everything with Gradle, modular Java
- name: Check everything with Gradle
run: >-
./gradlew check jacocoTestReport
-Dorg.gradle.jvmargs="--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
./gradlew check
- name: Upload results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: reports
path: buildGradle/reports
name: reports-java-${{ matrix.java }}
path: '*/build/reports'

16
.github/workflows/publish-github.yml поставляемый
Просмотреть файл

@ -16,21 +16,17 @@ jobs:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: '8'
distribution: 'adopt'
server-id: github
settings-path: ${{ github.workspace }}
- name: Set up Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
- name: Publish
env:
ORG_GRADLE_PROJECT_mavenUser: ${{ github.actor }}
ORG_GRADLE_PROJECT_mavenPassword: ${{ secrets.GITHUB_TOKEN }}
ORG_GRADLE_PROJECT_SIGNINGKEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }}
ORG_GRADLE_PROJECT_SIGNINGPASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }}
run: >-
./gradlew publish
-PmavenReleaseRepo="https://maven.pkg.github.com/mozilla/rhino"
-PmavenSnapshotRepo="https://maven.pkg.github.com/mozilla/rhino"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew publish

4
.github/workflows/publish-maven.yml поставляемый
Просмотреть файл

@ -12,9 +12,9 @@ jobs:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: '8'
distribution: 'adopt'

73
.github/workflows/scorecard.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,73 @@
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.
name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '31 1 * * 3'
push:
branches: [ "master" ]
# Declare default permissions as read only.
permissions: read-all
jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write
# Uncomment the permissions below if installing in a private repository.
# contents: read
# actions: read
steps:
- name: "Checkout code"
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3
with:
results_file: results.sarif
results_format: sarif
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecard on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional.
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
# Public repositories:
# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories:
# - `publish_results` will always be set to `false`, regardless
# of the value entered here.
publish_results: true
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: SARIF file
path: results.sarif
retention-days: 5
# Upload the results to GitHub's code scanning dashboard (optional).
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@429e1977040da7a23b6822b13c129cd1ba93dbb2 # v3.26.2
with:
sarif_file: results.sarif

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

@ -4,27 +4,25 @@
# build directories
build/
lib/
buildGradle
# artifacts
*.zip
*.iml
.idea/
out/
target/
.gradle
*~
# eclipse
.classpath
.project
test262
bin/
.settings/
# idea
rhino.ipr
rhino.iws
# VSCode
.vscode

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

@ -1,3 +1,3 @@
[submodule "test262"]
path = test262
path = tests/test262
url = https://github.com/tc39/test262.git

116
README.md
Просмотреть файл

@ -10,10 +10,11 @@ Rhino is licensed under the [MPL 2.0](./LICENSE.txt).
## Releases
The current release is <a href="https://github.com/mozilla/rhino/releases/tag/Rhino1_7_14_Release">Rhino 1.7.14</a>. Please see the [Release Notes](./RELEASE-NOTES.md).
The current release is <a href="https://github.com/mozilla/rhino/releases/tag/Rhino1_7_15_Release">Rhino 1.7.15</a>. Please see the [Release Notes](./RELEASE-NOTES.md).
<details><summary>Releases</summary>
<table>
<tr><td><a href="https://github.com/mozilla/rhino/releases/tag/Rhino1_7_15_Release">Rhino 1.7.15</a></td><td>May 3, 2024</td></tr>
<tr><td><a href="https://github.com/mozilla/rhino/releases/tag/Rhino1_7_14_Release">Rhino 1.7.14</a></td><td>January 6, 2022</td></tr>
<tr><td><a href="https://github.com/mozilla/rhino/releases/tag/Rhino1_7_13_Release">Rhino 1.7.13</a></td><td>September 2, 2020</td></tr>
<tr><td><a href="https://github.com/mozilla/rhino/releases/tag/Rhino1_7_12_Release">Rhino 1.7.12</a></td><td>January 13, 2020</td></tr>
@ -45,26 +46,68 @@ JavaDoc for all the APIs:
[https://javadoc.io/doc/org.mozilla/rhino](https://javadoc.io/doc/org.mozilla/rhino)
## Code Structure
Rhino 1.7.15 and before were primarily used in a single JAR called "rhino.jar".
Newer releases now organize the code using Java modules. There are four primary modules:
* **rhino**: The primary codebase necessary and sufficient to run JavaScript code. Required by everything that uses Rhino. In releases *after* 1.7.15, this module does not contain the "tools" or the XML implementation.
* **rhino-tools**: Contains the shell, debugger, and the "Global" object, which many tests and other Rhino-based tools use. Note that adding Global gives Rhino the ability to print to stdout, open files, and do other things that may be considered dangerous in a sensitive environment, so it only makes sense to include if you will use it.
* **rhino-xml**: Adds the implementation of the E4X XML standard. Only required if you are using that.
* **rhino-engine**: Adds the Rhino implementation of the standard Java *ScriptEngine* interface. Some projects use this to be able to switch between script execution engines, but for anything even moderately complex it is almost always easier and always more flexible to use Rhino's API directly.
The release contains the following other modules, which are used while building and
testing but which are not published to Maven Central:
* **rhino-all**: This creates an "all-in-one" JAR that includes *rhino-runtime*, *rhino-tools*, and *rhino-xml*. This is what's used if you want to run Rhino using "java jar".
* **tests**: The tests that depend on all of Rhino and also the external tests, including the Mozilla legacy test scripts and the test262 tests.
* **benchmarks**: Runs benchmarks using JMH.
* **examples**: Surprisingly, this contains example code.
## Building
### Requirements
Rhino requires Java 11 to build. It will (currently) build with Java versions up to at least
Java 21. However, not all tools work with Java 21, such as "spotless", so Java 11 is required for
regular developers.
### How to Build
Rhino builds with `Gradle`. Here are some useful tasks:
```
./gradlew jar
```
Build and create `Rhino` jar in the `buildGradle/libs` directory.
```
git submodule init
git submodule update
./gradlew test
```
Build and run all the tests, including the official [ECMAScript Test Suite](https://github.com/tc39/test262).
See [Running tests](testsrc/README.md) for more detailed info about running tests.
```
./gradlew testBenchmark
```
Build and run benchmark tests.
For normal development, you can build the code, run the static checks, and run all the tests like this:
git submodule init
git submodule update
./gradlew check
To just run the Rhino shell, you can do this from the top-level directory:
./gradlew run -q --console=plain
Alternately, you can build an all-in-one JAR and run that:
./gradlew :rhino-all:build
java -jar rhino-all/build/libs/rhino-all-1.7.16-SNAPSHOT.jar
You can also run the benchmarks:
./gradlew jmh
### Code Coverage
The "Jacoco" coverage is enabled by default for the main published modules as well as the special
"tests" module. Coverage is generated for each of the main projects separately and available by
running
./gradlew jacocoTestReport
To see an aggregated coverage report for everything, which is probably what you want, run
./gradlew testCodeCoverageReport
The result is in:
./tests/build/reports/jacoco/testCodeCoverageReport/html
## Releasing and publishing new version
@ -85,30 +128,19 @@ mavenReleaseRepo=
5. Increase version and add `-SNAPSHOT` to it in `gradle.properties` in project root folder.
6. Push `gradle.properties` to `GitHub`
## Running
Rhino can run as a stand-alone interpreter from the command line:
```
java -jar buildGradle/libs/rhino-1.7.12.jar -debug -version 200
Rhino 1.7.9 2018 03 15
js> print('Hello, World!');
Hello, World!
js>
```
There is also a "rhino" package for many Linux distributions as well as Homebrew for the Mac.
You can also embed it, as most people do. See below for more docs.
### Java 16 and later
If you are using a modular JDK that disallows the reflective access to
non-public fields (16 and later), you may need to configure the JVM with the
non-public fields (16 and later), you *may* need to configure the JVM with the
[`--add-opens`](https://docs.oracle.com/en/java/javase/17/migrate/migrating-jdk-8-later-jdk-releases.html#GUID-12F945EB-71D6-46AF-8C3D-D354FD0B1781)
option to authorize the packages that your scripts shall use, for example:
```
--add-opens java.desktop/javax.swing.table=ALL-UNNAMED
```
This is not necessary just to build Rhino -- it may be necessary when embedding it
depending on what your project does.
## Issues
Most issues are managed on GitHub:
@ -142,22 +174,12 @@ hundreds of lines of changes to, please try to put the reformatting changes
alone into a single Git commit so that we can separate reformatting changes
from more substantive changes.
> **Warning:** If you build with Java 16 or later, you need to apply a
> workaround for a "spotless" issue. Otherwise, the task will be disabled
> and your PR may fail.
>
> The following must be added to your `gradle.properties`.
> ```
> org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
> --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
> --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
> --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
> --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
> ```
> For more details, see https://github.com/diffplug/spotless/issues/834#issuecomment-819118761
Currently, you must be building on Java 11 for Spotless to run. We recommend that you
have that ready. (We have not been able to figure out a version of Spotless and the
Google formatting plugin that it uses that works on many Java versions.)
## More Help
The Google group is the best place to go with questions:
GitHub is the best place to go with questions. For example, we use "GitHub discussions":
[https://groups.google.com/forum/#!forum/mozilla-rhino](https://groups.google.com/forum/#!forum/mozilla-rhino)
[https://github.com/mozilla/rhino/discussions](https://github.com/mozilla/rhino/discussions)

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

@ -1,3 +1,16 @@
# Rhino 1.7.15
## May 3, 2024
Highlights of this release include:
* Basic support for "rest parameters"
* Improvements in Unicode support
* "Symbol.species" implemented in many places
* More correct property ordering in many places
* And many more improvements and bug fixes
This release includes committs from 29 different committers. Thanks to you all for your help!
# Rhino 1.7.14
## January 6, 2022

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

@ -59,7 +59,9 @@ to the new tag. Include the following:
The "Publish to Maven Central" action on GitHub Actions will automatically
build the release, sign the JARs, and push it to oss.sonatype.org in the
"org.mozilla" area. Log in to oss.sonatype.org, verify that all the checks
"org.mozilla" area. Kick off this job using the "Actions" tag in the GitHub UI.
Next, Log in to oss.sonatype.org, verify that all the checks
that happen there were successful, and "close" the release. It will appear
on Maven Central a few hours later.

54
benchmarks/README.md Normal file
Просмотреть файл

@ -0,0 +1,54 @@
# Rhino Benchmarks
This directory contains a collection of various benchmarks that have been added to the Rhino
project over the years. They have all been collected here and run using the JMH framework.
## Running the Benchmarks
To run all the benchmarks that exist, simply run, from the top-level directory:
./gradlew jmh
In addition, the environment variable BENCHMARK may be used to restrict which benchmarks are
run -- it is a regular expression that matches the names of the benchmarks.
For example, to run only the SunSpider and V8 benchmarks, you can run:
BENCHMARK=V8|SunSpider ./gradlew jmh
Running all the benchmarks takes about half an hour, so this is a valuable thing to do!
## How the Benchmarks work
Java, with its just-in-time compilation pipeline, bytecode generation in Rhino, and
Java's super-complex garbage collector, is sensitive to warm up time and as a result, Rhino has
more variation between runs than other JavaScript engines. To get a repeatable result, we use
the JMH framework, which runs each benchmark many times and does other "black hole" protection
operations to try and get an accurate result. For this reason, these benchmarks take a lot longer
to run than your favorite on-line JavaScript benchmarking web site.
The purpose of these benchmarks has historically been to make Rhino perform better in server-side
environments, so they all run at the maximum optimization level (9). Since so many people also
use Rhino in interpreted mode, if there's an interest in benchmarking that too then we can
always adjust these tests.
## Benchmark Notes
Here are a few notes on the specific benchmarks:
* **SunSpiderBenchmark**: These are the venerable JavaScript benchmarks that have been used
for a long time. They test both low-level operations like math operations, as well as higher-level
tasks.
* **V8Benchmark**: These are Google's V8 benchmarks, which may have been created to show how
efficient V8 is. They are still a good way to show how far we have to go.
* **SlotMapBenchmark**: This is a low-level benchmark of the various SlotMap types in Rhino.
Tiny changes in SlotMap performance affect property access in Rhino and translate into big
changes in the other benchmarks.
* **PropertyBenchmark**: This is a micro-benchmark that uses JavaScript code to test the efficiency
of object property access.
* **ObjectBenchmark**: These serve a similar purpose to PropertyBenchmark and perhaps we should
have deleted these by now.
* **BuiltinBenchmark**: This tries to measure the relative performance of the various ways to create
native JavaScript objects in Java -- the reflection-based method, the IdScriptableObject that is used
for many internal objects, and lambda functions.
* **MathBenchmark**: This is a vehicle for quickly testing low-level math operations.

21
benchmarks/build.gradle Normal file
Просмотреть файл

@ -0,0 +1,21 @@
plugins {
id 'rhino.java-conventions'
id "me.champeau.jmh" version "0.7.2"
}
dependencies {
implementation project(':rhino')
implementation project(':rhino-tools')
}
jmh {
if (System.getenv('BENCHMARK') != null) {
includes = [System.getenv('BENCHMARK')]
}
benchmarkMode = ['avgt']
fork = 1
iterations = 5
timeOnIteration = '2s'
warmupIterations = 3
warmup = '5s'
}

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

@ -1,6 +1,7 @@
package org.mozilla.javascript.benchmarks;
import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.TimeUnit;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.IdFunctionObject;
import org.mozilla.javascript.IdScriptableObject;
@ -13,8 +14,8 @@ import org.mozilla.javascript.Undefined;
import org.mozilla.javascript.annotations.*;
import org.openjdk.jmh.annotations.*;
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public class BuiltinBenchmark {
@State(Scope.Thread)
public static class AbstractClassState {
@ -59,6 +60,7 @@ public class BuiltinBenchmark {
@State(Scope.Thread)
public static class AnnotatedClassState extends AbstractClassState {
@Override
@Setup(Level.Trial)
public void init()
throws IllegalAccessException, InvocationTargetException, InstantiationException {
@ -122,6 +124,7 @@ public class BuiltinBenchmark {
@State(Scope.Thread)
public static class IdClassState extends AbstractClassState {
@Override
@Setup(Level.Trial)
public void init()
throws IllegalAccessException, InvocationTargetException, InstantiationException {
@ -314,6 +317,7 @@ public class BuiltinBenchmark {
@State(Scope.Thread)
public static class DumbLambdaState extends AbstractClassState {
@Override
@Setup(Level.Trial)
public void init()
throws IllegalAccessException, InvocationTargetException, InstantiationException {

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

@ -2,6 +2,7 @@ package org.mozilla.javascript.benchmarks;
import java.io.FileReader;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.ScriptRuntime;
@ -9,6 +10,7 @@ import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.openjdk.jmh.annotations.*;
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public class MathBenchmark {
@State(Scope.Thread)
public static class MathState {

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

@ -3,6 +3,7 @@ package org.mozilla.javascript.benchmarks;
import java.io.FileReader;
import java.io.IOException;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.Scriptable;
@ -10,6 +11,7 @@ import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.tools.shell.Global;
import org.openjdk.jmh.annotations.*;
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public class ObjectBenchmark {
static final Random rand = new Random();

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

@ -2,6 +2,7 @@ package org.mozilla.javascript.benchmarks;
import java.io.FileReader;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.ScriptRuntime;
@ -9,6 +10,7 @@ import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.openjdk.jmh.annotations.*;
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public class PropertyBenchmark {
@State(Scope.Thread)
public static class PropertyState {

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

@ -1,12 +1,14 @@
package org.mozilla.javascript.benchmarks;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import org.mozilla.javascript.EmbeddedSlotMap;
import org.mozilla.javascript.HashSlotMap;
import org.mozilla.javascript.Slot;
import org.mozilla.javascript.SlotMap;
import org.openjdk.jmh.annotations.*;
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public class SlotMapBenchmark {
// Fixed seed for repeatability
private static final Random rand = new Random(0);

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

@ -11,10 +11,7 @@ import org.openjdk.jmh.annotations.*;
public class SunSpiderBenchmark {
private static final String TEST_BASE = "testsrc/benchmarks/sunspider-1.0/";
private static final int WARMUP_RUNS = 3;
private static final int MEASUREMENT_RUNS = 3;
private static final int DURATION_SECONDS = 5;
@OutputTimeUnit(TimeUnit.MICROSECONDS)
abstract static class AbstractState {
Context cx;
Scriptable scope;
@ -56,12 +53,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object threeDCube(ThreeDCubeState state) {
return state.run();
}
@ -74,12 +65,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object threeDMorph(ThreeDMorphState state) {
return state.run();
}
@ -92,12 +77,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object threeDRayTrace(ThreeDRayState state) {
return state.run();
}
@ -110,12 +89,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object accessBinaryTrees(AccessBinaryTreesState state) {
return state.run();
}
@ -128,12 +101,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object accessFannkuch(AccessFannkuchState state) {
return state.run();
}
@ -146,12 +113,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object accessNBody(AccessNBodyState state) {
return state.run();
}
@ -164,12 +125,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object accessNsieve(AccessFannAccessNsieveState state) {
return state.run();
}
@ -182,12 +137,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object bitops3BitBitsInByte(Bitops3BitState state) {
return state.run();
}
@ -200,12 +149,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object bitopsBitsInByte(BitopsBitsState state) {
return state.run();
}
@ -218,12 +161,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object bitopsBitwiseAnd(BitopsAndState state) {
return state.run();
}
@ -236,12 +173,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object bitopsNsieveBits(BitopsNsieveState state) {
return state.run();
}
@ -254,12 +185,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object controlflowRecursive(RecursiveState state) {
return state.run();
}
@ -272,12 +197,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object cryptoAes(CryptoAesState state) {
return state.run();
}
@ -290,12 +209,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object cryptoMd5(CryptoMd5State state) {
return state.run();
}
@ -308,12 +221,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object cryptoSha1(CryptoShaState state) {
return state.run();
}
@ -326,12 +233,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object dateFormatToFte(DateFormatToFteState state) {
return state.run();
}
@ -344,12 +245,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object dateFormatXparb(DateFormatXparbState state) {
return state.run();
}
@ -362,12 +257,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object mathCordic(MathCordicState state) {
return state.run();
}
@ -380,12 +269,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object mathPartialSums(MathPartialState state) {
return state.run();
}
@ -398,12 +281,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object mathSpectralNorm(MathSpectralNormState state) {
return state.run();
}
@ -416,12 +293,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object regexpDna(RegexpState state) {
return state.run();
}
@ -434,12 +305,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object stringBase64(StringBase64State state) {
return state.run();
}
@ -452,12 +317,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object stringFasta(StringFastaState state) {
return state.run();
}
@ -470,12 +329,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object stringTagcloud(StringTagcloudState state) {
return state.run();
}
@ -488,12 +341,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object stringUnpackCode(StringUnpackState state) {
return state.run();
}
@ -506,12 +353,6 @@ public class SunSpiderBenchmark {
}
@Benchmark
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = WARMUP_RUNS, time = DURATION_SECONDS, timeUnit = TimeUnit.SECONDS)
@Measurement(
iterations = MEASUREMENT_RUNS,
time = DURATION_SECONDS,
timeUnit = TimeUnit.SECONDS)
public Object stringValidateInput(StringValidateState state) {
return state.run();
}

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

@ -2,12 +2,14 @@ package org.mozilla.javascript.benchmarks;
import java.io.FileReader;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.mozilla.javascript.Callable;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.openjdk.jmh.annotations.*;
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public class V8Benchmark {
static Object[] emptyArgs = new Object[] {};

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

@ -1,515 +0,0 @@
plugins {
id 'java'
id 'idea'
id 'eclipse'
id 'maven-publish'
id 'signing'
id 'jacoco'
id 'distribution'
id 'checkstyle'
id 'com.diffplug.spotless' version "5.12.1"
id 'com.github.spotbugs' version "4.7.1"
}
tasks.withType(JavaCompile) {
sourceCompatibility = 1.8
targetCompatibility = 1.8
options.encoding = "UTF-8"
options.compilerArgs = [ "-Xlint:deprecation,unchecked" ]
}
compileTestJava {
options.compilerArgs = [ ]
}
repositories {
mavenCentral()
}
sourceSets {
main {
java {
srcDirs 'src', 'toolsrc', 'xmlimplsrc'
}
resources {
srcDirs 'src', 'toolsrc'
exclude "build.xml"
exclude "manifest"
}
}
test {
java {
srcDirs "testsrc", 'examples'
exclude 'tests/**'
}
resources {
srcDirs "testsrc"
}
}
jmh {
java {
srcDirs "benchmarks"
}
compileClasspath += sourceSets.test.runtimeClasspath
runtimeClasspath += sourceSets.test.runtimeClasspath
}
}
dependencies {
testImplementation "junit:junit:4.13.2"
testImplementation "org.yaml:snakeyaml:1.28"
testImplementation "javax.xml.soap:javax.xml.soap-api:1.4.0"
jmhImplementation project
jmhImplementation 'org.openjdk.jmh:jmh-core:1.27'
jmhAnnotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.27'
}
test {
useJUnit()
exclude "**/benchmarks/**"
jvmArgs += '-Xss1280k'
if (JavaVersion.current() > JavaVersion.VERSION_1_8) {
jvmArgs += ['--add-opens', 'java.desktop/javax.swing.table=ALL-UNNAMED']
}
jacoco.excludes = ['**/testsrc_tests_ecma_3_RegExp_perlstress*']
systemProperty 'java.awt.headless', 'true'
systemProperty 'mozilla.js.tests', 'testsrc/tests'
systemProperty 'mozilla.js.tests.timeout', 60000
systemProperty 'user.language', 'en'
systemProperty 'user.country', 'US'
systemProperty 'user.timezone', 'America/Los_Angeles'
systemProperty 'file.encoding', 'UTF-8'
if (System.getProperty('quick') != null) {
systemProperty 'TEST_OPTLEVEL', -1
} else if (System.getProperty('optLevel')) {
systemProperty 'TEST_OPTLEVEL', System.getProperty('optLevel')
}
systemProperty 'test262properties', System.getProperty('test262properties')
if (System.getProperty('updateTest262properties') != null) {
systemProperty 'updateTest262properties', System.getProperty('updateTest262properties')
}
maxHeapSize = "1g"
testLogging.showStandardStreams = true
// Many tests do not clean up contexts properly. This makes the tests much
// more resilient at the expense of performance.
forkEvery = 1
maxParallelForks = 64
}
task sunSpiderBenchmark(type: JavaExec) {
classpath = sourceSets.jmh.runtimeClasspath
mainClass = 'org.openjdk.jmh.Main'
args '-f', '1', '-bm', 'avgt', 'SunSpider'
}
task v8Benchmark(type: JavaExec) {
classpath = sourceSets.jmh.runtimeClasspath
mainClass = 'org.openjdk.jmh.Main'
args '-f', '1', '-i', '10', '-bm', 'avgt', '-tu', 'us', 'V8'
}
task testBenchmark() {}
testBenchmark.dependsOn sunSpiderBenchmark
testBenchmark.dependsOn v8Benchmark
task microBenchmark(type: JavaExec, description: 'JMH micro benchmark') {
def benchmark = System.getProperty('benchmark')
if (benchmark == null) {
benchmark = "MathBenchmark"
}
classpath = sourceSets.jmh.runtimeClasspath
mainClass = 'org.openjdk.jmh.Main'
args '-f', '1', '-bm', 'avgt', '-tu', 'ns', '-r', '5', benchmark
}
task listBenchmarks(type: JavaExec, description: 'JMH benchmarks') {
classpath = sourceSets.jmh.runtimeClasspath
mainClass = 'org.openjdk.jmh.Main'
args '-lp'
}
task jmhHelp(type: JavaExec, description: 'JMH benchmarks') {
classpath = sourceSets.jmh.runtimeClasspath
mainClass = 'org.openjdk.jmh.Main'
args '-help'
}
idea {
module {
excludeDirs += file('testsrc/tests/src')
excludeDirs += file('buildGradle')
excludeDirs += file('build')
excludeDirs += file('.idea')
excludeDirs += file('lib')
}
}
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(
"Manifest-Version": "1.0",
"Implementation-Version": project.version,
"Implementation-Title": "Mozilla Rhino",
"Implementation-Vendor": "Mozilla Foundation",
"Implementation-URL": "http://www.mozilla.org/rhino",
"Bundle-ManifestVersion": "2",
"Bundle-SymbolicName": "org.mozilla.rhino-runtime",
"Bundle-Version": project.version.replaceAll("-.*", ""),
"Export-Package": "org.mozilla.javascript,org.mozilla.javascript.ast,org.mozilla.javascript.annotations",
"Import-Package": "javax.lang.model,javax.script"
)
}
}
task engineJar(type: Jar) {
dependsOn compileJava
archiveBaseName = 'rhino-engine'
from (sourceSets.main.output) {
include 'org/mozilla/javascript/engine/**'
include 'META-INF/services/**'
}
from ('LICENSE.txt') {
into 'META-INF'
}
manifest {
attributes(
"Manifest-Version": "1.0",
"Implementation-Version": project.version,
"Implementation-Title": "Mozilla Rhino ScriptEngine",
"Implementation-Vendor": "Mozilla Foundation",
"Implementation-URL": "http://www.mozilla.org/rhino",
"Automatic-Module-Name": "org.mozilla.rhino.engine"
)
}
}
jar {
dependsOn compileJava
from ('LICENSE.txt') {
into 'META-INF'
}
from ('NOTICE.txt') {
into 'META-INF'
}
from ('NOTICE-tools.txt') {
into 'META-INF'
}
from sourceSets.main.output
excludes = ["org/mozilla/javascript/engine/**", "META-INF/services/**"]
// Class ImplementationVersion uses 'Implementation-Title'
manifest {
attributes(
"Manifest-Version": "1.0",
"Main-Class": "org.mozilla.javascript.tools.shell.Main",
"Implementation-Version": project.version,
"Implementation-Title": "Mozilla Rhino",
"Implementation-Vendor": "Mozilla Foundation",
"Implementation-URL": "http://www.mozilla.org/rhino",
"Automatic-Module-Name": "org.mozilla.rhino",
"Bundle-ManifestVersion": "2",
"Bundle-SymbolicName": "org.mozilla.rhino",
"Bundle-Version": project.version.replaceAll("-.*", ""),
"Export-Package": "org.mozilla.javascript,org.mozilla.javascript.ast,org.mozilla.javascript.annotations",
"Import-Package": "javax.lang.model,javax.script"
)
}
}
javadoc {
options.addBooleanOption("-allow-script-in-comments", true)
options.addStringOption('Xdoclint:html', '-quiet')
}
task javadocJar(type: Jar) {
archiveClassifier = 'javadoc'
from javadoc
}
task runtimeJavadocJar(type: Jar) {
archiveClassifier = 'javadoc'
from javadoc
exclude 'org/mozilla/javascript/tools', 'org/mozilla/javascript/engine'
}
task engineJavadocJar(type: Jar) {
archiveClassifier = 'javadoc'
from javadoc
include 'org/mozilla/javascript/engine/**'
}
task sourceJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = 'sources'
from ('LICENSE.txt') {
into 'META-INF'
}
from ('NOTICE.txt') {
into 'META-INF'
}
from ('NOTICE-tools.txt') {
into 'META-INF'
}
}
task runtimeSourceJar(type: Jar) {
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) {
archiveClassifier = 'sources'
from sourceSets.main.allJava
include 'org/mozilla/javascript/engine/**'
from ('LICENSE.txt') {
into 'META-INF'
}
}
publishing {
publications {
rhino(MavenPublication) {
groupId 'org.mozilla'
artifactId 'rhino'
artifacts = [jar, sourceJar, javadocJar]
pom.withXml {
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.
Full jar including tools, excluding the JSR-223 Script Engine wrapper.
""")
root.appendNode("url", "https://mozilla.github.io/rhino/")
def p = root.appendNode("parent")
p.appendNode("groupId", "org.sonatype.oss")
p.appendNode("artifactId", "oss-parent")
p.appendNode("version", "7")
def l = root.appendNode("licenses").appendNode("license")
l.appendNode("name", "Mozilla Public License, Version 2.0")
l.appendNode("url", "http://www.mozilla.org/MPL/2.0/index.txt")
def scm = root.appendNode("scm")
scm.appendNode("connection", "scm:git:git@github.com:mozilla/rhino.git")
scm.appendNode("developerConnection", "scm:git:git@github.com:mozilla/rhino.git")
scm.appendNode("url", "git@github.com:mozilla/rhino.git")
def o = root.appendNode("organization")
o.appendNode("name", "The Mozilla Foundation")
o.appendNode("url", "http://www.mozilla.org")
}
}
rhinoruntime(MavenPublication) {
groupId 'org.mozilla'
artifactId 'rhino-runtime'
artifacts = [runtimeJar, runtimeSourceJar, runtimeJavadocJar]
pom.withXml {
def root = asNode()
root.appendNode('description', """
Rhino JavaScript runtime jar, excludes tools & JSR-223 Script Engine wrapper.
""")
root.appendNode("url", "https://mozilla.github.io/rhino/")
def p = root.appendNode("parent")
p.appendNode("groupId", "org.sonatype.oss")
p.appendNode("artifactId", "oss-parent")
p.appendNode("version", "7")
def l = root.appendNode("licenses").appendNode("license")
l.appendNode("name", "Mozilla Public License, Version 2.0")
l.appendNode("url", "http://www.mozilla.org/MPL/2.0/index.txt")
def scm = root.appendNode("scm")
scm.appendNode("connection", "scm:git:git@github.com:mozilla/rhino.git")
scm.appendNode("developerConnection", "scm:git:git@github.com:mozilla/rhino.git")
scm.appendNode("url", "git@github.com:mozilla/rhino.git")
def o = root.appendNode("organization")
o.appendNode("name", "The Mozilla Foundation")
o.appendNode("url", "http://www.mozilla.org")
}
}
rhinoengine(MavenPublication) {
groupId 'org.mozilla'
artifactId 'rhino-engine'
artifacts = [engineJar, engineSourceJar, engineJavadocJar]
pom.withXml {
def root = asNode()
root.appendNode('description', """
Rhino Javascript JSR-223 Script Engine wrapper.
""")
root.appendNode("url", "https://mozilla.github.io/rhino/")
def p = root.appendNode("parent")
p.appendNode("groupId", "org.sonatype.oss")
p.appendNode("artifactId", "oss-parent")
p.appendNode("version", "7")
def l = root.appendNode("licenses").appendNode("license")
l.appendNode("name", "Mozilla Public License, Version 2.0")
l.appendNode("url", "http://www.mozilla.org/MPL/2.0/index.txt")
def scm = root.appendNode("scm")
scm.appendNode("connection", "scm:git:git@github.com:mozilla/rhino.git")
scm.appendNode("developerConnection", "scm:git:git@github.com:mozilla/rhino.git")
scm.appendNode("url", "git@github.com:mozilla/rhino.git")
def o = root.appendNode("organization")
o.appendNode("name", "The Mozilla Foundation")
o.appendNode("url", "http://www.mozilla.org")
def deps = root.appendNode("dependencies")
def rhino = deps.appendNode("dependency")
rhino.appendNode("groupId", "org.mozilla")
rhino.appendNode("artifactId", "rhino")
rhino.appendNode("version", getVersion())
}
}
}
if (project.hasProperty("mavenPassword")) {
repositories {
maven {
credentials {
username mavenUser
password mavenPassword
}
if (project.version.endsWith('-SNAPSHOT')) {
url mavenSnapshotRepo
} else {
url mavenReleaseRepo
}
}
}
}
}
signing {
if (project.hasProperty('SIGNINGKEY')) {
// Check for ORG_GRADLE_PROJECT_SIGNINGKEY environment variable for use in CI system.
// Otherwise, do not sign.
def signingKey = getProperty('SIGNINGKEY')
def signingPassword = getProperty('SIGNINGPASSWORD')
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.rhino
sign publishing.publications.rhinoengine
sign publishing.publications.rhinoruntime
}
}
spotbugs {
effort = "less"
reportLevel = "medium"
excludeFilter = file("./spotbugs-exclude.xml")
}
spotless {
java {
googleJavaFormat().aosp()
}
}
if (JavaVersion.current() > JavaVersion.VERSION_15
&& (!System.properties.containsKey('org.gradle.jvmargs')
|| !System.properties.get('org.gradle.jvmargs').contains('com.sun.tools.javac.api'))
&& (!project.hasProperty('org.gradle.jvmargs')
|| !project.property('org.gradle.jvmargs').contains('com.sun.tools.javac.api'))) {
tasks.named('check') {
doFirst {
logger.warn('WARNING: spotless plugin removed from check due to bug, ' + \
'see README for a workaround when building with Java 16+.')
}
}
spotless.enforceCheck false
}
jacocoTestReport {
dependsOn test
reports {
csv.required = true
html.required = true
}
}
checkstyle {
configFile = file("${projectDir}/checkstyle.xml")
sourceSets = [ project.sourceSets.main ]
}
distributions {
main {
contents {
from(sourceSets.main.java) {
into 'rhino' + project.version + '/src'
}
from(sourceSets.main.resources) {
exclude '**/*.java'
into 'rhino' + project.version + '/src'
}
from(javadoc.destinationDir) {
into 'rhino' + project.version + '/docs'
}
from(jar.outputs.files) {
into 'rhino' + project.version + '/lib'
}
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', 'gradle.properties',
'gradle/**', 'gradlew', 'man/*.1'
into 'rhino' + project.version
}
into "/"
}
}
}
distTar {
dependsOn javadoc, jar
compression = Compression.GZIP
archiveExtension = 'tar.gz'
}
distZip.dependsOn javadoc, jar, sourceJar, runtimeSourceJar

12
buildSrc/build.gradle Normal file
Просмотреть файл

@ -0,0 +1,12 @@
plugins {
id 'groovy-gradle-plugin'
}
repositories {
gradlePluginPortal()
}
dependencies {
implementation 'com.diffplug.spotless:spotless-plugin-gradle:6.25.0'
implementation 'net.ltgt.gradle:gradle-errorprone-plugin:4.0.0'
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше