Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tools/build_config/pom.py
169674 views
1
#!/usr/bin/env python
2
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
# Copyright (C) 2011-2025 German Aerospace Center (DLR) and others.
4
# This program and the accompanying materials are made available under the
5
# terms of the Eclipse Public License 2.0 which is available at
6
# https://www.eclipse.org/legal/epl-2.0/
7
# This Source Code may also be made available under the following Secondary
8
# Licenses when the conditions for such availability set forth in the Eclipse
9
# Public License 2.0 are satisfied: GNU General Public License, version 2
10
# or later which is available at
11
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
14
# @file pom.py
15
# @author Michael Behrisch
16
# @author Robert Hilbrich
17
# @date 2021-01-15
18
19
"""
20
Generates pom files to build libsumo and libtraci jars
21
"""
22
from __future__ import absolute_import
23
from __future__ import print_function
24
import sys
25
import os
26
27
import version
28
29
# SUMO versioning is "backwards" - it is based on the
30
# last git tag encountered in the repository and adds
31
# the amount of additional commits at the end.
32
#
33
# MAVEN versioning works slightly different -
34
# 1.9.0-SNAPSHOT (according to SUMO versioning)
35
# corresponds 1.10.0-SNAPSHOT in the MAVEN world.
36
#
37
# In #7921 we decide to make things simple by just
38
# adding 1 to the minor part of the SUMO version to
39
# move it to the MAVEN world.
40
# (Except when we are precisely at a release / tagged commit,
41
# then we do not add the 1, because versions are exactly
42
# the same in both worlds here.)
43
#
44
# - SUMO: 1.9.0 --> MAVEN: 1.9.0 (release)
45
# - SUMO: 1.9.1 --> MAVEN: 1.9.1 (release)
46
# - SUMO: 1.9.0.post18 --> MAVEN: 1.10.0-SNAPSHOT
47
# - SUMO: 1.9.1.post23 --> MAVEN: 1.10.0-SNAPSHOT
48
49
v = version.get_pep440_version() # v = '1.9.0.post180'
50
51
# Are we past a release?
52
# (If there is no ".post", we are exactly at a release, so we dont touch it)
53
if ".post" in v:
54
# example: '1.9.0.post10' -> '1', '9', '0.post10'
55
major, minor, _ = v.split(".", 2)
56
# Want v = '1.10.0-SNAPSHOT',
57
# but need to make sure, minor releases like
58
# 1.9.1-SNAPSHOT work ok too!
59
# --> we just override the patch-level version with 0
60
v = '%s.%s.0-SNAPSHOT' % (major, int(minor) + 1)
61
62
root = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
63
64
with open("pom.xml", "w") as pom:
65
pom.write("""<?xml version="1.0" encoding="UTF-8"?>
66
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \
67
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
68
<modelVersion>4.0.0</modelVersion>
69
<groupId>org.eclipse.sumo</groupId>
70
<artifactId>%s</artifactId>
71
<version>%s</version>
72
<packaging>jar</packaging>
73
<properties>
74
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
75
<maven.compiler.source>1.8</maven.compiler.source>
76
<maven.compiler.target>1.8</maven.compiler.target>
77
</properties>
78
79
<distributionManagement>
80
<repository>
81
<id>repo.eclipse.org</id>
82
<name>Project Repository - Releases</name>
83
<url>https://repo.eclipse.org/content/repositories/sumo-releases/</url>
84
</repository>
85
<snapshotRepository>
86
<id>repo.eclipse.org</id>
87
<name>Project Repository - Snapshots</name>
88
<url>https://repo.eclipse.org/content/repositories/sumo-snapshots/</url>
89
</snapshotRepository>
90
</distributionManagement>
91
92
<licenses>
93
<license>
94
<name>Eclipse Public License - v 2.0</name>
95
<url>https://www.eclipse.org/legal/epl-2.0</url>
96
</license>
97
<license>
98
<name>GNU General Public License, version 2 or later</name>
99
<url>https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html</url>
100
</license>
101
</licenses>
102
103
<build>
104
<plugins>
105
<plugin>
106
<groupId>org.apache.maven.plugins</groupId>
107
<artifactId>maven-jar-plugin</artifactId>
108
<version>2.3.1</version>
109
<configuration>
110
<outputDirectory>%s</outputDirectory>
111
</configuration>
112
</plugin>
113
<plugin>
114
<groupId>org.apache.maven.plugins</groupId>
115
<artifactId>maven-source-plugin</artifactId>
116
<version>3.2.0</version>
117
<configuration>
118
<outputDirectory>%s</outputDirectory>
119
</configuration>
120
</plugin>
121
</plugins>
122
<resources>
123
<resource>
124
<directory>%s</directory>
125
<includes>
126
<include>LICENSE</include>
127
<include>NOTICE.md</include>
128
</includes>
129
<targetPath>META-INF</targetPath>
130
</resource>
131
</resources>
132
</build>
133
</project>
134
""" % (sys.argv[1], v, sys.argv[2], sys.argv[2], root))
135
136