This is an automated email from the ASF dual-hosted git repository.

sjaranowski pushed a commit to branch MASSEMBLY-967
in repository https://gitbox.apache.org/repos/asf/maven-assembly-plugin.git

commit 008562db013cd5e39de21d7395508b4fc1400462
Author: Slawomir Jaranowski <s.jaranow...@gmail.com>
AuthorDate: Sun Feb 4 15:44:01 2024 +0100

    [MASSEMBLY-967] IT for jar-with-dependencies with main class
---
 src/it/it-project-parent/pom.xml                   | 19 +++++--
 .../main-class-and-dependencies/pom.xml            | 66 ++++++++++++++++++++++
 .../src/main/java/test/App.java                    | 33 +++++++++++
 .../main-class-and-dependencies/verify.groovy      | 38 +++++++++++++
 4 files changed, 152 insertions(+), 4 deletions(-)

diff --git a/src/it/it-project-parent/pom.xml b/src/it/it-project-parent/pom.xml
index 7c588ae9..511da0d6 100644
--- a/src/it/it-project-parent/pom.xml
+++ b/src/it/it-project-parent/pom.xml
@@ -18,13 +18,24 @@ 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";>
+         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.plugin.assembly.test</groupId>
   <artifactId>it-project-parent</artifactId>
   <packaging>pom</packaging>
   <version>1</version>
 
+  <!-- define versions of dependencies used in ITs -->
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>commons-io</groupId>
+        <artifactId>commons-io</artifactId>
+        <version>@commonsIoVersion@</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
   <build>
     <pluginManagement>
       <plugins>
@@ -71,14 +82,14 @@ under the License.
       </plugins>
     </pluginManagement>
   </build>
-  
+
   <profiles>
     <profile>
       <id>testing</id>
       <activation>
         <activeByDefault>true</activeByDefault>
       </activation>
-      
+
       <repositories>
         <!--
         <repository>
@@ -115,7 +126,7 @@ under the License.
     </profile>
     <profile>
       <id>live</id>
-      
+
       <!-- just avoids the information injected by the testing profile, above. 
-->
     </profile>
   </profiles>
diff --git 
a/src/it/projects/descriptor-refs/jar-with-dependencies/main-class-and-dependencies/pom.xml
 
b/src/it/projects/descriptor-refs/jar-with-dependencies/main-class-and-dependencies/pom.xml
new file mode 100644
index 00000000..ecd2a50b
--- /dev/null
+++ 
b/src/it/projects/descriptor-refs/jar-with-dependencies/main-class-and-dependencies/pom.xml
@@ -0,0 +1,66 @@
+<?xml version='1.0'?>
+<!--
+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: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' 
xmlns='http://maven.apache.org/POM/4.0.0'>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.maven.plugin.assembly.test</groupId>
+    <artifactId>it-project-parent</artifactId>
+    <version>1</version>
+  </parent>
+
+  <artifactId>main-class-and-dependencies</artifactId>
+  <version>1</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>assembly</id>
+            <phase>package</phase>
+            <goals>
+              <goal>single</goal>
+            </goals>
+            <configuration>
+              <descriptorRefs>
+                <descriptorRef>jar-with-dependencies</descriptorRef>
+              </descriptorRefs>
+              <archive>
+                <manifest>
+                  <mainClass>test.App</mainClass>
+                </manifest>
+              </archive>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
+
diff --git 
a/src/it/projects/descriptor-refs/jar-with-dependencies/main-class-and-dependencies/src/main/java/test/App.java
 
b/src/it/projects/descriptor-refs/jar-with-dependencies/main-class-and-dependencies/src/main/java/test/App.java
new file mode 100644
index 00000000..af52385c
--- /dev/null
+++ 
b/src/it/projects/descriptor-refs/jar-with-dependencies/main-class-and-dependencies/src/main/java/test/App.java
@@ -0,0 +1,33 @@
+package test;
+
+/*
+ * 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 org.apache.commons.io.IOUtils;
+
+/**
+ * Hello world!
+ *
+ */
+public class App 
+{
+    public static void main( String[] args ) {
+        System.out.print( "Hello World!" + IOUtils.LF );
+    }
+}
diff --git 
a/src/it/projects/descriptor-refs/jar-with-dependencies/main-class-and-dependencies/verify.groovy
 
b/src/it/projects/descriptor-refs/jar-with-dependencies/main-class-and-dependencies/verify.groovy
new file mode 100644
index 00000000..13b3daab
--- /dev/null
+++ 
b/src/it/projects/descriptor-refs/jar-with-dependencies/main-class-and-dependencies/verify.groovy
@@ -0,0 +1,38 @@
+/*
+ * 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.JarEntry
+import java.util.jar.JarFile
+import java.util.jar.Attributes
+
+def expectedJarEntries = [
+        "org/apache/commons/io/IOUtils.class",
+        "test/App.class"
+]
+
+File file = new File(basedir, 
"target/main-class-and-dependencies-1-jar-with-dependencies.jar")
+assert file.isFile(): "jar file is missing or a directory."
+
+JarFile jarFile = new JarFile(file)
+expectedJarEntries.each {entryName ->
+    JarEntry jarEntry = jarFile.getJarEntry(entryName)
+    assert jarEntry != null: "missing jar entry: " + entryName
+}
+
+assert "test.App" == 
jarFile.manifest.mainAttributes.getValue(Attributes.Name.MAIN_CLASS)

Reply via email to