Skip to content

Commit

Permalink
[MASSEMBLY-965] integration test ensuring correct copy of symbolic li…
Browse files Browse the repository at this point in the history
…nk (#82)


Co-authored-by: magu <[email protected]>
Co-authored-by: Slawomir Jaranowski <[email protected]>
  • Loading branch information
3 people authored May 1, 2023
1 parent 998f01a commit 17e7eb5
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/it/projects/file-sets/symbolic-links/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<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>
<parent>
<groupId>org.apache.maven.plugin.assembly.test</groupId>
<artifactId>it-project-parent</artifactId>
<version>1</version>
<relativePath>../../../it-project-parent/pom.xml</relativePath>
</parent>

<artifactId>symbolic-links</artifactId>
<packaging>pom</packaging>
<description>Test for MASSEMBLY-965 - Symbolic links get copied with absolute path</description>

<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/src.xml</descriptor>
</descriptors>
<attach>false</attach>
</configuration>
<executions>
<execution>
<id>single-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
32 changes: 32 additions & 0 deletions src/it/projects/file-sets/symbolic-links/setup.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/


import java.nio.file.Files

File target = new File('test.txt')
File link = new File(basedir, 'src/main/assembly-resources/a-symbolic-link')

if (link.exists()) {
link.delete()
}

Files.createSymbolicLink(link.toPath(), target.toPath())

return true
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
${project.version}
${project.artifactId}
35 changes: 35 additions & 0 deletions src/it/projects/file-sets/symbolic-links/src/main/assembly/src.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version='1.0'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>src</id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<outputDirectory></outputDirectory>
<directory>src/main/assembly-resources</directory>
</fileSet>
</fileSets>
</assembly>
35 changes: 35 additions & 0 deletions src/it/projects/file-sets/symbolic-links/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

File f = new File( basedir, "target/symbolic-links-1-src/a-symbolic-link" );

if ( !f.exists() ) {
println( "Copied link " + f + " is missing." )
return false
}

if ( !java.nio.file.Files.isSymbolicLink( f.toPath() ) ) {
println( "Not a symbolic link: " + f );
return false;
}

def linkTarget = java.nio.file.Files.readSymbolicLink( f.toPath() ).toString()
assert linkTarget == 'test.txt' : "Wrong link target for $f"

return true

0 comments on commit 17e7eb5

Please sign in to comment.