Skip to content

Commit

Permalink
more work
Browse files Browse the repository at this point in the history
  • Loading branch information
Aklakan committed Feb 16, 2024
1 parent dc8508d commit 0257501
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 24 deletions.
5 changes: 5 additions & 0 deletions docs/deployment/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Deployment
layout: default
nav_order: 40
---
15 changes: 8 additions & 7 deletions docs/archive-code.md → docs/how-tos/archive-code.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
title: Archiving Code and Data
title: Archive a Directory as a JAR
layout: default
nav_order: 35
parent: How-Tos
nav_order: 10
---

# Archiving Resources
# Archive a Directory as a JAR

## Synopsis

This chapter shows how any folder can be quickly archived as a versioned maven artifact.
This chapter shows how any folder can be quickly archived as a versioned maven artifact (of type JAR).

## Purpose

Expand All @@ -34,15 +35,15 @@ Adjust the `folder` property to a meaningful folder of your project such as `src
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.aksw.maven4data.examples</groupId>
<artifactId>archive-folder</artifactId>
<artifactId>my-archived-directory</artifactId>
<version>1.0.0-SNAPSHOT</version>

<!-- JAR files are ZIP files, so we are actually just creating a ZIP file here -->
<packaging>jar</packaging>

<properties>
<!-- Adjust the path to your needs -->
<folder>.</folder>
<directory-to-archive>.</directory-to-archive>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand All @@ -51,7 +52,7 @@ Adjust the `folder` property to a meaningful folder of your project such as `src
<build>
<resources>
<resource>
<directory>${folder}</directory>
<directory>${directory-to-archive}</directory>
</resource>
</resources>
</build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
title: Attaching Artifacts
layout: default
nav_order: 30
parent: How-Tos
nav_order: 20
---

## Attaching Artifacts
Expand All @@ -17,21 +18,10 @@ Installing or deploying the output will also install or deploy the attached arti
* Keeps dataset files accessible as separate files - i.e. without bundling them up, for example, as a JAR file.
* Deployment of the maven build output to a Build Artifact Repository Manager such as [Archiva](https://archiva.apache.org/) makes those artifacts easily accessible via HTTP(s).

## Referencing attached Artifacts

Attached artifacts can be referenced using the `pom.xml`'s [GAV](maven-concepts.md) plus the attached type and classifier.
For example, the `pom.xml` below will install itself as `org.aksw.maven4data.examples:attach-example:1.0.0-SNAPSHOT:xml:example`:

```bash
mvn dependency:copy -D'artifact=org.aksw.maven4data.examples:attach-example:1.0.0-SNAPSHOT:xml:myclassifier' \
-Dmdep.stripVersion=true -D'outputDirectory=.'
```
This will create the file `attach-example-myclassifier.xml` in the local directory. The filename follows the pattern `[artifactId]-[classifier].[type]`.


## Example

* The following example is self contained: Save the following snippet as `pom.xml` and run `mvn install`.
* The following example is self contained: Save the following snippet as `pom.xml` and run `mvn package`.


```xml
Expand All @@ -47,10 +37,10 @@ This will create the file `attach-example-myclassifier.xml` in the local directo
<name>Attach Artifact Example</name>

<properties>
<filepath>pom.xml</filepath>
<filepath>pom.xml</filepath>
<filetype>xml</filetype>
<classifier>myclassifier</classifier>

<build-helper-maven-plugin.version>3.5.0</build-helper-maven-plugin.version>
</properties>

Expand All @@ -72,8 +62,8 @@ This will create the file `attach-example-myclassifier.xml` in the local directo
<artifacts>
<artifact>
<file>${filepath}</file>
<type>${filetype}</type>
<classifier>${classifier}</classifier>
<type>${filetype}</type>
<classifier>${classifier}</classifier>
</artifact>
</artifacts>
</configuration>
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions docs/how-tos/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: How-Tos
layout: default
nav_order: 30
---
78 changes: 78 additions & 0 deletions docs/how-tos/reference-published-artifacts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
title: Referencing Non-JAR Artifacts
layout: default
parent: How-Tos
nav_order: 30
---

# Referencing Artifacts

## Downloading an artifact with the CLI

Attached artifacts can be referenced using the `pom.xml`'s [GAV](maven-concepts.md) plus the attached type and classifier.
For example, the `pom.xml` below will install itself as `org.aksw.maven4data.examples:attach-example:1.0.0-SNAPSHOT:xml:example`:

```bash
mvn dependency:copy -D'artifact=org.aksw.maven4data.examples:attach-example:1.0.0-SNAPSHOT:xml:myclassifier' \
-Dmdep.stripVersion=true -D'outputDirectory=.'
```
This will create the file `attach-example-myclassifier.xml` in the local directory. The filename follows the pattern `[artifactId]-[classifier].[type]`.

## Downloading an artifact from the pom.xml

```bash
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.aksw.maven4data.examples</groupId>
<artifactId>download-maven-artifact</artifactId>
<version>1.0.0-SNAPSHOT</version>

<packaging>pom</packaging>

<properties>
<datasetDirectory>${project.build.directory}/datasets</datasetDirectory>
</properties>

<build>
<resources>
<resource>
<directory>${project.build.directory}/datasets</directory>
</resource>
</resources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>resource-dependencies</id>
<phase>process-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<stripVersion>true</stripVersion>
<artifactItems>

<artifactItem>
<groupId>org.aksw.maven4data.examples</groupId>
<artifactId>climatetrace-fluorinated-gases</artifactId>
<version>0.2.0</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${datasetDirectory}</outputDirectory>
</artifactItem>

</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
```
File renamed without changes.

0 comments on commit 0257501

Please sign in to comment.