mavenmaven-archetypemaven-wagon-plugin

Store Maven Archetype In Google Cloud Storage


I am using a Maven wagon to store my artifacts in Google Cloud Storage. I followed this blog post https://egkatzioura.com/2018/04/09/host-your-maven-artifacts-using-google-cloud-storage/. I wanted to avoid using nexus for the overhead of running a server and the storage cost savings I could get from GCS.

Now I am creating some Maven Archetypes I'd also like to store this in GCS and have people be able to generate the archetype on their machines.

I have been unable to find any help on how I can do this, is it possible to use a wagon for your general settings and pull archetypes from it?


Solution

  • I have been able to solve my own questions. I needed to add the Google Wagon jar to my Maven lib directory. I also added an archetype profile to my .m2/settings.xml.

    <?xml version="1.0" encoding="UTF-8"?>
    <settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
      ...
      <profiles>
        <profile>
           <id>Archetype</id>
           <repositories>
              <repository>
                 <id>archetype</id>
                 <url>gs://my-archetype-bucket</url>
                 <releases>
                    <enabled>true</enabled>
                    <checksumPolicy>fail</checksumPolicy>
                 </releases>
                 <snapshots>
                    <enabled>true</enabled>
                    <checksumPolicy>warn</checksumPolicy>
                 </snapshots>
              </repository>
              <repository>
                <id>central</id>
                <url>http://repo1.maven.org/maven2/</url>
              </repository>
           </repositories>
        </profile>
      </profiles>
      <activeProfiles>
        <activeProfile>Archetype</activeProfile>
      </activeProfiles>
    </settings>