EPAM :: LightingTalks :: Oct 2013

7
Lightning Talks 1 Как загрузить артефакт из Maven, используя Java API? Ievgen Bogdanov

Transcript of EPAM :: LightingTalks :: Oct 2013

Lightning Talks 1Как загрузить артефакт из Maven, используя Java API?

Ievgen Bogdanov

Problem description

GroupId: com.wolterskluwer.services.configuration.conversionArtifactId: testVersion: 0.0.3Build: latest

• Service to manage maven artifacts• Get latest version (version+build No)• Download latest version

Old VS new (API) implementation

Old implementation:

• What if repository provider will be another? (new version)

• What if repository is secured?

New implementation requirements:

• Support configurable repositories (in XML style)

• Support security

• Make code robust and clean

Libraries and workflow

1. Read Maven settings (settings.xml)• maven-settings-builder (org.apache.maven)

2. Populate Aether repositories from Step 1• Aether-api

• Aether-util

3. Build artifactRequest

4. Create local repository• Aether-impl

5. Resolve artifact

To sum

• Only one possible approach to deal with Maven

• Pure documentation

• Lack of examples

• Get latest version means update local repository

Where to find

• Aether: http://eclipse.org/aether/

• Maven: http://maven.apache.org

• Example: http://git.eclipse.org/gitroot/aether/aether-demo.git

• Contact me ([email protected])

Appendix settings.xml<?xml version="1.0" encoding="UTF-8"?>

<settings …-->

<servers>

<server>

<id>archiva</id>

<username>USER</username>

<password>PASWORD</password>

</server>

</servers>

<!-- Where to store maven repo. Default is java.io.tmpdir folder -->

<localRepository>D:/repo</localRepository><activeProfiles>

<activeProfile>profile1</activeProfile></activeProfiles>

<profiles>

<profile>

<id>profile1</id>

<repositories>

<repository>

<id>archiva</id>

<url>http://url.to/repo/</url>

<releases>

<enabled>true</enabled>

<updatePolicy>always</updatePolicy>

<checksumPolicy>warn</checksumPolicy>

</releases>

</repository>

</repositories>

</profile>

</profiles>

</settings>