我是Maven的新手。我有一个项目,其中包括一个语法定义文件,是由SableCC读取,这是一个解析器生成器。SableCC读取语法文件并生成源代码,一旦编译,就会创建一个解析器。解析器由我项目的其余部分使用。
我认为我的问题不是SableCC问题,因为我见过使用Antlr (另一种可与SableCC相媲美的解析器生成器)的类似POM.XML文件,并且该POM.XML的<plugin>部分看起来与我的POM.XML文件中的<plugin>部分几乎相同。
下面是我的项目的文件结构,标识了SableCC使用的那些部分:

下面是我的完整POM.XML文件,它是我根据迄今为止看到的插件示例(特别是针对SableCC的那个)拼凑而成的:
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mbm</groupId>
<artifactId>properties</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Properties</name>
<description>Define and process program arguments</description>
<dependencies>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sablecc-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>我的问题是,SableCC插件如何知道输入文件在哪里,以及生成的4类输出Java源文件(分析、词法分析器、节点和解析器)应该放在哪里?我怀疑我需要向我的POM文件添加更多的Maven“东西”,但我不知道是什么。
发布于 2020-05-04 01:02:39
您可以在此处查看插件配置:https://github.com/tychobrailleur/sablecc-maven-plugin
更具体地说:
sourceDirectory:包含语法文件的目录。默认情况下,${basedir}/src/main/sablecc
outputDirectory:包含生成的源代码的目录。缺省情况下,${project.build.directory}/generated-sources/sablecc
您还可以解压缩JAR并在plugin.xml文件中查看以下配置:
<configuration>
<outputDirectory implementation="java.lang.String">${project.build.directory}/generated-sources/sablecc</outputDirectory>
<timestampDirectory implementation="java.lang.String">${basedir}/target</timestampDirectory>
<sourceDirectory implementation="java.lang.String">${basedir}/src/main/sablecc</sourceDirectory>
<project implementation="org.apache.maven.project.MavenProject">${project}</project>
<staleMillis implementation="int" default-value="0">${lastModGranularityMs}</staleMillis>
</configuration>https://stackoverflow.com/questions/61564883
复制相似问题