<!--

    Copyright © 2016-2026 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<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>
    <parent>
        <groupId>org.thingsboard</groupId>
        <version>4.4.0-SNAPSHOT</version>
        <artifactId>thingsboard</artifactId>
    </parent>
    <artifactId>application</artifactId>
    <packaging>jar</packaging>

    <name>ThingsBoard Server Application</name>
    <url>https://thingsboard.io</url>
    <description>Open-source IoT Platform - Device management, data collection, processing and visualization
    </description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <main.dir>${basedir}/..</main.dir>
        <pkg.type>java</pkg.type>
        <pkg.process-resources.phase>process-resources</pkg.process-resources.phase>
        <pkg.package.phase>package</pkg.package.phase>
        <pkg.name>thingsboard</pkg.name>
        <pkg.win.dist>${project.build.directory}/windows</pkg.win.dist>
        <pkg.copyInstallScripts>true</pkg.copyInstallScripts>
        <pkg.implementationTitle>ThingsBoard</pkg.implementationTitle>
        <pkg.mainClass>org.thingsboard.server.ThingsboardServerApplication</pkg.mainClass>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-transport-native-epoll</artifactId>
            <!-- Explicitly bring in the linux classifier, test may fail on 32-bit linux -->
            <classifier>linux-x86_64</classifier>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.common</groupId>
            <artifactId>actor</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.common</groupId>
            <artifactId>util</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.rule-engine</groupId>
            <artifactId>rule-engine-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.common</groupId>
            <artifactId>cluster-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.common</groupId>
            <artifactId>version-control</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.rule-engine</groupId>
            <artifactId>rule-engine-components</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.common.transport</groupId>
            <artifactId>transport-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.common.transport</groupId>
            <artifactId>mqtt</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.common.transport</groupId>
            <artifactId>http</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.common.transport</groupId>
            <artifactId>coap</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.common.transport</groupId>
            <artifactId>lwm2m</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.common.transport</groupId>
            <artifactId>snmp</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard</groupId>
            <artifactId>dao</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.common</groupId>
            <artifactId>queue</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.common.script</groupId>
            <artifactId>script-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.common.script</groupId>
            <artifactId>remote-js-client</artifactId>
        </dependency>
        <dependency>
        <groupId>org.thingsboard.common</groupId>
            <artifactId>stats</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.common</groupId>
            <artifactId>edge-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.common</groupId>
            <artifactId>edqs</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.common</groupId>
            <artifactId>discovery-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard</groupId>
            <artifactId>dao</artifactId>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.takari.junit</groupId>
            <artifactId>takari-cpsuite</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.paho</groupId>
            <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.paho</groupId>
            <artifactId>org.eclipse.paho.mqttv5.client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard</groupId>
            <artifactId>ui-ngx</artifactId>
            <version>${project.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-websocket</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-oauth2-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-oauth2-jose</artifactId>
        </dependency>
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-freemarker</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-csv</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>log4j-over-slf4j</artifactId>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sun.mail</groupId>
            <artifactId>jakarta.mail</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.twilio.sdk</groupId>
            <artifactId>twilio</artifactId>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-sns</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-recipes</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-tcnative-boringssl-static</artifactId>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-netty-shaded</artifactId>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-protobuf</artifactId>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-stub</artifactId>
        </dependency>
        <dependency>
            <groupId>org.opensmpp</groupId>
            <artifactId>opensmpp-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard</groupId>
            <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sun.winsw</groupId>
            <artifactId>winsw</artifactId>
            <classifier>bin</classifier>
            <type>exe</type>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.thingsboard</groupId>
            <artifactId>tools</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.thingsboard</groupId>
            <artifactId>rest-client</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.client</groupId>
            <artifactId>thingsboard-ce-client</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path</artifactId>
        </dependency>
        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path-assert</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.dbunit</groupId>
            <artifactId>dbunit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.github.springtestdbunit</groupId>
            <artifactId>spring-test-dbunit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>cassandra</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>postgresql</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>jdbc</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.javadelight</groupId>
            <artifactId>delight-nashorn-sandbox</artifactId>
        </dependency>
        <dependency>
            <groupId>org.passay</groupId>
            <artifactId>passay</artifactId>
        </dependency>
        <dependency>
            <groupId>com.github.ua-parser</groupId>
            <artifactId>uap-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.java-websocket</groupId>
            <artifactId>Java-WebSocket</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.aerogear</groupId>
            <artifactId>aerogear-otp-java</artifactId>
        </dependency>
        <dependency>
            <groupId>com.slack.api</groupId>
            <artifactId>slack-api-client</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.oauth-client</groupId>
            <artifactId>google-oauth-client</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.firebase</groupId>
            <artifactId>firebase-admin</artifactId>
        </dependency>
        <dependency>
            <groupId>org.rocksdb</groupId>
            <artifactId>rocksdbjni</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.langchain4j</groupId>
            <artifactId>langchain4j-open-ai</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.langchain4j</groupId>
            <artifactId>langchain4j-azure-open-ai</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.langchain4j</groupId>
            <artifactId>langchain4j-google-genai</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.langchain4j</groupId>
            <artifactId>langchain4j-mistral-ai</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.langchain4j</groupId>
            <artifactId>langchain4j-anthropic</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.langchain4j</groupId>
            <artifactId>langchain4j-bedrock</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.langchain4j</groupId>
            <artifactId>langchain4j-open-ai-official</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thingsboard.langchain4j</groupId>
            <artifactId>langchain4j-ollama</artifactId>
        </dependency>
    </dependencies>

    <build>
        <finalName>${pkg.name}-${project.version}</finalName>
        <resources>
            <resource>
                <directory>${project.basedir}/src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>thingsboard.yml</include>
                </includes>
            </resource>
            <resource>
                <directory>${project.basedir}/src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>thingsboard.yml</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>io.github.git-commit-id</groupId>
                <artifactId>git-commit-id-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>
                        <spring.config.name>thingsboard</spring.config.name>
                        <project.version>${project.version}</project.version>
                    </systemPropertyVariables>
                    <excludes>
                        <exclude>**/nosql/*Test.java</exclude>
                    </excludes>
                    <includes>
                        <include>**/*Test.java</include>
                        <include>**/*TestSuite.java</include>
                    </includes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.thingsboard</groupId>
                <artifactId>gradle-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>openapi-spec</id>
            <properties>
                <pkg.disabled>true</pkg.disabled>
                <pkg.package.phase>none</pkg.package.phase>
                <pkg.process-resources.phase>none</pkg.process-resources.phase>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                        <configuration>
                            <mainClass>org.thingsboard.server.ThingsboardServerApplication</mainClass>
                            <jmxPort>9001</jmxPort>
                        </configuration>
                        <executions>
                            <execution>
                                <id>build-info</id>
                                <goals><goal>build-info</goal></goals>
                                <configuration>
                                    <skip>false</skip>
                                </configuration>
                            </execution>
                            <execution>
                                <id>openapi-start</id>
                                <goals><goal>start</goal></goals>
                                <configuration>
                                    <skip>false</skip>
                                    <useTestClasspath>true</useTestClasspath>
                                    <jvmArguments>-Xmx1024m</jvmArguments>
                                    <arguments>
                                        <argument>--spring.config.name=thingsboard</argument>
                                        <argument>--spring.profiles.active=openapi</argument>
                                    </arguments>
                                    <maxAttempts>180</maxAttempts>
                                    <wait>2000</wait>
                                </configuration>
                            </execution>
                            <execution>
                                <id>openapi-stop</id>
                                <goals><goal>stop</goal></goals>
                                <configuration>
                                    <skip>false</skip>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.springdoc</groupId>
                        <artifactId>springdoc-openapi-maven-plugin</artifactId>
                        <version>1.4</version>
                        <executions>
                            <execution>
                                <id>generate-openapi-spec</id>
                                <goals><goal>generate</goal></goals>
                            </execution>
                        </executions>
                        <configuration>
                            <apiDocsUrl>http://localhost:8080/v3/api-docs/thingsboard</apiDocsUrl>
                            <outputFileName>openapi.json</outputFileName>
                            <outputDir>${project.build.directory}</outputDir>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>verify-openapi-spec-generated</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <requireFilesExist>
                                            <files>
                                                <file>${project.build.directory}/openapi.json</file>
                                            </files>
                                            <message>OpenAPI spec was not generated — target/openapi.json is missing. The springdoc-openapi-maven-plugin logs HTTP failures but does not fail the build; scan the log above for "An error has occured" or a 5xx response from /v3/api-docs/thingsboard and fix the underlying issue (e.g. duplicate @Schema names rejected by SwaggerConfiguration).</message>
                                        </requireFilesExist>
                                    </rules>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    <repositories>
        <repository>
            <id>jenkins</id>
            <name>Jenkins Repository</name>
            <url>https://repo.jenkins-ci.org/releases</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
</project>
