Accueil‎ > ‎

Host Maven Repository for Free

posted 27 Nov 2018, 07:55 by Christophe Noël   [ updated 29 Nov 2018, 02:10 ]
Actually, there is no (really) free Maven repository hosting. But it does not mean you have to pay for it !

Indeed, the solution comes from a very simple idea:
1. Build a maven repository locally
2. Copy to the file to a free hosting solution (Dropbox, Gitlab, Github, etc.)

Concretely, you build using:

-DaltDeploymentRepository=myRepositoryName::default::file:///C:/my/temp/dir

Then you need to copy/sync/push the directory to your hosting solution.

Once you understood this approach, we may go further in automation using GitHub using the Maven Plugin site-maven-plugin to publish the Maven site on build.

1. Let's build automatically the local repository on deploy

            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
                <configuration>            <altDeploymentRepository>internal.repo::default::file://C:/any/location</altDeploymentRepository>
                </configuration>
            </plugin>

2. Good, then here is how you publish automaticall to Github.

            <plugin>
                <groupId>com.github.github</groupId>
                <artifactId>site-maven-plugin</artifactId>
                <version>0.12</version>
                <configuration>
              
                    <message>Maven artifacts for ${project.version}</message> 
                    <project.url>https://github.com/xxx/yyy.git</project.url>
                    <noJekyll>true</noJekyll>                                  <!-- disable webpage processing -->
                    <outputDirectory>C:/any/location</outputDirectory> <!-- matches distribution management repository url above -->
                    <branch>refs/heads/master</branch>                       <!-- remote branch name -->
                    <includes>
                        <include>**/*</include>
                    </includes>
                    <repositoryName>maven-public-libs</repositoryName>      <!-- github repo name -->
                    <repositoryOwner>xxx</repositoryOwner>    <!-- github username  -->
                    
                </configuration>
                <executions>
                    <!-- run site-maven-plugin's 'site' target as part of the build's normal 'deploy' phase -->
                    <execution>
                        <goals>
                            <goal>site</goal>
                        </goals>
                        <phase>deploy</phase>
                    </execution>
                </executions>
            </plugin>



Comments