0

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 Answers2

0

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.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • Can i add archetypes to my local maven repository and try to create project in eclipse without connection to the internet? Is it possible? Maybe i need to add archetype-catalog.xml in my .m2 folder on my computer? – Alexander Gorbenko Oct 03 '19 at 07:41
  • Can you prefer more information about copy artifacts from one archiva to the another please? What should I do? – Alexander Gorbenko Oct 03 '19 at 07:50
  • You _can_ add the archetypes to your local repository and it will work, but these archetypes have dependencies, which themselves have dependencies and those have dependencies as well. If you try to figure that out by hand, you probably spend two weeks copying artifacts. 2. I have no experience with Archiva. Nowadays, people mostly use Nexus or Artifactory (which both have a version that is for free). In Nexus 2, you can just copy the storage directory from one computer to the other. In other repositories, it is usually more difficult. – J Fabian Meier Oct 03 '19 at 09:01
  • And let me give you this warning: It is hard to manage an "offline" Maven repository because every time you change something with the dependencies of a project, you need to copy _again_ a lot of stuff from MavenCentral to that offline repository. I tried to write a script that figures out _what_ you need to copy, but it is only 90% correct and often I will build a project 10 times against the offline Maven repository (always failing due to some missing artifact) until I have everything I need. – J Fabian Meier Oct 03 '19 at 09:03
  • Okey, so we need internet connection anyway. What if we create local maven repository with internet access will i see maven archetypes from eclipse at the start? What steps should i do before to see them? Do you recommend to create project on computer with direct access to maven repository and then copy it to the other computer without internet access and work with local repository? Thank you for the answers, really appreciate it. – Alexander Gorbenko Oct 03 '19 at 09:27
  • If you have no user settings.xml or put MavenCentral into it, Eclipse will try to resolve the archetypes from the internet and put them into your local repository. In a restricted environment, it is usually a good idea to have Archiva/Nexus/Artifactory running and let it handle the downloading from the internet. All users can then connect to that repository. – J Fabian Meier Oct 03 '19 at 17:18
-1

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.

Sambit
  • 7,625
  • 7
  • 34
  • 65