Use Azure WebSites to host custom maven repository

I was trying to set up a temporary maven repository to share java libraries. It turns out you can easily do it for free using azure WebSites. Here are step-by-step instructions:

<publishData>
	<morePublishingOptions>
	<publishProfile 
		profileName="dotm2 - FTP" 
		publishMethod="FTP" 
		publishUrl="ftp://waws-prod-dm1-003.ftp.azurewebsites.windows.net/site/wwwroot" 
		ftpPassiveMode="True" 
		userName="dotm2\$dotm2" 
		userPWD="password goes here" 
	</publishProfile>
</publishData>

Now you can access web site content by FTP.

<configuration>
	<system.webServer>
		<directoryBrowse enabled="true" showFlags="Date,Time,Extension,Size" />
		<staticContent>
			<mimeMap fileExtension=".pom" mimeType="application/xml" />
			<mimeMap fileExtension=".md5" mimeType="text/plain" />
			<mimeMap fileExtension=".sha1" mimeType="text/plain" />
		</staticContent>
	</system.webServer>
</configuration>

update(1/3/2015): At the moment of publication I forgot to configure mime types so pom files wasn’t accessible and gradle wasn’t able to resolve dependencies

apply plugin: 'maven'

configurations {
    deployerJars
}

repositories {
    mavenCentral()
}

dependencies { 
    deployerJars "org.apache.maven.wagon:wagon-ftp:2.8"
} 

version = "1.0.0-SNAPSHOT"
group = "com.microsoft.applicationinsights"

uploadArchives {
    repositories {
        mavenDeployer {
            configuration = configurations.deployerJars

            repository(url: "ftp://waws-prod-dm1-003.ftp.azurewebsites.windows.net/site/wwwroot/repository/") { 
                authentication(userName: "dotm2\\\$dotm2", password:javamavenuserpassword)
            }
         }
    }
}

Note, I’ve used variable “javamavenuserpassword” that you’ll need to supply to gradle to upload artifacts.

gradlew uploadArchives -Pjavamavenuserpassword=<password goes here>

That’s it. Now you can use artifacts from your repository like this:

repositories {
    mavenCentral()

    maven {
        url 'http://dotm2.azurewebsites.net/repository/'
    }
}

Comments

comments powered by Disqus