Created
February 13, 2013 11:28
-
-
Save rkistner/4943973 to your computer and use it in GitHub Desktop.
Upload Maven artifacts to remote S3 repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.example</groupId> | |
<artifactId>mvnuploader</artifactId> | |
<version>1.0.0-SNAPSHOT</version> | |
<packaging>pom</packaging> | |
<name>Uploader</name> | |
<build> | |
<extensions> | |
<extension> | |
<groupId>org.springframework.build</groupId> | |
<artifactId>aws-maven</artifactId> | |
<version>4.4.0.RELEASE</version> | |
</extension> | |
</extensions> | |
</build> | |
<repositories> | |
<repository> | |
<id>aws-releases</id> | |
<name>AWS Release Repository</name> | |
<url>s3://your.bucket.name/release</url> | |
</repository> | |
</repositories> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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"> | |
<servers> | |
<server> | |
<id>aws-releases</id> | |
<username><!-- access ID here --></username> | |
<passphrase><!-- secret ID here --></passphrase> | |
</server> | |
</servers> | |
</settings> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
MVN = 'mvn' | |
REPO_URL = 's3://your.bucket.name/releases' | |
REPO_ID = 'aws-releases' | |
DIR = '/opt/sonatype-work/nexus/storage/releases' | |
poms = Dir["#{DIR}/**/*.pom"] | |
puts "Uploading #{poms.count} artifacts" | |
count = 0 | |
poms.each do |pom| | |
pomxml = File.read(pom) | |
match = /.packaging.(\w+)..packaging./.match(pomxml) | |
packaging = 'jar' | |
if match | |
packaging = match[1] | |
end | |
artifact = pom.gsub(/pom$/, packaging) | |
if File.exists?(artifact) | |
puts "uploading #{count+1}: #{artifact}" | |
puts `#{MVN} deploy:deploy-file -DpomFile=#{pom} -Durl=#{REPO_URL} -Dfile=#{artifact} -DrepositoryId=#{REPO_ID}` | |
end | |
count += 1 | |
end | |
puts count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment