Skip to content

Instantly share code, notes, and snippets.

@stokito
Last active December 5, 2017 07:58
Show Gist options
  • Save stokito/067948b71f5b2bce4f0bd1ef5ea631f0 to your computer and use it in GitHub Desktop.
Save stokito/067948b71f5b2bce4f0bd1ef5ea631f0 to your computer and use it in GitHub Desktop.
Example of creation symlink to target folder on Windows. symlink may be to another partion with more space or even in memory (that increases build speed up to 20%)
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.stokito</groupId>
<artifactId>clean-symlink-sample</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<fileset>
<directory>target</directory>
<followSymlinks>false</followSymlinks>
<includes>
<include>**/*</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>com.pyx4j</groupId>
<artifactId>maven-junction-plugin</artifactId>
<version>1.0.3</version>
<executions>
<execution>
<id>id.post-clean</id>
<phase>clean</phase>
<goals>
<goal>link</goal>
</goals>
</execution>
</executions>
<configuration>
<links>
<!-- link the html generated by client to webapp directory -->
<link>
<src>C:/opt/dist/${project.artifactId}</src>
<dst>${project.build.directory}</dst>
</link>
</links>
</configuration>
</plugin>
</plugins>
</build>
</project>
<profiles>
<profile>
<id>inmemory</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>createInMemoryTarget</id>
<phase>initialize</phase>
<configuration>
<tasks>
<mkdir dir="M:/${project.groupId}/${project.artifactId}/${project.version}"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.pyx4j</groupId>
<artifactId>maven-junction-plugin</artifactId>
<version>1.0.3</version>
<executions>
<execution>
<id>symlinkTargetToInMemory</id>
<phase>initialize</phase>
<goals>
<goal>link</goal>
</goals>
</execution>
</executions>
<configuration>
<links>
<!-- link the target folder to appropriate in-memory to directory -->
<link>
<src>M:/${project.groupId}/${project.artifactId}/${project.version}</src>
<dst>${project.build.directory}</dst>
</link>
</links>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
@stokito
Copy link
Author

stokito commented May 10, 2016

See also ImDisk help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment