<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<parent>
		<groupId>io.ecocode</groupId>
		<artifactId>ecocode-parent</artifactId>
		<version>0.0.10</version>
	</parent>

	<artifactId>ecocode-rules-specifications</artifactId>

	<name>ecoCode Rules Specifications repository</name>
	<description>Repository that contains the specifications of every static-analysis rules available in ecoCode plugins.</description>
	<url>https://github.com/green-code-initiative/ecoCode/tree/main/ecocode-rules-specifications</url>
<dependencies>
	<dependency>
		<groupId>jakarta.json</groupId>
		<artifactId>jakarta.json-api</artifactId>
		<version>2.1.2</version>
	</dependency>

	<dependency>
		<groupId>org.glassfish</groupId>
		<artifactId>jakarta.json</artifactId>
		<version>2.0.1</version>
		<classifier>module</classifier>
	</dependency>

</dependencies>
	<build>
		<plugins>
			<plugin><!--
					This plugin convert ASCIIDOC rule specification in HTML format
					ASCIIDOC format is used with custom features such as :
					- syntax highlighting (see code blocks on ASCIIDOC rules)
					- inclusions (see: php/EC74.asciidoc)
					- table data generation from CSV (see: php/EC34.asciidoc)

					NB: Current version has a bug which display following false positive warning :
					[WARNING] Duplicated destination found: overwriting file ...

					This issue is fixed in 3.x release of asciidoctor-maven-plugin
				-->
				<groupId>org.asciidoctor</groupId>
				<artifactId>asciidoctor-maven-plugin</artifactId>
				<version>2.2.4</version>
				<executions>
					<execution>
						<id>convert-to-html</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>process-asciidoc</goal>
						</goals>
						<configuration>
							<sourceDirectory>${project.basedir}/src/main/rules</sourceDirectory>
							<outputDirectory>${project.build.directory}/rules-html</outputDirectory>
							<attributes>
								<source-highlighter>coderay</source-highlighter>
								<coderay-css>style</coderay-css>
							</attributes>
							<preserveDirectories>true</preserveDirectories>
							<embedAssets>true</embedAssets>
							<headerFooter>false</headerFooter>
							<relativeBaseDir>true</relativeBaseDir>
							<logHandler>
								<failIf>
									<severity>ERROR</severity>
								</failIf>
							</logHandler>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin><!--
					Prepare resources tree needed by language.
					Each metadata JSON file must be in the same folder as the HTML description file for the corresponding language.
				-->
				<groupId>com.github.johnpoth</groupId>
				<artifactId>jshell-maven-plugin</artifactId>
				<version>1.4</version>
				<executions>
					<execution>
						<id>prepare-rules-resources</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>run</goal>
						</goals>
						<configuration>
							<scripts>
								<script>${project.basedir}/src/main/script/PrepareResources.jsh</script>
							</scripts>
							<options>
								<option>-R "-DsourceDir=${project.build.directory}/rules-html"</option>
								<option>-R "-DtargetDir=${project.build.outputDirectory}/io/ecocode/rules"</option>
							</options>
						</configuration>
					</execution>
				</executions>

				<dependencies>
					<dependency>
						<groupId>jakarta.json</groupId>
						<artifactId>jakarta.json-api</artifactId>
						<version>2.1.2</version>
					</dependency>

					<dependency>
						<groupId>org.glassfish</groupId>
						<artifactId>jakarta.json</artifactId>
						<version>2.0.1</version>
						<classifier>module</classifier>
					</dependency>
				</dependencies>
			</plugin>
			<plugin><!--
					This module produce one artifact by language (with corresponding classifier)
					For example, to add rule specifications for Python language, add following dependency in python sonarqube plugin:

			        <dependency>
			            <groupId>io.ecocode</groupId>
			            <artifactId>ecocode-rules-specifications</artifactId>
			            <version>${project.version}</version>
			            <classifier>python</classifier>
			        </dependency>
				-->
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-assembly-plugin</artifactId>
				<version>3.6.0</version>
				<executions>
					<execution>
						<id>assembly-java</id>
						<phase>prepare-package</phase>
						<goals>
							<goal>single</goal>
						</goals>
						<configuration>
							<descriptors>
								<descriptor>${project.basedir}/src/main/assembly/java.xml</descriptor>
							</descriptors>
						</configuration>
					</execution>
					<execution>
						<id>assembly-php</id>
						<phase>prepare-package</phase>
						<goals>
							<goal>single</goal>
						</goals>
						<configuration>
							<descriptors>
								<descriptor>${project.basedir}/src/main/assembly/php.xml</descriptor>
							</descriptors>
						</configuration>
					</execution>
					<execution>
						<id>assembly-python</id>
						<phase>prepare-package</phase>
						<goals>
							<goal>single</goal>
						</goals>
						<configuration>
							<descriptors>
								<descriptor>${project.basedir}/src/main/assembly/python.xml</descriptor>
							</descriptors>
						</configuration>
					</execution>
					<execution>
						<id>assembly-javascript</id>
						<phase>prepare-package</phase>
						<goals>
							<goal>single</goal>
						</goals>
						<configuration>
							<descriptors>
								<descriptor>${project.basedir}/src/main/assembly/javascript.xml</descriptor>
							</descriptors>
						</configuration>
					</execution>
					<execution>
						<id>assembly-swift</id>
						<phase>prepare-package</phase>
						<goals>
							<goal>single</goal>
						</goals>
						<configuration>
							<descriptors>
								<descriptor>${project.basedir}/src/main/assembly/swift.xml</descriptor>
							</descriptors>
						</configuration>
					</execution>
					<execution>
						<id>assembly-xml</id>
						<phase>prepare-package</phase>
						<goals>
							<goal>single</goal>
						</goals>
						<configuration>
							<descriptors>
								<descriptor>${project.basedir}/src/main/assembly/xml.xml</descriptor>
							</descriptors>
						</configuration>
					</execution>
				</executions>
				<configuration>
					<appendAssemblyId>true</appendAssemblyId>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>
