diff --git a/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/commandline/pom.xml b/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/commandline/pom.xml new file mode 100644 index 00000000..b8a469dc --- /dev/null +++ b/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/commandline/pom.xml @@ -0,0 +1,65 @@ + + + + + + 4.0.0 + + + org.apache.maven.its.shade.drp + project-parent + 1.0 + + + commandline + jar + + MSHADE-326 + + Test to see that the reduced dependencies are gone from the reactor. + + + + + org.apache.maven.its.shade.drp + library + ${project.version} + + + + + + + org.apache.maven.plugins + maven-shade-plugin + @project.version@ + + + attach-shade + package + + shade + + + + + + + diff --git a/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/commandline/src/main/java/com/example/Main.java b/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/commandline/src/main/java/com/example/Main.java new file mode 100644 index 00000000..7a754e3a --- /dev/null +++ b/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/commandline/src/main/java/com/example/Main.java @@ -0,0 +1,27 @@ +/* + * 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 com.example; + +public class Main +{ + public static void main( String[] args ) { + System.out.println( "Hello World!" + ( StringTester.isEmpty("foo") ? " is empty!" : " -- ") ); + } +} diff --git a/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/invoker.properties b/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/invoker.properties new file mode 100644 index 00000000..a644cb7e --- /dev/null +++ b/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/invoker.properties @@ -0,0 +1,18 @@ +# 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. + +invoker.goals = clean package diff --git a/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/library/pom.xml b/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/library/pom.xml new file mode 100644 index 00000000..5c5657be --- /dev/null +++ b/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/library/pom.xml @@ -0,0 +1,82 @@ + + + + + + 4.0.0 + + + org.apache.maven.its.shade.drp + project-parent + 1.0 + + + library + jar + + MSHADE-326 + + Test to see that the reduced dependencies are gone from the reactor. + + + + + org.codehaus.plexus + plexus-utils + 1.4.1 + + + + + + + org.apache.maven.plugins + maven-shade-plugin + @project.version@ + + + attach-shade + package + + shade + + + true + true + true + true + + + org.codehaus.plexus + com.example.shaded.org.codehaus.plexus + + + + + org.codehaus.plexus:plexus-utils + + + + + + + + + diff --git a/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/library/src/main/java/com/example/StringTester.java b/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/library/src/main/java/com/example/StringTester.java new file mode 100644 index 00000000..33bcb53c --- /dev/null +++ b/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/library/src/main/java/com/example/StringTester.java @@ -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. + */ + +package com.example; + +import org.codehaus.plexus.util.StringUtils; + +public class StringTester +{ + public static boolean isEmpty( String input ) { + return StringUtils.isEmpty( input ); + } +} diff --git a/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/library/src/test/java/com/example/TestStringTester.java b/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/library/src/test/java/com/example/TestStringTester.java new file mode 100644 index 00000000..22f19461 --- /dev/null +++ b/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/library/src/test/java/com/example/TestStringTester.java @@ -0,0 +1,36 @@ +/* + * 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 com.example; + +import org.junit.Test; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +public class TestStringTester +{ + @Test + public void runTest() + { + assertTrue(StringTester.isEmpty("")); + assertFalse(StringTester.isEmpty("FooBar")); + } + +} diff --git a/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/pom.xml b/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/pom.xml new file mode 100644 index 00000000..8a192fc2 --- /dev/null +++ b/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/pom.xml @@ -0,0 +1,65 @@ + + + + + + 4.0.0 + + + org.apache.maven.plugins.shade.its + shade-parent + 1.0 + ../setup-parent + + + org.apache.maven.its.shade.drp + project-parent + pom + + MSHADE-326 + + Test to see that the reduced dependencies are gone from the reactor. + + + + + junit + junit + 4.12 + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + + + + + library + commandline + + + diff --git a/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/verify.bsh b/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/verify.bsh new file mode 100644 index 00000000..7010365b --- /dev/null +++ b/src/it/projects/MSHADE-326-Hide-dependencies-from-reactor/verify.bsh @@ -0,0 +1,113 @@ +/* + * 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.io.*; +import java.util.jar.*; +import java.util.Arrays; +import org.codehaus.plexus.util.*; + +String[] libraryWanted = +{ + "com/example/StringTester.class", + "com/example/shaded/org/codehaus/plexus/util/StringUtils.class", +}; + +String[] libraryUnwanted = +{ + "org/codehaus/plexus/util/StringUtils.class", +}; + +JarFile libraryJarFile = null; +try +{ + libraryJarFile = new JarFile( new File( basedir, "library/target/library-1.0.jar" ) ); + + for ( String path : libraryWanted ) + { + if ( libraryJarFile.getEntry( path ) == null ) + { + throw new IllegalStateException( "Library: wanted path is missing: " + path ); + } + } + + for ( String path : libraryUnwanted ) + { + if ( libraryJarFile.getEntry( path ) != null ) + { + throw new IllegalStateException( "Library: unwanted path is present: " + path ); + } + } + + JarEntry jarEntry = libraryJarFile.getEntry( "META-INF/maven/org.apache.maven.its.shade.drp/library/pom.xml" ); + String pomFile = IOUtil.toString( libraryJarFile.getInputStream( jarEntry ), "UTF-8" ); + + if ( pomFile.contains( "org.codehaus.plexus" ) ) { + throw new IllegalStateException( "The pom.xml still contains a reference to the org.codehaus.plexus dependency"); + } +} +finally +{ + if ( libraryJarFile != null ) { + libraryJarFile.close(); + } +} + + +// ===================== + +String[] commandlineWanted = +{ + "com/example/Main.class", + "com/example/StringTester.class", + "com/example/shaded/org/codehaus/plexus/util/StringUtils.class", +}; + +String[] commandlineUnwanted = +{ + "org/codehaus/plexus/util/Base64.class", + "org/codehaus/plexus/util/StringUtils.class", +}; + +JarFile commandlineJarFile = null; +try +{ + commandlineJarFile = new JarFile( new File( basedir, "commandline/target/commandline-1.0.jar" ) ); + + for ( String path : commandlineWanted ) + { + if ( commandlineJarFile.getEntry( path ) == null ) + { + throw new IllegalStateException( "Commandline: wanted path is missing: " + path ); + } + } + + for ( String path : commandlineUnwanted ) + { + if ( commandlineJarFile.getEntry( path ) != null ) + { + throw new IllegalStateException( "Commandline: unwanted path is present: " + path ); + } + } +} +finally +{ + if ( commandlineJarFile != null ) { + commandlineJarFile.close(); + } +} diff --git a/src/it/projects/MSHADE-340_shadedTestJarArtifactAttached/pom.xml b/src/it/projects/MSHADE-340_shadedTestJarArtifactAttached/pom.xml index 6b2fc156..34c352a5 100644 --- a/src/it/projects/MSHADE-340_shadedTestJarArtifactAttached/pom.xml +++ b/src/it/projects/MSHADE-340_shadedTestJarArtifactAttached/pom.xml @@ -92,6 +92,7 @@ under the License. maven-jar-plugin + default-jar jar test-jar