BJ5
BJ5

Reputation: 512

Maven deployed JARS from artifactory are not downloaded when they are given as dependency

I have created a jar file using maven and deployed it to local artifactory. I can see the jar file and pom in artifactory

<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.hr</groupId>
<artifactId>hotel-schema</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<parent>
    <groupId>com.mycompany.hr</groupId>
    <artifactId>spring-ws</artifactId>
    <version>1</version>
</parent>

<name>jaxb-schema Spring-WS Application</name>
<url>http://www.springframework.org/spring-ws</url>
<build>
    <finalName>hotel-schema</finalName>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <version>2.2</version>
            <executions>
                <execution>
                    <id>xjc</id>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                </execution>

            </executions>
            <configuration>
                <!-- The package of your generated sources -->
                <sources>
                    <source>../holidayService/src/main/xsd</source>
                </sources>
                <packageName>com.example.myschema</packageName>
                <outputDirectory>target/generated-sources/jaxb</outputDirectory>
            </configuration>

        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxb2-maven-plugin</artifactId>
        <version>2.2</version>
    </dependency>
</dependencies>

<distributionManagement>
    <repository>
        <id>central</id>
        <name>Babu-Dell-releases</name>
        <url>http://localhost:8081/artifactory/local-maven-snapshots</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <name>Babu-Dell-snapshots</name>
        <url>http://localhost:8081/artifactory/local-maven-snapshots</url>
    </snapshotRepository>
</distributionManagement>
</project>

However when I try to add the jar as dependency to another project, it is not getting downloaded. There is no error I can see.

<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>com.mycompany.hr</groupId>
    <artifactId>spring-ws</artifactId>
    <version>1</version>
</parent>
<artifactId>holidayService</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>holidayService Spring-WS Application</name>
<url>http://www.springframework.org/spring-ws</url>
<repositories>
    <repository>
        <id>my-internal-site</id>
        <url>http://localhost:8081/artifactory/local-maven-snapshots</url>
    </repository>
</repositories>
<build>
    <finalName>holidayService</finalName>
    <extensions>
        <extension>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-ftp</artifactId>
            <version>2.10</version>
        </extension>
    </extensions>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>tomcat-maven-plugin</artifactId>
            <version>1.1</version>
        </plugin>
    </plugins>
</build>
<dependencies>


    <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-ws-core</artifactId>
        <version>2.1.4.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>jaxen</groupId>
        <artifactId>jaxen</artifactId>
        <version>1.1.6</version>
    </dependency>
    <dependency>
        <groupId>org.jdom</groupId>
        <artifactId>jdom</artifactId>
        <version>2.0.2</version>

    </dependency>

    <dependency>
        <groupId>com.mycompany.hr</groupId>
        <artifactId>hotel-schema</artifactId>
        <version>1.0</version>
    </dependency>

</dependencies>

<distributionManagement>
    <repository>
        <id>central</id>
        <name>Babu-Dell-releases</name>
        <url>http://localhost:8081/artifactory/local-maven-snapshots</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <name>Babu-Dell-snapshots</name>
        <url>http://localhost:8081/artifactory/local-maven-snapshots</url>
    </snapshotRepository>
</distributionManagement>
</project>

Please help

Please find attached the image in my local repository[image of local repository][1]

Also please find below the settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
  <username>admin</username>
  <password>{YBoEnaZCnnEHquaMcfJGpTjh0I7i+vQAv9a2+CQL9ZE=}</password>
  <id>central</id>
</server>
<server>
  <username>admin</username>
  <password>{YBoEnaZCnnEHquaMcfJGpTjh0I7i+vQAv9a2+CQL9ZE=}</password>
  <id>snapshots</id>
</server>
</servers>
<profiles>
<profile>
  <repositories>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>libs-release</name>
      <url>http://localhost:8081/artifactory/local-maven-snapshots</url>
    </repository>
    <repository>
      <snapshots />
      <id>snapshots</id>
      <name>libs-snapshot</name>
      <url>http://localhost:8081/artifactory/local-maven-snapshots</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>plugins-release</name>
      <url>http://localhost:8081/artifactory/plugins-release</url>
    </pluginRepository>
    <pluginRepository>
      <snapshots />
      <id>snapshots</id>
      <name>plugins-snapshot</name>
      <url>http://localhost:8081/artifactory/plugins-snapshot</url>
    </pluginRepository>
  </pluginRepositories>
  <id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>

Image of eclipse maven dependencies

Artifactory server jar file image

Upvotes: 0

Views: 5481

Answers (2)

Shub
Shub

Reputation: 23

Appears that your profile not enabled, make it active by default or else give id to profile and append -PprofileId in your command, it should download.

Upvotes: 0

Michele Sacchetti
Michele Sacchetti

Reputation: 163

I think you made a bit of confusion here. You probably installed artifactory locally and you properly configured your maven settings.xml to point to it, but in your screenshot you are showing us the maven local repository under your .m2 folder.

They are 2 different repository as already stated by Gerold.

If you want your artifact to go on your LOCAL repo (i.e. your .m2/repository folder) you must invoke mvn install goal, while to deploy your artifact to REMOTE artifactory you have to invoke maven deploy goal and have a distributionManagement configured in your project which tell the project where to deploy.

If you just want to work locally you have no need to install artifactory, simply use your local repository (maven will do this for you out-of-the-box, so you can remove all the additional repository section in your settings.xml and the distributionManagement section.

Artifactory is extremely useful for team work, but should not be hosted locally but on a shared server where all team members can access. In any case, if you want to use it, you should check from its web interface if the artifact has been properly deployed.

Finally, as already asked, which is the error you got after a "mvn clean deploy" command ? there may be many reason why artifact has been installed locally (as per your screenshot) but not remotely (on artifactory)

Upvotes: 1

Related Questions