Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ under the License.
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>4.13.0</version>
<version>4.14.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand Down
19 changes: 19 additions & 0 deletions src/it/jar-follow-symlinks/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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.

# Creating a symbolic link needs privileges that are not granted by default on Windows.
invoker.os.family = !windows
59 changes: 59 additions & 0 deletions src/it/jar-follow-symlinks/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?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>

<groupId>org.apache.maven.its.source</groupId>
<artifactId>jar-follow-symlinks</artifactId>
<version>1.0-SNAPSHOT</version>

<name>Test for followSymlinks</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<followSymlinks>true</followSymlinks>
</configuration>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
29 changes: 29 additions & 0 deletions src/it/jar-follow-symlinks/setup.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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

// A source directory that is a symbolic link to a tree kept outside src/main/java.
File link = new File(basedir, 'src/main/java/shared')
if (Files.isSymbolicLink(link.toPath())) {
Files.delete(link.toPath())
}
Files.createSymbolicLink(link.toPath(), new File(basedir, 'shared-sources/shared').toPath())

return true
22 changes: 22 additions & 0 deletions src/it/jar-follow-symlinks/shared-sources/shared/Shared.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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.
*/

package shared;

public class Shared {}
20 changes: 20 additions & 0 deletions src/it/jar-follow-symlinks/src/main/java/MyClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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.
*/

public class MyClass {}
34 changes: 34 additions & 0 deletions src/it/jar-follow-symlinks/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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.util.zip.ZipFile

File jar = new File(basedir, 'target/jar-follow-symlinks-1.0-SNAPSHOT-sources.jar')
assert jar.isFile() : "Missing sources jar $jar"

new ZipFile(jar).withCloseable { zip ->
def entry = zip.getEntry('shared/Shared.java')
assert entry != null : "shared/Shared.java is missing; entries were ${zip.entries().collect { it.name }}"

// The link was resolved, so the entry carries the target's source rather than a link path.
def text = zip.getInputStream(entry).text
assert text.contains('class Shared') : "shared/Shared.java holds $text"
}

return true
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;

Check warning on line 38 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-17-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 38 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-25-zulu 4.0.0-rc-6

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 38 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / macos-latest jdk-21-zulu 4.0.0-rc-6

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 38 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-25-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 38 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / macos-latest jdk-25-zulu 4.0.0-rc-6

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 38 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-21-zulu 4.0.0-rc-6

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 38 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / macos-latest jdk-25-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 38 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-8-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 38 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / macos-latest jdk-8-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 38 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-21-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 38 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / macos-latest jdk-21-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
Expand Down Expand Up @@ -83,6 +83,16 @@
@Parameter(property = "maven.source.useDefaultExcludes", defaultValue = "true")
private boolean useDefaultExcludes;

/**
* Whether to follow symbolic links below the source directories. When false, a symbolic link is archived as a
* link, which points nowhere once the jar is unpacked somewhere else; when true, a link is archived as the file
* or directory it points at, and a linked directory's contents are included.
*
* @since 3.5.0
*/
@Parameter(property = "maven.source.followSymlinks", defaultValue = "false")
private boolean followSymlinks;

/**
* The Maven Project Object
*/
Expand All @@ -92,7 +102,7 @@
/**
* The Jar archiver.
*/
@Component(role = Archiver.class, hint = "jar")

Check warning on line 105 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-17-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 105 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-25-zulu 4.0.0-rc-6

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 105 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / macos-latest jdk-21-zulu 4.0.0-rc-6

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 105 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-25-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 105 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / macos-latest jdk-25-zulu 4.0.0-rc-6

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 105 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-21-zulu 4.0.0-rc-6

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 105 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / macos-latest jdk-25-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 105 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-8-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 105 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / macos-latest jdk-8-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 105 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-21-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 105 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / macos-latest jdk-21-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated
private JarArchiver jarArchiver;

/**
Expand Down Expand Up @@ -155,7 +165,7 @@
/**
* Used for attaching the source jar to the project.
*/
@Component

Check warning on line 168 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-17-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 168 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-25-zulu 4.0.0-rc-6

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 168 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / macos-latest jdk-21-zulu 4.0.0-rc-6

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 168 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-25-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 168 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / macos-latest jdk-25-zulu 4.0.0-rc-6

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 168 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-21-zulu 4.0.0-rc-6

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 168 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / macos-latest jdk-25-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 168 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-8-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 168 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / macos-latest jdk-8-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 168 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / ubuntu-latest jdk-21-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated

Check warning on line 168 in src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java

View workflow job for this annotation

GitHub Actions / Verify / macos-latest jdk-21-zulu 3.10.0-rc-1

org.apache.maven.plugins.annotations.Component in org.apache.maven.plugins.annotations has been deprecated
private MavenProjectHelper projectHelper;

/**
Expand Down Expand Up @@ -444,7 +454,9 @@
throws MojoExecutionException {
try {
getLog().debug("add directory " + sourceDirectory + " to archiver");
archiver.addFileSet(DefaultFileSet.fileSet(sourceDirectory).includeExclude(pIncludes, pExcludes));
archiver.addFileSet(DefaultFileSet.fileSet(sourceDirectory)
.includeExclude(pIncludes, pExcludes)
.followingSymLinks(followSymlinks));
} catch (ArchiverException e) {
throw new MojoExecutionException("Error adding directory to source archive.", e);
}
Expand All @@ -463,8 +475,10 @@
throws MojoExecutionException {
try {
getLog().debug("add directory " + sourceDirectory + " to archiver with prefix " + prefix);
archiver.addFileSet(
DefaultFileSet.fileSet(sourceDirectory).prefixed(prefix).includeExclude(pIncludes, pExcludes));
archiver.addFileSet(DefaultFileSet.fileSet(sourceDirectory)
.prefixed(prefix)
.includeExclude(pIncludes, pExcludes)
.followingSymLinks(followSymlinks));
} catch (ArchiverException e) {
throw new MojoExecutionException("Error adding directory to source archive.", e);
}
Expand Down
Loading