You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2019/04/13 09:37:24 UTC
[maven-shade-plugin] branch MSHADE-313 created (now e4321c5)
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a change to branch MSHADE-313
in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git.
at e4321c5 [MSHADE-313] Rename IT Remove unused import Adjust logging (to keep info as clean as possible) Clean up pom
This branch includes the following new commits:
new cfe70aa Merge branch 'master' of https://gitbox.apache.org/repos/asf/maven-shade-plugin
new 4f8bcef Keep Services
new c22949b Keeping services always
new 2e8b926 Fixed: Failed in serveral cases
new d352a22 testing service description file syntax
new 7cdf37d improved comprehensibility
new b896388 workaround: RAT tries to check compiler plugin's log
new 78ca1f3 Only keep actually consumed services
new 783b2ac deep scan for services loading services
new 0b453ed IT checks for existence of service descriptors
new e4321c5 [MSHADE-313] Rename IT Remove unused import Adjust logging (to keep info as clean as possible) Clean up pom
The 11 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[maven-shade-plugin] 04/11: Fixed: Failed in serveral cases
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MSHADE-313
in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git
commit 2e8b926a37b945fb103b425dbf32f5f9699d4b9c
Author: Markus KARG <ma...@headcrashing.eu>
AuthorDate: Tue Apr 2 07:58:27 2019 +0200
Fixed: Failed in serveral cases
---
.../maven/plugins/shade/filter/MinijarFilter.java | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java b/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
index cab8861..8a74ee4 100644
--- a/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
+++ b/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
@@ -28,6 +28,8 @@ import org.vafer.jdependency.Clazz;
import org.vafer.jdependency.Clazzpath;
import org.vafer.jdependency.ClazzpathUnit;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -138,13 +140,19 @@ public class MinijarFilter
}
try ( final BufferedReader bufferedReader =
- new BufferedReader( new InputStreamReader( jar.getInputStream( jarEntry ) ) ) )
+ new BufferedReader( new InputStreamReader( jar.getInputStream( jarEntry ), UTF_8 ) ) )
{
for ( String className = bufferedReader.readLine(); className != null;
className = bufferedReader.readLine() )
{
- log.info( className + " was not removed because it is a service" );
- removeClass( cp , className );
+ className = className.split( "#", 2 )[0].trim();
+ if ( className.isEmpty() )
+ {
+ continue;
+ }
+
+ log.info( className + " was not removed because it is a service" );
+ removeClass( cp, className );
}
}
catch ( final IOException e )
@@ -168,6 +176,11 @@ public class MinijarFilter
private void removeClass( final Clazzpath clazzPath, final String className )
{
final Clazz clazz = clazzPath.getClazz( className );
+ if ( clazz == null )
+ {
+ return;
+ }
+
removable.remove( clazz );
removable.removeAll( clazz.getTransitiveDependencies() );
}
[maven-shade-plugin] 06/11: improved comprehensibility
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MSHADE-313
in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git
commit 7cdf37daabb40c70d7bbd925074c78441a1bc121
Author: Markus KARG <ma...@headcrashing.eu>
AuthorDate: Wed Apr 3 22:40:32 2019 +0200
improved comprehensibility
---
.../java/org/apache/maven/plugins/shade/filter/MinijarFilter.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java b/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
index 8a74ee4..528caa8 100644
--- a/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
+++ b/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
@@ -142,10 +142,10 @@ public class MinijarFilter
try ( final BufferedReader bufferedReader =
new BufferedReader( new InputStreamReader( jar.getInputStream( jarEntry ), UTF_8 ) ) )
{
- for ( String className = bufferedReader.readLine(); className != null;
- className = bufferedReader.readLine() )
+ for ( String line = bufferedReader.readLine(); line != null;
+ line = bufferedReader.readLine() )
{
- className = className.split( "#", 2 )[0].trim();
+ final String className = line.split( "#", 2 )[0].trim();
if ( className.isEmpty() )
{
continue;
[maven-shade-plugin] 07/11: workaround: RAT tries to check compiler
plugin's log
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MSHADE-313
in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git
commit b896388421f84ad5ca81164e5b17ed474ee3acfa
Author: Markus KARG <ma...@headcrashing.eu>
AuthorDate: Wed Apr 3 22:43:19 2019 +0200
workaround: RAT tries to check compiler plugin's log
---
pom.xml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/pom.xml b/pom.xml
index 84644cd..a960b8a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -210,6 +210,8 @@
<exclude>src/it/MSHADE-182/src/main/resources/META-INF/services/relocateme.Service</exclude>
<exclude>src/it/MSHADE-182/target/classes/META-INF/services/relocateme.Service</exclude>
<exclude>src/it/MSHADE-182/build.log</exclude>
+ <exclude>src/it/MSHADE-313/service/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst</exclude>
+ <exclude>src/it/MSHADE-313/service/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst</exclude>
</excludes>
</configuration>
</plugin>
[maven-shade-plugin] 01/11: Merge branch 'master' of
https://gitbox.apache.org/repos/asf/maven-shade-plugin
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MSHADE-313
in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git
commit cfe70aaf35cd91b5b32057e2a46288577e7f0d46
Merge: ee481d6 52eed09
Author: rfscholte <rf...@apache.org>
AuthorDate: Tue Apr 2 19:36:51 2019 +0200
Merge branch 'master' of https://gitbox.apache.org/repos/asf/maven-shade-plugin
pom.xml | 3 ++
.../resource/ServicesResourceTransformer.java | 14 -------
.../resource/ServiceResourceTransformerTest.java | 44 ++++++++++++++++++++++
3 files changed, 47 insertions(+), 14 deletions(-)
[maven-shade-plugin] 09/11: deep scan for services loading services
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MSHADE-313
in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git
commit 783b2ac5f4ca94798329d55571c82b65e90759de
Author: Markus KARG <ma...@headcrashing.eu>
AuthorDate: Sun Apr 7 21:35:58 2019 +0000
deep scan for services loading services
---
.../{used-service => dependency-service}/pom.xml | 2 +-
.../src/main/java/DependencyReferencedClass.java} | 6 +-
.../src/main/java/DependencyServiceClass.java} | 7 +-
.../src/main/java/DependencyServiceInterface.java} | 6 +-
.../main/java/DependencyUnreferencedClass.java} | 6 +-
.../META-INF/services/DependencyServiceInterface | 20 +++++
src/it/MSHADE-313/pom.xml | 1 +
src/it/MSHADE-313/used-service/pom.xml | 8 ++
.../src/main/java/SomeReferencedClass.java | 9 +-
src/it/MSHADE-313/verify.bsh | 8 +-
.../maven/plugins/shade/filter/MinijarFilter.java | 100 +++++++++++----------
11 files changed, 110 insertions(+), 63 deletions(-)
diff --git a/src/it/MSHADE-313/used-service/pom.xml b/src/it/MSHADE-313/dependency-service/pom.xml
similarity index 95%
copy from src/it/MSHADE-313/used-service/pom.xml
copy to src/it/MSHADE-313/dependency-service/pom.xml
index fe4edc0..9c589d5 100644
--- a/src/it/MSHADE-313/used-service/pom.xml
+++ b/src/it/MSHADE-313/dependency-service/pom.xml
@@ -23,6 +23,6 @@ under the License.
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.shade.mj</groupId>
- <artifactId>used-service</artifactId>
+ <artifactId>dependency-service</artifactId>
<version>1.0</version>
</project>
diff --git a/src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java b/src/it/MSHADE-313/dependency-service/src/main/java/DependencyReferencedClass.java
similarity index 94%
copy from src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java
copy to src/it/MSHADE-313/dependency-service/src/main/java/DependencyReferencedClass.java
index afc0f5f..4c0bc26 100644
--- a/src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java
+++ b/src/it/MSHADE-313/dependency-service/src/main/java/DependencyReferencedClass.java
@@ -6,9 +6,9 @@
* 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
@@ -17,6 +17,6 @@
* under the License.
*/
-public class SomeReferencedClass
+public class DependencyReferencedClass
{
}
diff --git a/src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java b/src/it/MSHADE-313/dependency-service/src/main/java/DependencyServiceClass.java
similarity index 84%
copy from src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java
copy to src/it/MSHADE-313/dependency-service/src/main/java/DependencyServiceClass.java
index afc0f5f..8820be7 100644
--- a/src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java
+++ b/src/it/MSHADE-313/dependency-service/src/main/java/DependencyServiceClass.java
@@ -6,9 +6,9 @@
* 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
@@ -17,6 +17,7 @@
* under the License.
*/
-public class SomeReferencedClass
+public class DependencyServiceClass implements DependencyServiceInterface
{
+ private static DependencyReferencedClass anEssentialDependency;
}
diff --git a/src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java b/src/it/MSHADE-313/dependency-service/src/main/java/DependencyServiceInterface.java
similarity index 94%
copy from src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java
copy to src/it/MSHADE-313/dependency-service/src/main/java/DependencyServiceInterface.java
index afc0f5f..b32026a 100644
--- a/src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java
+++ b/src/it/MSHADE-313/dependency-service/src/main/java/DependencyServiceInterface.java
@@ -6,9 +6,9 @@
* 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
@@ -17,6 +17,6 @@
* under the License.
*/
-public class SomeReferencedClass
+public interface DependencyServiceInterface
{
}
diff --git a/src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java b/src/it/MSHADE-313/dependency-service/src/main/java/DependencyUnreferencedClass.java
similarity index 94%
copy from src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java
copy to src/it/MSHADE-313/dependency-service/src/main/java/DependencyUnreferencedClass.java
index afc0f5f..20d838c 100644
--- a/src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java
+++ b/src/it/MSHADE-313/dependency-service/src/main/java/DependencyUnreferencedClass.java
@@ -6,9 +6,9 @@
* 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
@@ -17,6 +17,6 @@
* under the License.
*/
-public class SomeReferencedClass
+public class DependencyUnreferencedClass
{
}
diff --git a/src/it/MSHADE-313/dependency-service/src/main/resources/META-INF/services/DependencyServiceInterface b/src/it/MSHADE-313/dependency-service/src/main/resources/META-INF/services/DependencyServiceInterface
new file mode 100644
index 0000000..2b68806
--- /dev/null
+++ b/src/it/MSHADE-313/dependency-service/src/main/resources/META-INF/services/DependencyServiceInterface
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+ DependencyServiceClass # Please do not remove comments or whitespace; they are part of the IT test.
+
diff --git a/src/it/MSHADE-313/pom.xml b/src/it/MSHADE-313/pom.xml
index 7907136..543e162 100644
--- a/src/it/MSHADE-313/pom.xml
+++ b/src/it/MSHADE-313/pom.xml
@@ -35,6 +35,7 @@ under the License.
<modules>
<module>unused-service</module>
<module>used-service</module>
+ <module>dependency-service</module>
<module>test</module>
</modules>
</project>
diff --git a/src/it/MSHADE-313/used-service/pom.xml b/src/it/MSHADE-313/used-service/pom.xml
index fe4edc0..342cf2d 100644
--- a/src/it/MSHADE-313/used-service/pom.xml
+++ b/src/it/MSHADE-313/used-service/pom.xml
@@ -25,4 +25,12 @@ under the License.
<groupId>org.apache.maven.its.shade.mj</groupId>
<artifactId>used-service</artifactId>
<version>1.0</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.its.shade.mj</groupId>
+ <artifactId>dependency-service</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
</project>
diff --git a/src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java b/src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java
index afc0f5f..6430d7f 100644
--- a/src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java
+++ b/src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java
@@ -6,9 +6,9 @@
* 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
@@ -17,6 +17,11 @@
* under the License.
*/
+import java.util.ServiceLoader;
+
public class SomeReferencedClass
{
+ {
+ ServiceLoader.load( DependencyServiceInterface.class );
+ }
}
diff --git a/src/it/MSHADE-313/verify.bsh b/src/it/MSHADE-313/verify.bsh
index cf79b16..38014a8 100644
--- a/src/it/MSHADE-313/verify.bsh
+++ b/src/it/MSHADE-313/verify.bsh
@@ -24,14 +24,18 @@ String[] wanted =
"Main.class",
"SomeServiceInterface.class",
"SomeServiceClass.class",
- "SomeReferencedClass.class"
+ "SomeReferencedClass.class",
+ "DependencyServiceInterface.class",
+ "DependencyServiceClass.class",
+ "DependencyReferencedClass.class"
};
String[] unwanted =
{
"UnusedServiceInterface.class",
"UnusedServiceClass.class",
- "SomeUnreferencedClass.class"
+ "SomeUnreferencedClass.class",
+ "DependencyUnreferencedClass.class"
};
JarFile jarFile = new JarFile( new File( basedir, "test/target/test-1.0.jar" ) );
diff --git a/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java b/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
index e04355e..e0a8e85 100644
--- a/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
+++ b/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
@@ -125,71 +125,79 @@ public class MinijarFilter
private void removeServices( final MavenProject project, final Clazzpath cp )
{
- final Set<Clazz> neededClasses = cp.getClazzes();
- neededClasses.removeAll( removable );
- try
+ boolean repeatScan;
+ do
{
- for ( final String fileName : project.getRuntimeClasspathElements() )
+ repeatScan = false;
+ final Set<Clazz> neededClasses = cp.getClazzes();
+ neededClasses.removeAll( removable );
+ try
{
- try ( final JarFile jar = new JarFile( fileName ) )
+ for ( final String fileName : project.getRuntimeClasspathElements() )
{
- for ( final Enumeration<JarEntry> entries = jar.entries(); entries.hasMoreElements(); )
+ try ( final JarFile jar = new JarFile( fileName ) )
{
- final JarEntry jarEntry = entries.nextElement();
- if ( jarEntry.isDirectory() || !jarEntry.getName().startsWith( "META-INF/services/" ) )
+ for ( final Enumeration<JarEntry> entries = jar.entries(); entries.hasMoreElements(); )
{
- continue;
- }
+ final JarEntry jarEntry = entries.nextElement();
+ if ( jarEntry.isDirectory() || !jarEntry.getName().startsWith( "META-INF/services/" ) )
+ {
+ continue;
+ }
- final String serviceClassName = jarEntry.getName().substring( "META-INF/services/".length() );
- final boolean isNeededClass = neededClasses.contains( cp.getClazz( serviceClassName ) );
- if ( !isNeededClass )
- {
- continue;
- }
+ final String serviceClassName =
+ jarEntry.getName().substring( "META-INF/services/".length() );
+ final boolean isNeededClass = neededClasses.contains( cp.getClazz( serviceClassName ) );
+ if ( !isNeededClass )
+ {
+ continue;
+ }
- try ( final BufferedReader bufferedReader =
- new BufferedReader( new InputStreamReader( jar.getInputStream( jarEntry ), UTF_8 ) ) )
- {
- for ( String line = bufferedReader.readLine(); line != null;
- line = bufferedReader.readLine() )
+ try ( final BufferedReader bufferedReader =
+ new BufferedReader( new InputStreamReader( jar.getInputStream( jarEntry ), UTF_8 ) ) )
{
- final String className = line.split( "#", 2 )[0].trim();
- if ( className.isEmpty() )
+ for ( String line = bufferedReader.readLine(); line != null;
+ line = bufferedReader.readLine() )
{
- continue;
+ final String className = line.split( "#", 2 )[0].trim();
+ if ( className.isEmpty() )
+ {
+ continue;
+ }
+
+ final Clazz clazz = cp.getClazz( className );
+ if ( clazz == null || !removable.contains( clazz ) )
+ {
+ continue;
+ }
+
+ log.info( className + " was not removed because it is a service" );
+ removeClass( cp, clazz );
+ repeatScan = true; // check whether the found classes use services in turn
}
-
- log.info( className + " was not removed because it is a service" );
- removeClass( cp, className );
}
- }
- catch ( final IOException e )
- {
- log.warn( e.getMessage() );
+ catch ( final IOException e )
+ {
+ log.warn( e.getMessage() );
+ }
}
}
- }
- catch ( final IOException e )
- {
- log.warn( e.getMessage() );
+ catch ( final IOException e )
+ {
+ log.warn( e.getMessage() );
+ }
}
}
+ catch ( final DependencyResolutionRequiredException e )
+ {
+ log.warn( e.getMessage() );
+ }
}
- catch ( final DependencyResolutionRequiredException e )
- {
- log.warn( e.getMessage() );
- }
+ while ( repeatScan );
}
- private void removeClass( final Clazzpath clazzPath, final String className )
+ private void removeClass( final Clazzpath clazzPath, final Clazz clazz )
{
- final Clazz clazz = clazzPath.getClazz( className );
- if ( clazz == null )
- {
- return;
- }
-
removable.remove( clazz );
removable.removeAll( clazz.getTransitiveDependencies() );
}
[maven-shade-plugin] 03/11: Keeping services always
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MSHADE-313
in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git
commit c22949b0cd54148e894ba9f64676a77fe4f05dc1
Author: Markus KARG <ma...@headcrashing.eu>
AuthorDate: Mon Apr 1 19:45:13 2019 +0200
Keeping services always
---
src/it/MSHADE-313/pom.xml | 1 -
.../apache/maven/plugins/shade/filter/MinijarFilter.java | 11 +++--------
.../java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java | 13 +------------
3 files changed, 4 insertions(+), 21 deletions(-)
diff --git a/src/it/MSHADE-313/pom.xml b/src/it/MSHADE-313/pom.xml
index ac8310a..4772be8 100644
--- a/src/it/MSHADE-313/pom.xml
+++ b/src/it/MSHADE-313/pom.xml
@@ -67,7 +67,6 @@ under the License.
<configuration>
<shadedArtifactAttached>false</shadedArtifactAttached>
<minimizeJar>true</minimizeJar>
- <keepServices>true</keepServices>
</configuration>
</execution>
</executions>
diff --git a/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java b/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
index 0029a34..cab8861 100644
--- a/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
+++ b/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
@@ -79,18 +79,17 @@ public class MinijarFilter
public MinijarFilter( MavenProject project, Log log )
throws IOException
{
- this( project, log, Collections.<SimpleFilter>emptyList(), false );
+ this( project, log, Collections.<SimpleFilter>emptyList() );
}
/**
* @param project {@link MavenProject}
* @param log {@link Log}
* @param simpleFilters {@link SimpleFilter}
- * @param keepServices don't eliminate classes needed by {@code META-INF/services}
* @throws IOException in case of errors.
* @since 1.6
*/
- public MinijarFilter( MavenProject project, Log log, List<SimpleFilter> simpleFilters, final boolean keepServices )
+ public MinijarFilter( MavenProject project, Log log, List<SimpleFilter> simpleFilters )
throws IOException
{
this.log = log;
@@ -118,11 +117,7 @@ public class MinijarFilter
removable.removeAll( artifactUnit.getTransitiveDependencies() );
removeSpecificallyIncludedClasses( project,
simpleFilters == null ? Collections.<SimpleFilter>emptyList() : simpleFilters );
-
- if ( keepServices )
- {
- removeServices( project, cp );
- }
+ removeServices( project, cp );
}
}
diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
index 48a4874..c99ed42 100644
--- a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
+++ b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
@@ -332,17 +332,6 @@ public class ShadeMojo
private boolean minimizeJar;
/**
- * When {@code true}, classes will be safe from getting stripped down by {@code minimizeJar} if they are
- * services (i. e. referenced by a text file contained in {@code META-INF/services}.
- *
- * @see #minimizeJar
- *
- * @since 3.2.2
- */
- @Parameter
- private boolean keepServices;
-
- /**
* The path to the output file for the shaded artifact. When this parameter is set, the created archive will neither
* replace the project's main artifact nor will it be attached. Hence, this parameter causes the parameters
* {@link #finalName}, {@link #shadedArtifactAttached}, {@link #shadedClassifierName} and
@@ -832,7 +821,7 @@ public class ShadeMojo
try
{
- filters.add( new MinijarFilter( project, getLog(), simpleFilters, keepServices ) );
+ filters.add( new MinijarFilter( project, getLog(), simpleFilters ) );
}
catch ( IOException e )
{
[maven-shade-plugin] 02/11: Keep Services
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MSHADE-313
in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git
commit 4f8bcef2c35ecad36c883983a72d537bc428f9c2
Author: Markus KARG <ma...@headcrashing.eu>
AuthorDate: Thu Mar 14 07:27:59 2019 +0100
Keep Services
Signed-off-by: Markus KARG <ma...@headcrashing.eu>
---
pom.xml | 3 +
src/it/MSHADE-313/invoker.properties | 18 +++++
src/it/MSHADE-313/pom.xml | 77 ++++++++++++++++++++++
src/it/MSHADE-313/src/main/java/Main.java | 22 +++++++
src/it/MSHADE-313/verify.bsh | 51 ++++++++++++++
.../maven/plugins/shade/filter/MinijarFilter.java | 67 ++++++++++++++++++-
.../apache/maven/plugins/shade/mojo/ShadeMojo.java | 13 +++-
7 files changed, 248 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index cb10a84..84644cd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -81,6 +81,9 @@
<contributor>
<name>Fabiano Cipriano de Oliveira</name>
</contributor>
+ <contributor>
+ <name>Markus Karg</name>
+ </contributor>
</contributors>
<dependencies>
diff --git a/src/it/MSHADE-313/invoker.properties b/src/it/MSHADE-313/invoker.properties
new file mode 100644
index 0000000..c8b7b3c
--- /dev/null
+++ b/src/it/MSHADE-313/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.java.version = 1.8+
diff --git a/src/it/MSHADE-313/pom.xml b/src/it/MSHADE-313/pom.xml
new file mode 100644
index 0000000..ac8310a
--- /dev/null
+++ b/src/it/MSHADE-313/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.shade.mj</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0</version>
+ <packaging>jar</packaging>
+
+ <name>MSHADE-313</name>
+ <description>
+ Prevent minimizeJar from excluding classes that are used by services.
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>jdom</groupId>
+ <artifactId>jdom</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.glassfish.jaxb</groupId>
+ <artifactId>jaxb-runtime</artifactId>
+ <version>2.3.2</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <id>attach-shade</id>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <shadedArtifactAttached>false</shadedArtifactAttached>
+ <minimizeJar>true</minimizeJar>
+ <keepServices>true</keepServices>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/it/MSHADE-313/src/main/java/Main.java b/src/it/MSHADE-313/src/main/java/Main.java
new file mode 100644
index 0000000..293e02c
--- /dev/null
+++ b/src/it/MSHADE-313/src/main/java/Main.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 Main
+{
+}
diff --git a/src/it/MSHADE-313/verify.bsh b/src/it/MSHADE-313/verify.bsh
new file mode 100644
index 0000000..8542a85
--- /dev/null
+++ b/src/it/MSHADE-313/verify.bsh
@@ -0,0 +1,51 @@
+/*
+ * 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.*;
+
+String[] wanted =
+{
+ "Main.class",
+ "com/sun/xml/bind/v2/runtime/JAXBContextImpl.class"
+};
+
+String[] unwanted =
+{
+ "org/jdom/Document.class"
+};
+
+JarFile jarFile = new JarFile( new File( basedir, "target/test-1.0.jar" ) );
+
+for ( String path : wanted )
+{
+ if ( jarFile.getEntry( path ) == null )
+ {
+ throw new IllegalStateException( "wanted path is missing: " + path );
+ }
+}
+
+for ( String path : unwanted )
+{
+ if ( jarFile.getEntry( path ) != null )
+ {
+ throw new IllegalStateException( "unwanted path is present: " + path );
+ }
+}
+
+jarFile.close();
diff --git a/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java b/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
index bccf1b4..0029a34 100644
--- a/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
+++ b/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
@@ -20,6 +20,7 @@ package org.apache.maven.plugins.shade.filter;
*/
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.IOUtil;
@@ -27,15 +28,20 @@ import org.vafer.jdependency.Clazz;
import org.vafer.jdependency.Clazzpath;
import org.vafer.jdependency.ClazzpathUnit;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.util.Collections;
+import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
import java.util.zip.ZipException;
/**
@@ -73,17 +79,18 @@ public class MinijarFilter
public MinijarFilter( MavenProject project, Log log )
throws IOException
{
- this( project, log, Collections.<SimpleFilter>emptyList() );
+ this( project, log, Collections.<SimpleFilter>emptyList(), false );
}
/**
* @param project {@link MavenProject}
* @param log {@link Log}
* @param simpleFilters {@link SimpleFilter}
+ * @param keepServices don't eliminate classes needed by {@code META-INF/services}
* @throws IOException in case of errors.
* @since 1.6
*/
- public MinijarFilter( MavenProject project, Log log, List<SimpleFilter> simpleFilters )
+ public MinijarFilter( MavenProject project, Log log, List<SimpleFilter> simpleFilters, final boolean keepServices )
throws IOException
{
this.log = log;
@@ -111,9 +118,65 @@ public class MinijarFilter
removable.removeAll( artifactUnit.getTransitiveDependencies() );
removeSpecificallyIncludedClasses( project,
simpleFilters == null ? Collections.<SimpleFilter>emptyList() : simpleFilters );
+
+ if ( keepServices )
+ {
+ removeServices( project, cp );
+ }
+ }
+ }
+
+ private void removeServices( final MavenProject project, final Clazzpath cp )
+ {
+ try
+ {
+ for ( final String fileName : project.getRuntimeClasspathElements() )
+ {
+ try ( final JarFile jar = new JarFile( fileName ) )
+ {
+ for ( final Enumeration<JarEntry> entries = jar.entries(); entries.hasMoreElements(); )
+ {
+ final JarEntry jarEntry = entries.nextElement();
+ if ( !jarEntry.getName().startsWith( "META-INF/services/" ) )
+ {
+ continue;
+ }
+
+ try ( final BufferedReader bufferedReader =
+ new BufferedReader( new InputStreamReader( jar.getInputStream( jarEntry ) ) ) )
+ {
+ for ( String className = bufferedReader.readLine(); className != null;
+ className = bufferedReader.readLine() )
+ {
+ log.info( className + " was not removed because it is a service" );
+ removeClass( cp , className );
+ }
+ }
+ catch ( final IOException e )
+ {
+ log.warn( e.getMessage() );
+ }
+ }
+ }
+ catch ( final IOException e )
+ {
+ log.warn( e.getMessage() );
+ }
+ }
+ }
+ catch ( final DependencyResolutionRequiredException e )
+ {
+ log.warn( e.getMessage() );
}
}
+ private void removeClass( final Clazzpath clazzPath, final String className )
+ {
+ final Clazz clazz = clazzPath.getClazz( className );
+ removable.remove( clazz );
+ removable.removeAll( clazz.getTransitiveDependencies() );
+ }
+
private ClazzpathUnit addDependencyToClasspath( Clazzpath cp, Artifact dependency )
throws IOException
{
diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
index c99ed42..48a4874 100644
--- a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
+++ b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
@@ -332,6 +332,17 @@ public class ShadeMojo
private boolean minimizeJar;
/**
+ * When {@code true}, classes will be safe from getting stripped down by {@code minimizeJar} if they are
+ * services (i. e. referenced by a text file contained in {@code META-INF/services}.
+ *
+ * @see #minimizeJar
+ *
+ * @since 3.2.2
+ */
+ @Parameter
+ private boolean keepServices;
+
+ /**
* The path to the output file for the shaded artifact. When this parameter is set, the created archive will neither
* replace the project's main artifact nor will it be attached. Hence, this parameter causes the parameters
* {@link #finalName}, {@link #shadedArtifactAttached}, {@link #shadedClassifierName} and
@@ -821,7 +832,7 @@ public class ShadeMojo
try
{
- filters.add( new MinijarFilter( project, getLog(), simpleFilters ) );
+ filters.add( new MinijarFilter( project, getLog(), simpleFilters, keepServices ) );
}
catch ( IOException e )
{
[maven-shade-plugin] 10/11: IT checks for existence of service
descriptors
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MSHADE-313
in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git
commit 0b453ed88ce9b849bf0069683b8830d56f2d4303
Author: Markus KARG <ma...@headcrashing.eu>
AuthorDate: Mon Apr 8 20:53:31 2019 +0000
IT checks for existence of service descriptors
@rfscholte explicitly asked for this
---
src/it/MSHADE-313/verify.bsh | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/it/MSHADE-313/verify.bsh b/src/it/MSHADE-313/verify.bsh
index 38014a8..2a58a84 100644
--- a/src/it/MSHADE-313/verify.bsh
+++ b/src/it/MSHADE-313/verify.bsh
@@ -22,9 +22,11 @@ import java.util.jar.*;
String[] wanted =
{
"Main.class",
+ "META-INF/services/SomeServiceInterface",
"SomeServiceInterface.class",
"SomeServiceClass.class",
"SomeReferencedClass.class",
+ "META-INF/services/DependencyServiceInterface",
"DependencyServiceInterface.class",
"DependencyServiceClass.class",
"DependencyReferencedClass.class"
[maven-shade-plugin] 11/11: [MSHADE-313] Rename IT Remove unused
import Adjust logging (to keep info as clean as possible) Clean up pom
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MSHADE-313
in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git
commit e4321c5c9c3986a1911a75ad91170d6c6a493bad
Author: rfscholte <rf...@apache.org>
AuthorDate: Sat Apr 13 11:37:10 2019 +0200
[MSHADE-313] Rename IT
Remove unused import
Adjust logging (to keep info as clean as possible)
Clean up pom
---
pom.xml | 6 +-----
.../dependency-service/pom.xml | 0
.../src/main/java/DependencyReferencedClass.java | 0
.../src/main/java/DependencyServiceClass.java | 0
.../src/main/java/DependencyServiceInterface.java | 0
.../src/main/java/DependencyUnreferencedClass.java | 0
.../META-INF/services/DependencyServiceInterface | 0
.../invoker.properties | 0
.../pom.xml | 0
.../test/pom.xml | 0
.../test/src/main/java/Main.java | 0
.../unused-service/pom.xml | 0
.../src/main/java/UnusedServiceClass.java | 0
.../src/main/java/UnusedServiceInterface.java | 0
.../resources/META-INF/services/UnusedServiceInterface | 0
.../used-service/pom.xml | 0
.../used-service/src/main/java/SomeReferencedClass.java | 0
.../used-service/src/main/java/SomeServiceClass.java | 0
.../src/main/java/SomeServiceInterface.java | 0
.../src/main/java/SomeUnreferencedClass.java | 0
.../resources/META-INF/services/SomeServiceInterface | 0
.../verify.bsh | 0
.../maven/plugins/shade/filter/MinijarFilter.java | 17 +++++++----------
23 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/pom.xml b/pom.xml
index a960b8a..0cd2884 100644
--- a/pom.xml
+++ b/pom.xml
@@ -208,12 +208,8 @@
<exclude>src/it/rerun-with-reloc/src/main/resources/some-ordinary-resource.txt</exclude>
<exclude>src/it/rerun-without-reloc/src/main/resources/some-ordinary-resource.txt</exclude>
<exclude>src/it/MSHADE-182/src/main/resources/META-INF/services/relocateme.Service</exclude>
- <exclude>src/it/MSHADE-182/target/classes/META-INF/services/relocateme.Service</exclude>
- <exclude>src/it/MSHADE-182/build.log</exclude>
- <exclude>src/it/MSHADE-313/service/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst</exclude>
- <exclude>src/it/MSHADE-313/service/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst</exclude>
</excludes>
- </configuration>
+ </configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
diff --git a/src/it/MSHADE-313/dependency-service/pom.xml b/src/it/MSHADE-313_minimized-services/dependency-service/pom.xml
similarity index 100%
rename from src/it/MSHADE-313/dependency-service/pom.xml
rename to src/it/MSHADE-313_minimized-services/dependency-service/pom.xml
diff --git a/src/it/MSHADE-313/dependency-service/src/main/java/DependencyReferencedClass.java b/src/it/MSHADE-313_minimized-services/dependency-service/src/main/java/DependencyReferencedClass.java
similarity index 100%
rename from src/it/MSHADE-313/dependency-service/src/main/java/DependencyReferencedClass.java
rename to src/it/MSHADE-313_minimized-services/dependency-service/src/main/java/DependencyReferencedClass.java
diff --git a/src/it/MSHADE-313/dependency-service/src/main/java/DependencyServiceClass.java b/src/it/MSHADE-313_minimized-services/dependency-service/src/main/java/DependencyServiceClass.java
similarity index 100%
rename from src/it/MSHADE-313/dependency-service/src/main/java/DependencyServiceClass.java
rename to src/it/MSHADE-313_minimized-services/dependency-service/src/main/java/DependencyServiceClass.java
diff --git a/src/it/MSHADE-313/dependency-service/src/main/java/DependencyServiceInterface.java b/src/it/MSHADE-313_minimized-services/dependency-service/src/main/java/DependencyServiceInterface.java
similarity index 100%
rename from src/it/MSHADE-313/dependency-service/src/main/java/DependencyServiceInterface.java
rename to src/it/MSHADE-313_minimized-services/dependency-service/src/main/java/DependencyServiceInterface.java
diff --git a/src/it/MSHADE-313/dependency-service/src/main/java/DependencyUnreferencedClass.java b/src/it/MSHADE-313_minimized-services/dependency-service/src/main/java/DependencyUnreferencedClass.java
similarity index 100%
rename from src/it/MSHADE-313/dependency-service/src/main/java/DependencyUnreferencedClass.java
rename to src/it/MSHADE-313_minimized-services/dependency-service/src/main/java/DependencyUnreferencedClass.java
diff --git a/src/it/MSHADE-313/dependency-service/src/main/resources/META-INF/services/DependencyServiceInterface b/src/it/MSHADE-313_minimized-services/dependency-service/src/main/resources/META-INF/services/DependencyServiceInterface
similarity index 100%
rename from src/it/MSHADE-313/dependency-service/src/main/resources/META-INF/services/DependencyServiceInterface
rename to src/it/MSHADE-313_minimized-services/dependency-service/src/main/resources/META-INF/services/DependencyServiceInterface
diff --git a/src/it/MSHADE-313/invoker.properties b/src/it/MSHADE-313_minimized-services/invoker.properties
similarity index 100%
rename from src/it/MSHADE-313/invoker.properties
rename to src/it/MSHADE-313_minimized-services/invoker.properties
diff --git a/src/it/MSHADE-313/pom.xml b/src/it/MSHADE-313_minimized-services/pom.xml
similarity index 100%
rename from src/it/MSHADE-313/pom.xml
rename to src/it/MSHADE-313_minimized-services/pom.xml
diff --git a/src/it/MSHADE-313/test/pom.xml b/src/it/MSHADE-313_minimized-services/test/pom.xml
similarity index 100%
rename from src/it/MSHADE-313/test/pom.xml
rename to src/it/MSHADE-313_minimized-services/test/pom.xml
diff --git a/src/it/MSHADE-313/test/src/main/java/Main.java b/src/it/MSHADE-313_minimized-services/test/src/main/java/Main.java
similarity index 100%
rename from src/it/MSHADE-313/test/src/main/java/Main.java
rename to src/it/MSHADE-313_minimized-services/test/src/main/java/Main.java
diff --git a/src/it/MSHADE-313/unused-service/pom.xml b/src/it/MSHADE-313_minimized-services/unused-service/pom.xml
similarity index 100%
rename from src/it/MSHADE-313/unused-service/pom.xml
rename to src/it/MSHADE-313_minimized-services/unused-service/pom.xml
diff --git a/src/it/MSHADE-313/unused-service/src/main/java/UnusedServiceClass.java b/src/it/MSHADE-313_minimized-services/unused-service/src/main/java/UnusedServiceClass.java
similarity index 100%
rename from src/it/MSHADE-313/unused-service/src/main/java/UnusedServiceClass.java
rename to src/it/MSHADE-313_minimized-services/unused-service/src/main/java/UnusedServiceClass.java
diff --git a/src/it/MSHADE-313/unused-service/src/main/java/UnusedServiceInterface.java b/src/it/MSHADE-313_minimized-services/unused-service/src/main/java/UnusedServiceInterface.java
similarity index 100%
rename from src/it/MSHADE-313/unused-service/src/main/java/UnusedServiceInterface.java
rename to src/it/MSHADE-313_minimized-services/unused-service/src/main/java/UnusedServiceInterface.java
diff --git a/src/it/MSHADE-313/unused-service/src/main/resources/META-INF/services/UnusedServiceInterface b/src/it/MSHADE-313_minimized-services/unused-service/src/main/resources/META-INF/services/UnusedServiceInterface
similarity index 100%
rename from src/it/MSHADE-313/unused-service/src/main/resources/META-INF/services/UnusedServiceInterface
rename to src/it/MSHADE-313_minimized-services/unused-service/src/main/resources/META-INF/services/UnusedServiceInterface
diff --git a/src/it/MSHADE-313/used-service/pom.xml b/src/it/MSHADE-313_minimized-services/used-service/pom.xml
similarity index 100%
rename from src/it/MSHADE-313/used-service/pom.xml
rename to src/it/MSHADE-313_minimized-services/used-service/pom.xml
diff --git a/src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java b/src/it/MSHADE-313_minimized-services/used-service/src/main/java/SomeReferencedClass.java
similarity index 100%
rename from src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java
rename to src/it/MSHADE-313_minimized-services/used-service/src/main/java/SomeReferencedClass.java
diff --git a/src/it/MSHADE-313/used-service/src/main/java/SomeServiceClass.java b/src/it/MSHADE-313_minimized-services/used-service/src/main/java/SomeServiceClass.java
similarity index 100%
rename from src/it/MSHADE-313/used-service/src/main/java/SomeServiceClass.java
rename to src/it/MSHADE-313_minimized-services/used-service/src/main/java/SomeServiceClass.java
diff --git a/src/it/MSHADE-313/used-service/src/main/java/SomeServiceInterface.java b/src/it/MSHADE-313_minimized-services/used-service/src/main/java/SomeServiceInterface.java
similarity index 100%
rename from src/it/MSHADE-313/used-service/src/main/java/SomeServiceInterface.java
rename to src/it/MSHADE-313_minimized-services/used-service/src/main/java/SomeServiceInterface.java
diff --git a/src/it/MSHADE-313/used-service/src/main/java/SomeUnreferencedClass.java b/src/it/MSHADE-313_minimized-services/used-service/src/main/java/SomeUnreferencedClass.java
similarity index 100%
rename from src/it/MSHADE-313/used-service/src/main/java/SomeUnreferencedClass.java
rename to src/it/MSHADE-313_minimized-services/used-service/src/main/java/SomeUnreferencedClass.java
diff --git a/src/it/MSHADE-313/used-service/src/main/resources/META-INF/services/SomeServiceInterface b/src/it/MSHADE-313_minimized-services/used-service/src/main/resources/META-INF/services/SomeServiceInterface
similarity index 100%
rename from src/it/MSHADE-313/used-service/src/main/resources/META-INF/services/SomeServiceInterface
rename to src/it/MSHADE-313_minimized-services/used-service/src/main/resources/META-INF/services/SomeServiceInterface
diff --git a/src/it/MSHADE-313/verify.bsh b/src/it/MSHADE-313_minimized-services/verify.bsh
similarity index 100%
rename from src/it/MSHADE-313/verify.bsh
rename to src/it/MSHADE-313_minimized-services/verify.bsh
diff --git a/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java b/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
index e0a8e85..10606d2 100644
--- a/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
+++ b/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
@@ -23,7 +23,6 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.util.IOUtil;
import org.vafer.jdependency.Clazz;
import org.vafer.jdependency.Clazzpath;
import org.vafer.jdependency.ClazzpathUnit;
@@ -171,7 +170,7 @@ public class MinijarFilter
continue;
}
- log.info( className + " was not removed because it is a service" );
+ log.debug( className + " was not removed because it is a service" );
removeClass( cp, clazz );
repeatScan = true; // check whether the found classes use services in turn
}
@@ -235,12 +234,10 @@ public class MinijarFilter
removePackages( artifactUnit.getTransitiveDependencies(), packageNames );
}
- @SuppressWarnings( "rawtypes" )
- private void removePackages( Set clazzes, Set<String> packageNames )
+ private void removePackages( Set<Clazz> clazzes, Set<String> packageNames )
{
- for ( Object clazze : clazzes )
+ for ( Clazz clazz : clazzes )
{
- Clazz clazz = (Clazz) clazze;
String name = clazz.getName();
while ( name.contains( "." ) )
{
@@ -278,7 +275,7 @@ public class MinijarFilter
if ( clazzes.contains( clazz ) //
&& simpleFilter.isSpecificallyIncluded( clazz.getName().replace( '.', '/' ) ) )
{
- log.info( clazz.getName() + " not removed because it was specifically included" );
+ log.debug( clazz.getName() + " not removed because it was specifically included" );
j.remove();
}
}
@@ -288,13 +285,13 @@ public class MinijarFilter
}
}
- /** {@inheritDoc} */
+ @Override
public boolean canFilter( File jar )
{
return true;
}
- /** {@inheritDoc} */
+ @Override
public boolean isFiltered( String classFile )
{
String className = classFile.replace( '/', '.' ).replaceFirst( "\\.class$", "" );
@@ -311,7 +308,7 @@ public class MinijarFilter
return false;
}
- /** {@inheritDoc} */
+ @Override
public void finished()
{
int classesTotal = classesRemoved + classesKept;
[maven-shade-plugin] 08/11: Only keep actually consumed services
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MSHADE-313
in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git
commit 78ca1f3296779de8f461e32053ca536bf298e1c3
Author: Markus KARG <ma...@headcrashing.eu>
AuthorDate: Sat Apr 6 12:04:52 2019 +0000
Only keep actually consumed services
---
src/it/MSHADE-313/pom.xml | 3 ++-
src/it/MSHADE-313/test/pom.xml | 8 +++++++-
src/it/MSHADE-313/test/src/main/java/Main.java | 9 +++++++--
src/it/MSHADE-313/{service => unused-service}/pom.xml | 2 +-
.../src/main/java/UnusedServiceClass.java} | 2 +-
.../src/main/java/UnusedServiceInterface.java} | 2 +-
.../main/resources/META-INF/services/UnusedServiceInterface} | 2 +-
src/it/MSHADE-313/{service => used-service}/pom.xml | 2 +-
.../src/main/java/SomeReferencedClass.java | 0
.../src/main/java/SomeServiceClass.java | 0
.../src/main/java/SomeServiceInterface.java | 0
.../src/main/java/SomeUnreferencedClass.java | 0
.../src/main/resources/META-INF/services/SomeServiceInterface | 0
src/it/MSHADE-313/verify.bsh | 2 ++
.../org/apache/maven/plugins/shade/filter/MinijarFilter.java | 11 ++++++++++-
15 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/src/it/MSHADE-313/pom.xml b/src/it/MSHADE-313/pom.xml
index 0eab97c..7907136 100644
--- a/src/it/MSHADE-313/pom.xml
+++ b/src/it/MSHADE-313/pom.xml
@@ -33,7 +33,8 @@ under the License.
</description>
<modules>
- <module>service</module>
+ <module>unused-service</module>
+ <module>used-service</module>
<module>test</module>
</modules>
</project>
diff --git a/src/it/MSHADE-313/test/pom.xml b/src/it/MSHADE-313/test/pom.xml
index b0ecdaa..cb51ef6 100644
--- a/src/it/MSHADE-313/test/pom.xml
+++ b/src/it/MSHADE-313/test/pom.xml
@@ -29,7 +29,13 @@ under the License.
<dependencies>
<dependency>
<groupId>org.apache.maven.its.shade.mj</groupId>
- <artifactId>service</artifactId>
+ <artifactId>unused-service</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven.its.shade.mj</groupId>
+ <artifactId>used-service</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
diff --git a/src/it/MSHADE-313/test/src/main/java/Main.java b/src/it/MSHADE-313/test/src/main/java/Main.java
index 293e02c..3f22717 100644
--- a/src/it/MSHADE-313/test/src/main/java/Main.java
+++ b/src/it/MSHADE-313/test/src/main/java/Main.java
@@ -6,9 +6,9 @@
* 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
@@ -17,6 +17,11 @@
* under the License.
*/
+import java.util.ServiceLoader;
+
public class Main
{
+ public static void main( String[] args ) {
+ ServiceLoader.load( SomeServiceInterface.class );
+ }
}
diff --git a/src/it/MSHADE-313/service/pom.xml b/src/it/MSHADE-313/unused-service/pom.xml
similarity index 95%
copy from src/it/MSHADE-313/service/pom.xml
copy to src/it/MSHADE-313/unused-service/pom.xml
index 3dc87e2..3058161 100644
--- a/src/it/MSHADE-313/service/pom.xml
+++ b/src/it/MSHADE-313/unused-service/pom.xml
@@ -23,6 +23,6 @@ under the License.
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.shade.mj</groupId>
- <artifactId>service</artifactId>
+ <artifactId>unused-service</artifactId>
<version>1.0</version>
</project>
diff --git a/src/it/MSHADE-313/service/src/main/java/SomeServiceInterface.java b/src/it/MSHADE-313/unused-service/src/main/java/UnusedServiceClass.java
similarity index 92%
copy from src/it/MSHADE-313/service/src/main/java/SomeServiceInterface.java
copy to src/it/MSHADE-313/unused-service/src/main/java/UnusedServiceClass.java
index d5c3e95..893d019 100644
--- a/src/it/MSHADE-313/service/src/main/java/SomeServiceInterface.java
+++ b/src/it/MSHADE-313/unused-service/src/main/java/UnusedServiceClass.java
@@ -17,6 +17,6 @@
* under the License.
*/
-public interface SomeServiceInterface
+public class UnusedServiceClass implements UnusedServiceInterface
{
}
diff --git a/src/it/MSHADE-313/service/src/main/java/SomeServiceInterface.java b/src/it/MSHADE-313/unused-service/src/main/java/UnusedServiceInterface.java
similarity index 95%
copy from src/it/MSHADE-313/service/src/main/java/SomeServiceInterface.java
copy to src/it/MSHADE-313/unused-service/src/main/java/UnusedServiceInterface.java
index d5c3e95..f1654b6 100644
--- a/src/it/MSHADE-313/service/src/main/java/SomeServiceInterface.java
+++ b/src/it/MSHADE-313/unused-service/src/main/java/UnusedServiceInterface.java
@@ -17,6 +17,6 @@
* under the License.
*/
-public interface SomeServiceInterface
+public interface UnusedServiceInterface
{
}
diff --git a/src/it/MSHADE-313/service/src/main/resources/META-INF/services/SomeServiceInterface b/src/it/MSHADE-313/unused-service/src/main/resources/META-INF/services/UnusedServiceInterface
similarity index 89%
copy from src/it/MSHADE-313/service/src/main/resources/META-INF/services/SomeServiceInterface
copy to src/it/MSHADE-313/unused-service/src/main/resources/META-INF/services/UnusedServiceInterface
index 5af3e8e..1dd5c84 100644
--- a/src/it/MSHADE-313/service/src/main/resources/META-INF/services/SomeServiceInterface
+++ b/src/it/MSHADE-313/unused-service/src/main/resources/META-INF/services/UnusedServiceInterface
@@ -16,5 +16,5 @@
# specific language governing permissions and limitations
# under the License.
#
- SomeServiceClass # Please do not remove comments or whitespace; they are part of the IT test.
+ UnusedServiceClass # Please do not remove comments or whitespace; they are part of the IT test.
diff --git a/src/it/MSHADE-313/service/pom.xml b/src/it/MSHADE-313/used-service/pom.xml
similarity index 95%
rename from src/it/MSHADE-313/service/pom.xml
rename to src/it/MSHADE-313/used-service/pom.xml
index 3dc87e2..fe4edc0 100644
--- a/src/it/MSHADE-313/service/pom.xml
+++ b/src/it/MSHADE-313/used-service/pom.xml
@@ -23,6 +23,6 @@ under the License.
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.shade.mj</groupId>
- <artifactId>service</artifactId>
+ <artifactId>used-service</artifactId>
<version>1.0</version>
</project>
diff --git a/src/it/MSHADE-313/service/src/main/java/SomeReferencedClass.java b/src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java
similarity index 100%
rename from src/it/MSHADE-313/service/src/main/java/SomeReferencedClass.java
rename to src/it/MSHADE-313/used-service/src/main/java/SomeReferencedClass.java
diff --git a/src/it/MSHADE-313/service/src/main/java/SomeServiceClass.java b/src/it/MSHADE-313/used-service/src/main/java/SomeServiceClass.java
similarity index 100%
rename from src/it/MSHADE-313/service/src/main/java/SomeServiceClass.java
rename to src/it/MSHADE-313/used-service/src/main/java/SomeServiceClass.java
diff --git a/src/it/MSHADE-313/service/src/main/java/SomeServiceInterface.java b/src/it/MSHADE-313/used-service/src/main/java/SomeServiceInterface.java
similarity index 100%
rename from src/it/MSHADE-313/service/src/main/java/SomeServiceInterface.java
rename to src/it/MSHADE-313/used-service/src/main/java/SomeServiceInterface.java
diff --git a/src/it/MSHADE-313/service/src/main/java/SomeUnreferencedClass.java b/src/it/MSHADE-313/used-service/src/main/java/SomeUnreferencedClass.java
similarity index 100%
rename from src/it/MSHADE-313/service/src/main/java/SomeUnreferencedClass.java
rename to src/it/MSHADE-313/used-service/src/main/java/SomeUnreferencedClass.java
diff --git a/src/it/MSHADE-313/service/src/main/resources/META-INF/services/SomeServiceInterface b/src/it/MSHADE-313/used-service/src/main/resources/META-INF/services/SomeServiceInterface
similarity index 100%
rename from src/it/MSHADE-313/service/src/main/resources/META-INF/services/SomeServiceInterface
rename to src/it/MSHADE-313/used-service/src/main/resources/META-INF/services/SomeServiceInterface
diff --git a/src/it/MSHADE-313/verify.bsh b/src/it/MSHADE-313/verify.bsh
index e3c5d32..cf79b16 100644
--- a/src/it/MSHADE-313/verify.bsh
+++ b/src/it/MSHADE-313/verify.bsh
@@ -29,6 +29,8 @@ String[] wanted =
String[] unwanted =
{
+ "UnusedServiceInterface.class",
+ "UnusedServiceClass.class",
"SomeUnreferencedClass.class"
};
diff --git a/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java b/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
index 528caa8..e04355e 100644
--- a/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
+++ b/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java
@@ -125,6 +125,8 @@ public class MinijarFilter
private void removeServices( final MavenProject project, final Clazzpath cp )
{
+ final Set<Clazz> neededClasses = cp.getClazzes();
+ neededClasses.removeAll( removable );
try
{
for ( final String fileName : project.getRuntimeClasspathElements() )
@@ -134,7 +136,14 @@ public class MinijarFilter
for ( final Enumeration<JarEntry> entries = jar.entries(); entries.hasMoreElements(); )
{
final JarEntry jarEntry = entries.nextElement();
- if ( !jarEntry.getName().startsWith( "META-INF/services/" ) )
+ if ( jarEntry.isDirectory() || !jarEntry.getName().startsWith( "META-INF/services/" ) )
+ {
+ continue;
+ }
+
+ final String serviceClassName = jarEntry.getName().substring( "META-INF/services/".length() );
+ final boolean isNeededClass = neededClasses.contains( cp.getClazz( serviceClassName ) );
+ if ( !isNeededClass )
{
continue;
}
[maven-shade-plugin] 05/11: testing service description file syntax
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MSHADE-313
in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git
commit d352a224021d43e050b8c2a1e75547e01f1489eb
Author: Markus KARG <ma...@headcrashing.eu>
AuthorDate: Wed Apr 3 18:58:23 2019 +0200
testing service description file syntax
---
src/it/MSHADE-313/pom.xml | 49 +++-------------------
src/it/MSHADE-313/service/pom.xml | 28 +++++++++++++
.../src/main/java/SomeReferencedClass.java} | 2 +-
.../src/main/java/SomeServiceClass.java} | 3 +-
.../src/main/java/SomeServiceInterface.java} | 2 +-
.../src/main/java/SomeUnreferencedClass.java} | 2 +-
.../META-INF/services/SomeServiceInterface | 20 +++++++++
src/it/MSHADE-313/{ => test}/pom.xml | 16 +------
.../MSHADE-313/{ => test}/src/main/java/Main.java | 0
src/it/MSHADE-313/verify.bsh | 8 ++--
10 files changed, 66 insertions(+), 64 deletions(-)
diff --git a/src/it/MSHADE-313/pom.xml b/src/it/MSHADE-313/pom.xml
index 4772be8..0eab97c 100644
--- a/src/it/MSHADE-313/pom.xml
+++ b/src/it/MSHADE-313/pom.xml
@@ -23,54 +23,17 @@ under the License.
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.shade.mj</groupId>
- <artifactId>test</artifactId>
+ <artifactId>aggregate</artifactId>
<version>1.0</version>
- <packaging>jar</packaging>
+ <packaging>pom</packaging>
<name>MSHADE-313</name>
<description>
Prevent minimizeJar from excluding classes that are used by services.
</description>
- <dependencies>
- <dependency>
- <groupId>jdom</groupId>
- <artifactId>jdom</artifactId>
- <version>1.0</version>
- </dependency>
-
- <dependency>
- <groupId>org.glassfish.jaxb</groupId>
- <artifactId>jaxb-runtime</artifactId>
- <version>2.3.2</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>@project.version@</version>
- <executions>
- <execution>
- <id>attach-shade</id>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <shadedArtifactAttached>false</shadedArtifactAttached>
- <minimizeJar>true</minimizeJar>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+ <modules>
+ <module>service</module>
+ <module>test</module>
+ </modules>
</project>
diff --git a/src/it/MSHADE-313/service/pom.xml b/src/it/MSHADE-313/service/pom.xml
new file mode 100644
index 0000000..3dc87e2
--- /dev/null
+++ b/src/it/MSHADE-313/service/pom.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.shade.mj</groupId>
+ <artifactId>service</artifactId>
+ <version>1.0</version>
+</project>
diff --git a/src/it/MSHADE-313/src/main/java/Main.java b/src/it/MSHADE-313/service/src/main/java/SomeReferencedClass.java
similarity index 96%
copy from src/it/MSHADE-313/src/main/java/Main.java
copy to src/it/MSHADE-313/service/src/main/java/SomeReferencedClass.java
index 293e02c..afc0f5f 100644
--- a/src/it/MSHADE-313/src/main/java/Main.java
+++ b/src/it/MSHADE-313/service/src/main/java/SomeReferencedClass.java
@@ -17,6 +17,6 @@
* under the License.
*/
-public class Main
+public class SomeReferencedClass
{
}
diff --git a/src/it/MSHADE-313/src/main/java/Main.java b/src/it/MSHADE-313/service/src/main/java/SomeServiceClass.java
similarity index 86%
copy from src/it/MSHADE-313/src/main/java/Main.java
copy to src/it/MSHADE-313/service/src/main/java/SomeServiceClass.java
index 293e02c..0beac7a 100644
--- a/src/it/MSHADE-313/src/main/java/Main.java
+++ b/src/it/MSHADE-313/service/src/main/java/SomeServiceClass.java
@@ -17,6 +17,7 @@
* under the License.
*/
-public class Main
+public class SomeServiceClass implements SomeServiceInterface
{
+ private static SomeReferencedClass anEssentialDependency;
}
diff --git a/src/it/MSHADE-313/src/main/java/Main.java b/src/it/MSHADE-313/service/src/main/java/SomeServiceInterface.java
similarity index 95%
copy from src/it/MSHADE-313/src/main/java/Main.java
copy to src/it/MSHADE-313/service/src/main/java/SomeServiceInterface.java
index 293e02c..d5c3e95 100644
--- a/src/it/MSHADE-313/src/main/java/Main.java
+++ b/src/it/MSHADE-313/service/src/main/java/SomeServiceInterface.java
@@ -17,6 +17,6 @@
* under the License.
*/
-public class Main
+public interface SomeServiceInterface
{
}
diff --git a/src/it/MSHADE-313/src/main/java/Main.java b/src/it/MSHADE-313/service/src/main/java/SomeUnreferencedClass.java
similarity index 95%
copy from src/it/MSHADE-313/src/main/java/Main.java
copy to src/it/MSHADE-313/service/src/main/java/SomeUnreferencedClass.java
index 293e02c..7cb81ba 100644
--- a/src/it/MSHADE-313/src/main/java/Main.java
+++ b/src/it/MSHADE-313/service/src/main/java/SomeUnreferencedClass.java
@@ -17,6 +17,6 @@
* under the License.
*/
-public class Main
+public class SomeUnreferencedClass
{
}
diff --git a/src/it/MSHADE-313/service/src/main/resources/META-INF/services/SomeServiceInterface b/src/it/MSHADE-313/service/src/main/resources/META-INF/services/SomeServiceInterface
new file mode 100644
index 0000000..5af3e8e
--- /dev/null
+++ b/src/it/MSHADE-313/service/src/main/resources/META-INF/services/SomeServiceInterface
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+ SomeServiceClass # Please do not remove comments or whitespace; they are part of the IT test.
+
diff --git a/src/it/MSHADE-313/pom.xml b/src/it/MSHADE-313/test/pom.xml
similarity index 83%
copy from src/it/MSHADE-313/pom.xml
copy to src/it/MSHADE-313/test/pom.xml
index 4772be8..b0ecdaa 100644
--- a/src/it/MSHADE-313/pom.xml
+++ b/src/it/MSHADE-313/test/pom.xml
@@ -25,25 +25,13 @@ under the License.
<groupId>org.apache.maven.its.shade.mj</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
- <packaging>jar</packaging>
-
- <name>MSHADE-313</name>
- <description>
- Prevent minimizeJar from excluding classes that are used by services.
- </description>
<dependencies>
<dependency>
- <groupId>jdom</groupId>
- <artifactId>jdom</artifactId>
+ <groupId>org.apache.maven.its.shade.mj</groupId>
+ <artifactId>service</artifactId>
<version>1.0</version>
</dependency>
-
- <dependency>
- <groupId>org.glassfish.jaxb</groupId>
- <artifactId>jaxb-runtime</artifactId>
- <version>2.3.2</version>
- </dependency>
</dependencies>
<build>
diff --git a/src/it/MSHADE-313/src/main/java/Main.java b/src/it/MSHADE-313/test/src/main/java/Main.java
similarity index 100%
rename from src/it/MSHADE-313/src/main/java/Main.java
rename to src/it/MSHADE-313/test/src/main/java/Main.java
diff --git a/src/it/MSHADE-313/verify.bsh b/src/it/MSHADE-313/verify.bsh
index 8542a85..e3c5d32 100644
--- a/src/it/MSHADE-313/verify.bsh
+++ b/src/it/MSHADE-313/verify.bsh
@@ -22,15 +22,17 @@ import java.util.jar.*;
String[] wanted =
{
"Main.class",
- "com/sun/xml/bind/v2/runtime/JAXBContextImpl.class"
+ "SomeServiceInterface.class",
+ "SomeServiceClass.class",
+ "SomeReferencedClass.class"
};
String[] unwanted =
{
- "org/jdom/Document.class"
+ "SomeUnreferencedClass.class"
};
-JarFile jarFile = new JarFile( new File( basedir, "target/test-1.0.jar" ) );
+JarFile jarFile = new JarFile( new File( basedir, "test/target/test-1.0.jar" ) );
for ( String path : wanted )
{