"""
Generates pom files to build libsumo and libtraci jars
"""
from __future__ import absolute_import
from __future__ import print_function
import sys
import os
import version
v = version.get_pep440_version()
if ".post" in v:
major, minor, _ = v.split(".", 2)
v = '%s.%s.0-SNAPSHOT' % (major, int(minor) + 1)
root = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
with open("pom.xml", "w") as pom:
pom.write("""<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.sumo</groupId>
<artifactId>%s</artifactId>
<version>%s</version>
<packaging>jar</packaging>
<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>
<distributionManagement>
<repository>
<id>repo.eclipse.org</id>
<name>Project Repository - Releases</name>
<url>https://repo.eclipse.org/content/repositories/sumo-releases/</url>
</repository>
<snapshotRepository>
<id>repo.eclipse.org</id>
<name>Project Repository - Snapshots</name>
<url>https://repo.eclipse.org/content/repositories/sumo-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<licenses>
<license>
<name>Eclipse Public License - v 2.0</name>
<url>https://www.eclipse.org/legal/epl-2.0</url>
</license>
<license>
<name>GNU General Public License, version 2 or later</name>
<url>https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html</url>
</license>
</licenses>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>%s</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<outputDirectory>%s</outputDirectory>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>%s</directory>
<includes>
<include>LICENSE</include>
<include>NOTICE.md</include>
</includes>
<targetPath>META-INF</targetPath>
</resource>
</resources>
</build>
</project>
""" % (sys.argv[1], v, sys.argv[2], sys.argv[2], root))