Skip to content

Commit

Permalink
JS-174 Generate Java classes for deserialization of ESTree (#4714)
Browse files Browse the repository at this point in the history
  • Loading branch information
saberduck authored May 29, 2024
1 parent 01e72c2 commit 720d1c6
Show file tree
Hide file tree
Showing 4 changed files with 646 additions and 2 deletions.
49 changes: 48 additions & 1 deletion sonar-plugin/bridge/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand All @@ -12,6 +13,10 @@

<name>SonarQube JavaScript :: Bridge</name>

<properties>
<protobuf.version>3.24.2</protobuf.version>
</properties>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down Expand Up @@ -39,6 +44,12 @@
<artifactId>xz</artifactId>
</dependency>

<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>${protobuf.version}</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
Expand Down Expand Up @@ -67,6 +78,13 @@
</dependencies>

<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.6.2</version>
</extension>
</extensions>
<plugins>
<!-- copy runtimes so they are accessible by unit tests -->
<plugin>
Expand All @@ -89,6 +107,35 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<executions>
<execution>
<id>generate-protobuf-java-sources</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}
</protocArtifact>
<protoSourceRoot>${project.basedir}/src/main/protobuf</protoSourceRoot>
<outputDirectory>${project.build.directory}/generated-sources/protobuf</outputDirectory>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protoc</artifactId>
<version>${protobuf.version}</version>
<type>exe</type>
<classifier>${os.detected.classifier}</classifier>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

Expand Down
File renamed without changes.
5 changes: 4 additions & 1 deletion tools/protobuf/generate-proto-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,10 @@ function addHandWrittenMessages(messages: Record<string, ProtobufMessage>) {

function writeMessagesToFile(messages: Record<string, ProtobufMessage>) {
fs.mkdirSync('output', { recursive: true });
fs.writeFileSync(path.join('output', 'ast.proto'), addPrefix(translateToProtoFormat(messages)));
fs.writeFileSync(
path.join('output', 'estree.proto'),
addPrefix(translateToProtoFormat(messages)),
);
/**
* Translate the messages to a protobuf file format.
*/
Expand Down
Loading

0 comments on commit 720d1c6

Please sign in to comment.