0

With a lot of people working from home currently and using VPNs, I am having an issue with building on maven for personal projects that don't use work related artefacts.

Which results in me always needing to be connected to the VPN.

For example if I create a new spring boot application, it requires me to be on the VPN otherwise it won't be able to build properly, with an error like this:

Failed to read artifact descriptor for com.hubspot.slack:slack-base:jar:1.8: Could not transfer artifact com.hubspot.slack:slack-base:pom:1.8 from/to at-repository (https://foobar.jfrog.io/foobar/public): Access denied to: https://foobar.jfrog.io/foobar/public/com/hubspot/slack/slack-base/1.8/slack-base-1.8.pom

Is there a way for me to configure maven to try and build without the need for my company repository?

Or can I have multiple configs and a way to switch between them?

I understand it should fail for foocompany specific artefacts but not everything else.

This is the config.xml (redacted name)

    <?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">
    <mirrors>

        <mirror>
            <id>foo-repository</id>
            <url>https://foo.jfrog.io/foo/public</url>
            <mirrorOf>*</mirrorOf>
        </mirror>
    </mirrors>

    <servers>
        <server>
            <id>foo-repository</id>
            <username>deployment</username>
            <password>xxx</password>
        </server>
        <server>
            <id>snapshots</id>
            <username>deployment</username>
            <password>xxx</password>
        </server>
        <server>
            <id>releases</id>
            <username>deployment</username>
            <password>xxx</password>
        </server>
    </servers>

    <profiles>
        <profile>
            <id>default</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>

            <repositories>
                <repository>
                    <id>foo-repository</id>
                    <url>This has to be populated but the URL will be taken from the mirror.</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>

            <pluginRepositories>
                <pluginRepository>
                    <id>foo-repository</id>
                    <url>This has to be populated but the URL will be taken from the mirror.</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
</settings>
tomaytotomato
  • 3,788
  • 16
  • 64
  • 119
  • When you are building a personal project and you are off your VPN, just rename the config.xml to something like config.off - effectively remove the config. – SiKing Apr 27 '20 at 15:42
  • You can run Maven in offline mode, see e.g. https://stackoverflow.com/a/7233762/927493 – J Fabian Meier Apr 27 '20 at 15:55

1 Answers1

0

Essentially it was a case of disabling the user maven config like so and using a bash alias to make it easier

#turn off default settings
mv ~/.m2/settings.xml ~/.m2/settings.xml.off

#turn on again
mv ~/.m2/settings.xml.off ~/.m2/settings.xml

More info on my workaround can be seen here:

https://tomaytotomato.com/maven-whilst-working-from-home/

tomaytotomato
  • 3,788
  • 16
  • 64
  • 119