Как добавить в maven локальную зависимость?

212
28 апреля 2018, 19:14

Главный pom.xml-родитель justvillage:

<?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>ua.lokha</groupId>
    <artifactId>justvillage</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <modules>
        <module>bukkit-klimenko</module>
        <module>bungee-klimenko</module>
        <module>common-klimenko</module>
    </modules>
    <properties>
        <kotlin.version>1.2.31</kotlin.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <plugin.authors>[lokha]</plugin.authors>
    </properties>
    <dependencies>
        <!-- Commons -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.7</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-math3</artifactId>
            <version>3.0</version>
        </dependency>
        <!--Kotlin-->
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib-jdk8</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-test</artifactId>
            <version>${kotlin.version}</version>
            <scope>test</scope>
        </dependency>
        <!-- Annotations -->
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>jsr305</artifactId>
            <version>3.0.2</version>
        </dependency>
    </dependencies>
    <repositories>
        <!-- GitHub -->
<!--
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
-->
        <!-- Наше -->
        <repository>
            <id>ml-nexus-read</id>
            <url>http://nexus.mineland.net/content/repositories/public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.7.0</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                    <executions>
                        <!-- Replacing default-compile as it is treated specially by maven -->
                        <execution>
                            <id>default-compile</id>
                            <phase>none</phase>
                        </execution>
                        <!-- Replacing default-testCompile as it is treated specially by maven -->
                        <execution>
                            <id>default-testCompile</id>
                            <phase>none</phase>
                        </execution>
                        <execution>
                            <id>java-compile</id>
                            <phase>compile</phase>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>java-test-compile</id>
                            <phase>test-compile</phase>
                            <goals>
                                <goal>testCompile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <!-- Старый компилятор
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
                -->
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin.version}</version>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <sourceDirs>
                                <sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
                                <sourceDir>${project.basedir}/src/main/java</sourceDir>
                            </sourceDirs>
                        </configuration>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                        <configuration>
                            <sourceDirs>
                                <sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
                                <sourceDir>${project.basedir}/src/test/java</sourceDir>
                            </sourceDirs>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <jvmTarget>1.8</jvmTarget>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Наследник common-klimenko:

<?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">
    <parent>
        <artifactId>justvillage</artifactId>
        <groupId>ua.lokha</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>common-klimenko</artifactId>
    <dependencies>
        <!--driver for connection to MYSql database -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.34</version>
            <scope>provided</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.2.16.Final</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-hikaricp</artifactId>
            <version>5.2.16.Final</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.zaxxer/HikariCP -->
        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.22</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.22</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>

Наследник bungee-klimenko, у которого в зависимостях есть common-klimenko:

<?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">
    <parent>
        <artifactId>justvillage</artifactId>
        <groupId>ua.lokha</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>bungee-klimenko</artifactId>
    <properties>
        <plugin.namePlugin>BungeeKlimenko</plugin.namePlugin>
        <plugin.mainClass>ua.lokha.bungeeklimenko.BungeeKlimenkoPlugin</plugin.mainClass>
    </properties>
    <dependencies>

        <!--Common code-->
        <dependency>
            <groupId>ua.lokha</groupId>
            <artifactId>common-klimenko</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <!--AntiBot-->
        <dependency>
            <groupId>net.justvillage</groupId>
            <artifactId>WorkingAntiBot</artifactId>
            <version>udobsta</version>
            <scope>provided</scope>
        </dependency>
        <!--BungeeCord-->
        <dependency>
            <groupId>net.justvillage</groupId>
            <artifactId>bungee</artifactId>
            <version>build1308</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.2</version>
                <configuration>
                    <outputDirectory>../TestBungee/plugins/</outputDirectory>
                    <finalName>${plugin.namePlugin}</finalName>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Выполняю clean install для common-klimenko:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building common-klimenko 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ common-klimenko ---
[INFO] Deleting D:\IdeaProjects\justvillage\common-klimenko\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ common-klimenko ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- kotlin-maven-plugin:1.2.31:compile (compile) @ common-klimenko ---
[WARNING] No sources found skipping Kotlin compile
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (java-compile) @ common-klimenko ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to D:\IdeaProjects\justvillage\common-klimenko\target\classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ common-klimenko ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\IdeaProjects\justvillage\common-klimenko\src\test\resources
[INFO] 
[INFO] --- kotlin-maven-plugin:1.2.31:test-compile (test-compile) @ common-klimenko ---
[WARNING] No sources found skipping Kotlin compile
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (java-test-compile) @ common-klimenko ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ common-klimenko ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ common-klimenko ---
[INFO] Building jar: D:\IdeaProjects\justvillage\common-klimenko\target\common-klimenko-1.0-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ common-klimenko ---
[INFO] Installing D:\IdeaProjects\justvillage\common-klimenko\target\common-klimenko-1.0-SNAPSHOT.jar to C:\Users\lokha\.m2\repository\ua\lokha\common-klimenko\1.0-SNAPSHOT\common-klimenko-1.0-SNAPSHOT.jar
[INFO] Installing D:\IdeaProjects\justvillage\common-klimenko\pom.xml to C:\Users\lokha\.m2\repository\ua\lokha\common-klimenko\1.0-SNAPSHOT\common-klimenko-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.304 s
[INFO] Finished at: 2018-04-27T14:35:56+03:00
[INFO] Final Memory: 23M/171M
[INFO] ------------------------------------------------------------------------

Выполняю clean package для bungee-klimenko:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building bungee-klimenko 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.428 s
[INFO] Finished at: 2018-04-27T14:39:16+03:00
[INFO] Final Memory: 7M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project bungee-klimenko: Could not resolve dependencies for project ua.lokha:bungee-klimenko:jar:1.0-SNAPSHOT: Failed to collect dependencies at ua.lokha:common-klimenko:jar:1.0-SNAPSHOT: Failed to read artifact descriptor for ua.lokha:common-klimenko:jar:1.0-SNAPSHOT: Failure to find ua.lokha:justvillage:pom:1.0-SNAPSHOT in http://nexus.mineland.net/content/repositories/public was cached in the local repository, resolution will not be reattempted until the update interval of ml-nexus-read has elapsed or updates are forced -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

Вот и ошибка. Failed to execute goal on project bungee-klimenko: Could not resolve dependencies for project ua.lokha:bungee-klimenko:jar:1.0-SNAPSHOT: Failed to collect dependencies at ua.lokha:common-klimenko:jar:1.0-SNAPSHOT: Failed to read artifact descriptor for ua.lokha:common-klimenko:jar:1.0-SNAPSHOT: Failure to find ua.lokha:justvillage:pom:1.0-SNAPSHOT in http://nexus.mineland.net/content/repositories/public was cached in the local repository, resolution will not be reattempted until the update interval of ml-nexus-read has elapsed or updates are forced -> [Help 1]

Почему оно не видит зависимость? Вот же она! В локальном репозитории, вот:

READ ALSO
Генерация QR-кода программно

Генерация QR-кода программно

Есть приложение с полями:

179
Как распарсить временную зону в DateTimeFormatter?

Как распарсить временную зону в DateTimeFormatter?

У меня есть String такого содержания:

217
Проблема с ListView и Sqlite

Проблема с ListView и Sqlite

В моем приложении для хранения данных используется SqliteВ таблице несколько столбцов, один из которых title

206
Проверить,есть ли информация в getIntent()

Проверить,есть ли информация в getIntent()

Есть условие,но нужно что-бы я знал,есть ли информация в getIntent, как это проверить?

175