<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/xsd/maven-4.0.0.xsd">

	<parent>
		<artifactId>modules-template</artifactId>
		<groupId>org.openprovenance.prov</groupId>
		<version>2.2.4</version>
	</parent>

	<modelVersion>4.0.0</modelVersion>
	<artifactId>prov-jsweet-candy-java</artifactId>
	<name> |---- PROV-JSWEET-CANDY-JAVA</name>

	<repositories>
		<repository>
			<id>jsweet-central</id>
			<name>libs-release</name>
			<url>https://repository.jsweet.org/artifactory/libs-release-local</url>
		</repository>
	</repositories>
	<!--
	<pluginRepositories>
		<pluginRepository>
			<id>jsweet-plugins-release</id>
			<name>plugins-release</name>
			<url>https://repository.jsweet.org/artifactory/plugins-release-local</url>
		</pluginRepository>
	</pluginRepositories>
	-->

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<maven.compiler.source>1.8</maven.compiler.source>
		<maven.compiler.target>1.8</maven.compiler.target>
	</properties>

	<profiles>
		<profile>
			<id>java8</id>
			<activation>
				<jdk>[1.8,)</jdk>
			</activation>
			<properties>
				<javadoc.opts>-Xdoclint:none</javadoc.opts>
			</properties>

		</profile>
	</profiles>


	<build>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
				<filtering>true</filtering>
			</resource>
		</resources>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>${compiler.plugin.version}</version>
				<configuration>
					<!-- note, overriding with lower release version than overall toolbox, to accommodate jsweet old jvm requirement -->
					<release>11</release>
					<fork>true</fork>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>templating-maven-plugin</artifactId>
				<version>3.0.0</version>
				<executions>
					<execution>
						<id>preparing.jsweet.script</id>
						<goals>
							<goal>filter-sources</goal>
						</goals>
						<configuration>
							<sourceDirectory>src/main/jsweet</sourceDirectory>
							<outputDirectory>${project.build.directory}/jsweet</outputDirectory>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<version>3.0.0</version>
				<executions>
					<execution>
						<phase>generate-sources</phase>
						<goals>
							<goal>add-resource</goal>
						</goals>
						<configuration>
							<resources>
								<resource>
									<directory>${project.build.directory}/resources</directory>
									<targetPath />
									<excludes>
										<exclude>**/junk/**</exclude>
									</excludes>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>


			<plugin>
				<artifactId>maven-antrun-plugin</artifactId>
				<version>${antrun.plugin.version}</version>
				<executions>
                    <execution>
                        <id>antrun-jsweet</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <echo message="Running JSweet by calling mvn with MAVEN_OPTS" />
                                <exec executable="mvn">
                                    <env key="MAVEN_OPTS" value="--add-opens jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" />
                                    <arg value="-f" />
                                    <arg value="${project.build.directory}/jsweet/pom-jsweet.xml" />
                                    <arg value="jsweet:jsweet" />
                                </exec>
                            </target>
                        </configuration>
                    </execution>
					<execution>
						<phase>package</phase>
						<configuration>
							<target>
								<echo message="copying generated bundles to dist..." />
								<copy file="${project.build.directory}/resources/META-INF/resources/webjars/${project.artifactId}/${project.version}/bundle.js" tofile="dist/${project.artifactId}.js" verbose="true" failonerror="false" />
								<copy file="${project.build.directory}/resources/src/typings/${project.artifactId}/${project.version}/bundle.d.ts" tofile="dist/${project.artifactId}.d.ts" verbose="true" failonerror="false" />
							</target>
						</configuration>
						<goals>
							<goal>run</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

		</plugins>
	</build>
	<dependencies>
		<dependency>
			<groupId>org.jsweet</groupId>
			<artifactId>jsweet-core</artifactId>
			<version>6.3.1</version>
		</dependency>
	</dependencies>

</project>
