elharo commented on code in PR #162:
URL: 
https://github.com/apache/maven-shade-plugin/pull/162#discussion_r1141341540


##########
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 = "<artifactId>mshade-419-api</artifactId>"
+
+String mainPomFileContent = FileUtils.fileRead( new File( basedir, 
"impl/pom.xml" ), "UTF-8" )

Review Comment:
   can we use the Apache Commons IO version instead?



##########
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 = "<artifactId>mshade-419-api</artifactId>"
+
+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

Review Comment:
   I think you can use try with resources here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to