diff --git a/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/api/pom.xml b/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/api/pom.xml new file mode 100644 index 00000000..3fd4d0d7 --- /dev/null +++ b/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/api/pom.xml @@ -0,0 +1,33 @@ + + + + + + 4.0.0 + + org.apache.maven.its.shade.cdrp-mm + mshade-419-parent + 1.0 + + mshade-419-api + 1.0 + diff --git a/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/api/src/main/java/Api.java b/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/api/src/main/java/Api.java new file mode 100644 index 00000000..b1a0ba74 --- /dev/null +++ b/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/api/src/main/java/Api.java @@ -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. + */ + +public class Api +{ +} diff --git a/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/impl-user/pom.xml b/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/impl-user/pom.xml new file mode 100644 index 00000000..199e396a --- /dev/null +++ b/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/impl-user/pom.xml @@ -0,0 +1,55 @@ + + + + + + 4.0.0 + + org.apache.maven.its.shade.cdrp-mm + mshade-419-parent + 1.0 + + mshade-419-simple-user + 1.0 + + + + org.apache.maven.its.shade.cdrp-mm + mshade-419-impl + 1.0 + jar + + + + + diff --git a/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/impl-user/src/main/java/SimpleUser.java b/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/impl-user/src/main/java/SimpleUser.java new file mode 100644 index 00000000..8e67f173 --- /dev/null +++ b/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/impl-user/src/main/java/SimpleUser.java @@ -0,0 +1,24 @@ +/* + * 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 SimpleUser +{ + Impl impl = new Impl(); + Api api = new Impl(); +} diff --git a/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/impl/pom.xml b/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/impl/pom.xml new file mode 100644 index 00000000..2dcedc8b --- /dev/null +++ b/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/impl/pom.xml @@ -0,0 +1,60 @@ + + + + + + 4.0.0 + + org.apache.maven.its.shade.cdrp-mm + mshade-419-parent + 1.0 + + mshade-419-impl + 1.0 + + + org.apache.maven.its.shade.cdrp-mm + mshade-419-api + 1.0 + + + + + + maven-shade-plugin + @project.version@ + + + + shade + + + true + + + + + + + + + diff --git a/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/impl/src/main/java/Impl.java b/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/impl/src/main/java/Impl.java new file mode 100644 index 00000000..737fb97c --- /dev/null +++ b/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/impl/src/main/java/Impl.java @@ -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. + */ + +public class Impl extends Api +{ +} diff --git a/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/pom.xml b/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/pom.xml new file mode 100644 index 00000000..e577f89c --- /dev/null +++ b/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/pom.xml @@ -0,0 +1,49 @@ + + + + + + 4.0.0 + org.apache.maven.its.shade.cdrp-mm + mshade-419-parent + pom + 1.0 + + api + impl + impl-user + + + + + maven-jar-plugin + + + + jar + + + + + + + diff --git a/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/verify.groovy b/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/verify.groovy new file mode 100644 index 00000000..952f5a3d --- /dev/null +++ b/src/it/projects/MSHADE-419_createDependencyReducedPom_multimodule/verify.groovy @@ -0,0 +1,61 @@ +/* + * 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.jar.* +import org.codehaus.plexus.util.* + +// note that the following checks were passing even before any fix for MSHADE-419, +// since the generated poms and jars are generated correctly. +// only compilation of the impl-user module is failing because it uses the normal jar but +// without its transitive dependencies + +String jarPrefix = "impl/target/mshade-419-impl-1.0" +String jarPomPath = "META-INF/maven/org.apache.maven.its.shade.cdrp-mm/mshade-419-impl/pom.xml" +String apiDependencyString = "mshade-419-api" + +String mainPomFileContent = FileUtils.fileRead( new File( basedir, "impl/pom.xml" ), "UTF-8" ) +if ( !mainPomFileContent.contains( apiDependencyString ) ) +{ + throw new IllegalStateException( "The pom.xml should still contain the api dependency:\n" + mainPomFileContent ) +} + +String reducedPomFileContent = FileUtils.fileRead( new File( basedir, "impl/dependency-reduced-pom.xml" ), "UTF-8" ) +if ( reducedPomFileContent.contains( apiDependencyString ) ) +{ + throw new IllegalStateException( "The dependency-reduced-pom.xml should not contain the api dependency:\n" + reducedPomFileContent ) +} + +JarFile jarFile = null +try +{ + jarFile = new JarFile ( new File( basedir, jarPrefix + ".jar" ) ) + JarEntry jarEntry = jarFile.getEntry(jarPomPath ) + String pomFile = IOUtil.toString( jarFile.getInputStream( jarEntry ), "UTF-8" ) + if ( !pomFile.contains( apiDependencyString ) ) + { + throw new IllegalStateException( "The pom.xml in the normal jar should still contain the api dependency:\n" + pomFile ) + } +} +finally +{ + if ( jarFile != null ) + { + jarFile.close() + } +}