| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,58 @@ | |||
| 1 | + <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | + <!-- | ||
| 3 | + Licensed to the Apache Software Foundation (ASF) under one | ||
| 4 | + or more contributor license agreements. See the NOTICE file | ||
| 5 | + distributed with this work for additional information | ||
| 6 | + regarding copyright ownership. The ASF licenses this file | ||
| 7 | + to you under the Apache License, Version 2.0 (the | ||
| 8 | + "License"); you may not use this file except in compliance | ||
| 9 | + with the License. You may obtain a copy of the License at | ||
| 10 | + | ||
| 11 | + http://www.apache.org/licenses/LICENSE-2.0 | ||
| 12 | + | ||
| 13 | + Unless required by applicable law or agreed to in writing, | ||
| 14 | + software distributed under the License is distributed on an | ||
| 15 | + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| 16 | + KIND, either express or implied. See the License for the | ||
| 17 | + specific language governing permissions and limitations | ||
| 18 | + under the License. | ||
| 19 | + --> | ||
| 20 | + <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 21 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 22 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
| 23 | + <modelVersion>4.0.0</modelVersion> | ||
| 24 | + | ||
| 25 | + <groupId>org.apache.maven.plugins</groupId> | ||
| 26 | + <artifactId>mjar-296-exclude-default</artifactId> | ||
| 27 | + <name>mjar-296-suppress-default-excludes</name> | ||
| 28 | + <description>Verifies that the resulting jar not includes files excluded by default</description> | ||
| 29 | + <packaging>jar</packaging> | ||
| 30 | + <version>1.0-SNAPSHOT</version> | ||
| 31 | + | ||
| 32 | + <properties> | ||
| 33 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| 34 | + <project.build.outputTimestamp>2023-11-19T13:25:58Z</project.build.outputTimestamp> | ||
| 35 | + </properties> | ||
| 36 | + | ||
| 37 | + <build> | ||
| 38 | + <pluginManagement> | ||
| 39 | + <plugins> | ||
| 40 | + <plugin> | ||
| 41 | + <groupId>org.apache.maven.plugins</groupId> | ||
| 42 | + <artifactId>maven-resources-plugin</artifactId> | ||
| 43 | + <version>@version.maven-resources-plugin@</version> | ||
| 44 | + <configuration> | ||
| 45 | + <addDefaultExcludes>false</addDefaultExcludes> | ||
| 46 | + </configuration> | ||
| 47 | + </plugin> | ||
| 48 | + </plugins> | ||
| 49 | + </pluginManagement> | ||
| 50 | + <plugins> | ||
| 51 | + <plugin> | ||
| 52 | + <groupId>org.apache.maven.plugins</groupId> | ||
| 53 | + <artifactId>maven-jar-plugin</artifactId> | ||
| 54 | + <version>@project.version@</version> | ||
| 55 | + </plugin> | ||
| 56 | + </plugins> | ||
| 57 | + </build> | ||
| 58 | + </project> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,29 @@ | |||
| 1 | + import java.nio.file.Files | ||
| 2 | + import java.nio.file.Paths | ||
| 3 | + | ||
| 4 | + /* | ||
| 5 | + * Licensed to the Apache Software Foundation (ASF) under one | ||
| 6 | + * or more contributor license agreements. See the NOTICE file | ||
| 7 | + * distributed with this work for additional information | ||
| 8 | + * regarding copyright ownership. The ASF licenses this file | ||
| 9 | + * to you under the Apache License, Version 2.0 (the | ||
| 10 | + * "License"); you may not use this file except in compliance | ||
| 11 | + * with the License. You may obtain a copy of the License at | ||
| 12 | + * | ||
| 13 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 14 | + * | ||
| 15 | + * Unless required by applicable law or agreed to in writing, | ||
| 16 | + * software distributed under the License is distributed on an | ||
| 17 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| 18 | + * KIND, either express or implied. See the License for the | ||
| 19 | + * specific language governing permissions and limitations | ||
| 20 | + * under the License. | ||
| 21 | + */ | ||
| 22 | + | ||
| 23 | + // excluded files are not copied by m-invoker-p - so we need create one | ||
| 24 | + | ||
| 25 | + def resDir = basedir.toPath().resolve("src/main/resources") | ||
| 26 | + Files.createDirectories(resDir) | ||
| 27 | + Files.createFile(resDir.resolve(".cvsignore")) | ||
| 28 | + | ||
| 29 | + return true | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,31 @@ | |||
| 1 | + | ||
| 2 | + /* | ||
| 3 | + * Licensed to the Apache Software Foundation (ASF) under one | ||
| 4 | + * or more contributor license agreements. See the NOTICE file | ||
| 5 | + * distributed with this work for additional information | ||
| 6 | + * regarding copyright ownership. The ASF licenses this file | ||
| 7 | + * to you under the Apache License, Version 2.0 (the | ||
| 8 | + * "License"); you may not use this file except in compliance | ||
| 9 | + * with the License. You may obtain a copy of the License at | ||
| 10 | + * | ||
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 12 | + * | ||
| 13 | + * Unless required by applicable law or agreed to in writing, | ||
| 14 | + * software distributed under the License is distributed on an | ||
| 15 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| 16 | + * KIND, either express or implied. See the License for the | ||
| 17 | + * specific language governing permissions and limitations | ||
| 18 | + * under the License. | ||
| 19 | + */ | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * Hello world! | ||
| 23 | + * | ||
| 24 | + */ | ||
| 25 | + public class Foo | ||
| 26 | + { | ||
| 27 | + public static void main( String[] args ) | ||
| 28 | + { | ||
| 29 | + System.out.println( "Hello World!" ); | ||
| 30 | + } | ||
| 31 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,31 @@ | |||
| 1 | + /* | ||
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one | ||
| 3 | + * or more contributor license agreements. See the NOTICE file | ||
| 4 | + * distributed with this work for additional information | ||
| 5 | + * regarding copyright ownership. The ASF licenses this file | ||
| 6 | + * to you under the Apache License, Version 2.0 (the | ||
| 7 | + * "License"); you may not use this file except in compliance | ||
| 8 | + * with the License. You may obtain a copy of the License at | ||
| 9 | + * | ||
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 11 | + * | ||
| 12 | + * Unless required by applicable law or agreed to in writing, | ||
| 13 | + * software distributed under the License is distributed on an | ||
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| 15 | + * KIND, either express or implied. See the License for the | ||
| 16 | + * specific language governing permissions and limitations | ||
| 17 | + * under the License. | ||
| 18 | + */ | ||
| 19 | + | ||
| 20 | + import java.util.jar.*; | ||
| 21 | + | ||
| 22 | + def target = new File(basedir, "target") | ||
| 23 | + | ||
| 24 | + def cvsignore = new File(target, "classes/.cvsignore") | ||
| 25 | + assert cvsignore.exists() | ||
| 26 | + | ||
| 27 | + def artifact = new File(target, "mjar-296-exclude-default-1.0-SNAPSHOT.jar") | ||
| 28 | + assert artifact.exists() | ||
| 29 | + | ||
| 30 | + def jar = new JarFile(artifact) | ||
| 31 | + assert ".cvsignore" !in jar.entries()*.name | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,61 @@ | |||
| 1 | + <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | + <!-- | ||
| 3 | + Licensed to the Apache Software Foundation (ASF) under one | ||
| 4 | + or more contributor license agreements. See the NOTICE file | ||
| 5 | + distributed with this work for additional information | ||
| 6 | + regarding copyright ownership. The ASF licenses this file | ||
| 7 | + to you under the Apache License, Version 2.0 (the | ||
| 8 | + "License"); you may not use this file except in compliance | ||
| 9 | + with the License. You may obtain a copy of the License at | ||
| 10 | + | ||
| 11 | + http://www.apache.org/licenses/LICENSE-2.0 | ||
| 12 | + | ||
| 13 | + Unless required by applicable law or agreed to in writing, | ||
| 14 | + software distributed under the License is distributed on an | ||
| 15 | + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| 16 | + KIND, either express or implied. See the License for the | ||
| 17 | + specific language governing permissions and limitations | ||
| 18 | + under the License. | ||
| 19 | + --> | ||
| 20 | + <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 21 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 22 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
| 23 | + <modelVersion>4.0.0</modelVersion> | ||
| 24 | + | ||
| 25 | + <groupId>org.apache.maven.plugins</groupId> | ||
| 26 | + <artifactId>mjar-296-suppress-default-excludes</artifactId> | ||
| 27 | + <name>mjar-296-suppress-default-excludes</name> | ||
| 28 | + <description>Verifies that the resulting jar includes files excluded by default</description> | ||
| 29 | + <packaging>jar</packaging> | ||
| 30 | + <version>1.0-SNAPSHOT</version> | ||
| 31 | + | ||
| 32 | + <properties> | ||
| 33 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| 34 | + <project.build.outputTimestamp>2023-11-19T13:25:58Z</project.build.outputTimestamp> | ||
| 35 | + </properties> | ||
| 36 | + | ||
| 37 | + <build> | ||
| 38 | + <pluginManagement> | ||
| 39 | + <plugins> | ||
| 40 | + <plugin> | ||
| 41 | + <groupId>org.apache.maven.plugins</groupId> | ||
| 42 | + <artifactId>maven-resources-plugin</artifactId> | ||
| 43 | + <version>@version.maven-resources-plugin@</version> | ||
| 44 | + <configuration> | ||
| 45 | + <addDefaultExcludes>false</addDefaultExcludes> | ||
| 46 | + </configuration> | ||
| 47 | + </plugin> | ||
| 48 | + </plugins> | ||
| 49 | + </pluginManagement> | ||
| 50 | + <plugins> | ||
| 51 | + <plugin> | ||
| 52 | + <groupId>org.apache.maven.plugins</groupId> | ||
| 53 | + <artifactId>maven-jar-plugin</artifactId> | ||
| 54 | + <version>@project.version@</version> | ||
| 55 | + <configuration> | ||
| 56 | + <addDefaultExcludes>false</addDefaultExcludes> | ||
| 57 | + </configuration> | ||
| 58 | + </plugin> | ||
| 59 | + </plugins> | ||
| 60 | + </build> | ||
| 61 | + </project> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,29 @@ | |||
| 1 | + import java.nio.file.Files | ||
| 2 | + import java.nio.file.Path | ||
| 3 | + import java.nio.file.Paths | ||
| 4 | + | ||
| 5 | + /* | ||
| 6 | + * Licensed to the Apache Software Foundation (ASF) under one | ||
| 7 | + * or more contributor license agreements. See the NOTICE file | ||
| 8 | + * distributed with this work for additional information | ||
| 9 | + * regarding copyright ownership. The ASF licenses this file | ||
| 10 | + * to you under the Apache License, Version 2.0 (the | ||
| 11 | + * "License"); you may not use this file except in compliance | ||
| 12 | + * with the License. You may obtain a copy of the License at | ||
| 13 | + * | ||
| 14 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 15 | + * | ||
| 16 | + * Unless required by applicable law or agreed to in writing, | ||
| 17 | + * software distributed under the License is distributed on an | ||
| 18 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| 19 | + * KIND, either express or implied. See the License for the | ||
| 20 | + * specific language governing permissions and limitations | ||
| 21 | + * under the License. | ||
| 22 | + */ | ||
| 23 | + | ||
| 24 | + // excluded files are not copied by m-invoker-p - so we need create one | ||
| 25 | + def resDir = basedir.toPath().resolve("src/main/resources") | ||
| 26 | + Files.createDirectories(resDir) | ||
| 27 | + Files.createFile(resDir.resolve(".cvsignore")) | ||
| 28 | + | ||
| 29 | + return true | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,31 @@ | |||
| 1 | + | ||
| 2 | + /* | ||
| 3 | + * Licensed to the Apache Software Foundation (ASF) under one | ||
| 4 | + * or more contributor license agreements. See the NOTICE file | ||
| 5 | + * distributed with this work for additional information | ||
| 6 | + * regarding copyright ownership. The ASF licenses this file | ||
| 7 | + * to you under the Apache License, Version 2.0 (the | ||
| 8 | + * "License"); you may not use this file except in compliance | ||
| 9 | + * with the License. You may obtain a copy of the License at | ||
| 10 | + * | ||
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 12 | + * | ||
| 13 | + * Unless required by applicable law or agreed to in writing, | ||
| 14 | + * software distributed under the License is distributed on an | ||
| 15 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| 16 | + * KIND, either express or implied. See the License for the | ||
| 17 | + * specific language governing permissions and limitations | ||
| 18 | + * under the License. | ||
| 19 | + */ | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * Hello world! | ||
| 23 | + * | ||
| 24 | + */ | ||
| 25 | + public class Foo | ||
| 26 | + { | ||
| 27 | + public static void main( String[] args ) | ||
| 28 | + { | ||
| 29 | + System.out.println( "Hello World!" ); | ||
| 30 | + } | ||
| 31 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,33 @@ | |||
| 1 | + /* | ||
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one | ||
| 3 | + * or more contributor license agreements. See the NOTICE file | ||
| 4 | + * distributed with this work for additional information | ||
| 5 | + * regarding copyright ownership. The ASF licenses this file | ||
| 6 | + * to you under the Apache License, Version 2.0 (the | ||
| 7 | + * "License"); you may not use this file except in compliance | ||
| 8 | + * with the License. You may obtain a copy of the License at | ||
| 9 | + * | ||
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 11 | + * | ||
| 12 | + * Unless required by applicable law or agreed to in writing, | ||
| 13 | + * software distributed under the License is distributed on an | ||
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| 15 | + * KIND, either express or implied. See the License for the | ||
| 16 | + * specific language governing permissions and limitations | ||
| 17 | + * under the License. | ||
| 18 | + */ | ||
| 19 | + | ||
| 20 | + import java.util.jar.*; | ||
| 21 | + | ||
| 22 | + def target = new File(basedir, "target") | ||
| 23 | + | ||
| 24 | + def cvsignore = new File(target, "classes/.cvsignore") | ||
| 25 | + assert cvsignore.exists() | ||
| 26 | + | ||
| 27 | + def artifact = new File(target, "mjar-296-suppress-default-excludes-1.0-SNAPSHOT.jar") | ||
| 28 | + assert artifact.exists() | ||
| 29 | + | ||
| 30 | + def jar = new JarFile(artifact) | ||
| 31 | + assert ".cvsignore" in jar.entries()*.name | ||
| 32 | + | ||
| 33 | + | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,6 +38,7 @@ | |||
| 38 | 38 | import org.apache.maven.toolchain.ToolchainManager; | |
| 39 | 39 | import org.codehaus.plexus.archiver.Archiver; | |
| 40 | 40 | import org.codehaus.plexus.archiver.jar.JarArchiver; | |
| 41 | + import org.codehaus.plexus.archiver.util.DefaultFileSet; | ||
| 41 | 42 | ||
| 42 | 43 | /** | |
| 43 | 44 | * Base class for creating a jar from project classes. | |
@@ -169,6 +170,38 @@ public abstract class AbstractJarMojo extends AbstractMojo { | |||
| 169 | 170 | @Parameter(property = "maven.jar.detectMultiReleaseJar", defaultValue = "true") | |
| 170 | 171 | private boolean detectMultiReleaseJar; | |
| 171 | 172 | ||
| 173 | + /** | ||
| 174 | + * If set to {@code false}, the files and directories that by default are excluded from the resulting archive, | ||
| 175 | + * like {@code .gitignore}, {@code .cvsignore} etc. will be included. | ||
| 176 | + * This means all files like the following will be included. | ||
| 177 | + * <ul> | ||
| 178 | + * <li>Misc: **/*~, **/#*#, **/.#*, **/%*%, **/._*</li> | ||
| 179 | + * <li>CVS: **/CVS, **/CVS/**, **/.cvsignore</li> | ||
| 180 | + * <li>RCS: **/RCS, **/RCS/**</li> | ||
| 181 | + * <li>SCCS: **/SCCS, **/SCCS/**</li> | ||
| 182 | + * <li>VSSercer: **/vssver.scc</li> | ||
| 183 | + * <li>MKS: **/project.pj</li> | ||
| 184 | + * <li>SVN: **/.svn, **/.svn/**</li> | ||
| 185 | + * <li>GNU: **/.arch-ids, **/.arch-ids/**</li> | ||
| 186 | + * <li>Bazaar: **/.bzr, **/.bzr/**</li> | ||
| 187 | + * <li>SurroundSCM: **/.MySCMServerInfo</li> | ||
| 188 | + * <li>Mac: **/.DS_Store</li> | ||
| 189 | + * <li>Serena Dimension: **/.metadata, **/.metadata/**</li> | ||
| 190 | + * <li>Mercurial: **/.hg, **/.hg/**</li> | ||
| 191 | + * <li>Git: **/.git, **/.git/**</li> | ||
| 192 | + * <li>Bitkeeper: **/BitKeeper, **/BitKeeper/**, **/ChangeSet, | ||
| 193 | + * **/ChangeSet/**</li> | ||
| 194 | + * <li>Darcs: **/_darcs, **/_darcs/**, **/.darcsrepo, | ||
| 195 | + * **/.darcsrepo/****/-darcs-backup*, **/.darcs-temp-mail | ||
| 196 | + * </ul> | ||
| 197 | + * | ||
| 198 | + * @see <a href="https://codehaus-plexus.github.io/plexus-utils/apidocs/org/codehaus/plexus/util/AbstractScanner.html#DEFAULTEXCLUDES">DEFAULTEXCLUDES</a> | ||
| 199 | + * | ||
| 200 | + * @since 3.4.0 | ||
| 201 | + */ | ||
| 202 | + @Parameter(defaultValue = "true") | ||
| 203 | + private boolean addDefaultExcludes; | ||
| 204 | + | ||
| 172 | 205 | /** | |
| 173 | 206 | * Return the specific output directory to serve as the root for the archive. | |
| 174 | 207 | * @return get classes directory. | |
@@ -281,7 +314,7 @@ public File createArchive() throws MojoExecutionException { | |||
| 281 | 314 | getLog().warn("JAR will be empty - no content was marked for inclusion!"); | |
| 282 | 315 | } | |
| 283 | 316 | } else { | |
| 284 | - archiver.getArchiver().addDirectory(contentDirectory, getIncludes(), getExcludes()); | ||
| 317 | + archiver.getArchiver().addFileSet(getFileSet(contentDirectory)); | ||
| 285 | 318 | } | |
| 286 | 319 | ||
| 287 | 320 | archiver.createArchive(session, project, archive); | |
@@ -353,4 +386,14 @@ private String[] getExcludes() { | |||
| 353 | 386 | } | |
| 354 | 387 | return DEFAULT_EXCLUDES; | |
| 355 | 388 | } | |
| 389 | + | ||
| 390 | + private org.codehaus.plexus.archiver.FileSet getFileSet(File contentDirectory) { | ||
| 391 | + DefaultFileSet fileSet = DefaultFileSet.fileSet(contentDirectory) | ||
| 392 | + .prefixed("") | ||
| 393 | + .includeExclude(getIncludes(), getExcludes()) | ||
| 394 | + .includeEmptyDirs(true); | ||
| 395 | + | ||
| 396 | + fileSet.setUsingDefaultExcludes(addDefaultExcludes); | ||
| 397 | + return fileSet; | ||
| 398 | + } | ||
| 356 | 399 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments