How to connect local archiva repository and create maven project in Eclipse?

646 views Asked by At

I have no internet access on my project and trying to deploy archiva and use it to create maven projects offline. So, i downloaded apache archiva and deployed it on my local computer. Then i created local repository with this settings. repository settings

Then i changed settings.xml in maven folder

    <?xml version="1.0" encoding="UTF-8"?>
    <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 
    http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>C:/MavenRepository/.m2/repository</localRepository>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
</servers>
<mirrors>
    <mirror>
        <id>local.repository</id>
        <name>test repo</name>

    <url>http://localhost:8888/archiva/repository/local.repository</url>
        <mirrorOf>*</mirrorOf>
    </mirror>
</mirrors>
<profiles>
    <profile>
        <id>local</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>

        <repositories>
            <repository>
                <id>local.repository</id>
                <name>local.repository</name>

     <url>http://localhost:8888/repository/local.repository/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>local.repository</id>
                <name>local.repository</name>

   <url>http://localhost:8888/repository/local.repository/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
            </pluginRepository>
        </pluginRepositories>
    </profile>
</profiles>
    </settings>

and then tried to add archetype catalog in maven settings in eclipse but it saying remote catalog is empty empty remote catalog. What i need to do to get correct archetypes to create maven project in eclipse?

2

There are 2 answers

6
J Fabian Meier On

You created a new Maven repository. It is empty. Then you defined it as mirror in your settings.xml. This means that all requests (including the one for archetypes) go to an empty repository.

The same will happen when you try to build anything with Maven. Maven will try to download tons of plugins, JARs, POMs etc. from the Maven repository and will fail.

You will need Internet connection somewhere. You can e.g. connect your archiva to MavenCentral, build your project and then shut down the connection. Or you can do this on another computer and copy the artifacts from one archiva to the other.

2
Sambit On

Before you create a maven project with Archiva or Nexus, you have make the following settings for Maven.

  1. Go to Maven installation folder and open the file /conf/settings.xml, and add the following for Archiva.
<mirror>
  <id>internal</id>
  <name>Proxy Cache - Internal Repository</name>
  <url>http://localhost:8080/archiva/repository/internal</url>
  <mirrorOf>*</mirrorOf>
</mirror>
  1. Configure eclipse with local maven setting. Go to preference in Eclipse, Preference > Maven > Installation and add the local maven setup for eclipse so that Eclipse will know about the local settings.
  2. Then configure the user setting in eclipse with the local maven setting.xml. Go to Preference > Maven > User Settings and click on Browse button to select the /conf/settings.xml file from Maven installation folder.

Finally you can try to create a maven project or you import a Maven project.