本文整理汇总了Java中org.apache.maven.plugins.shade.resource.ResourceTransformer类的典型用法代码示例。如果您正苦于以下问题:Java ResourceTransformer类的具体用法?Java ResourceTransformer怎么用?Java ResourceTransformer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResourceTransformer类属于org.apache.maven.plugins.shade.resource包,在下文中一共展示了ResourceTransformer类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createShadeSourcesRequest
import org.apache.maven.plugins.shade.resource.ResourceTransformer; //导入依赖的package包/类
private ShadeRequest createShadeSourcesRequest( Set<File> testArtifacts, File testJar, List<Filter> filters,
List<Relocator> relocators,
List<ResourceTransformer> resourceTransformers )
{
ShadeRequest shadeSourcesRequest =
shadeRequest( testArtifacts, testJar, filters, relocators, resourceTransformers, this.consistentDates,
this.disableJarFileVerification );
shadeSourcesRequest.setShadeSourcesContent( shadeSourcesContent );
return shadeSourcesRequest;
}
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:11,代码来源:ShadeMojo.java
示例2: getResourceTransformers
import org.apache.maven.plugins.shade.resource.ResourceTransformer; //导入依赖的package包/类
private List<ResourceTransformer> getResourceTransformers()
{
if ( transformers == null )
{
return Collections.emptyList();
}
return Arrays.asList( transformers );
}
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:10,代码来源:ShadeMojo.java
示例3: testShaderWithStaticInitializedClass
import org.apache.maven.plugins.shade.resource.ResourceTransformer; //导入依赖的package包/类
public void testShaderWithStaticInitializedClass()
throws Exception
{
Shader s = newShader();
Set<File> set = new LinkedHashSet<File>();
set.add( new File( "src/test/jars/test-artifact-1.0-SNAPSHOT.jar" ) );
List<Relocator> relocators = new ArrayList<Relocator>();
relocators.add( new SimpleRelocator( "org.apache.maven.plugins.shade", null, null, null ) );
List<ResourceTransformer> resourceTransformers = new ArrayList<ResourceTransformer>();
List<Filter> filters = new ArrayList<Filter>();
File file = new File( "target/testShaderWithStaticInitializedClass.jar" );
ShadeRequest shadeRequest = new ShadeRequest();
shadeRequest.setJars( set );
shadeRequest.setUberJar( file );
shadeRequest.setFilters( filters );
shadeRequest.setRelocators( relocators );
shadeRequest.setResourceTransformers( resourceTransformers );
s.shade( shadeRequest );
URLClassLoader cl = new URLClassLoader( new URL[] { file.toURI().toURL() } );
Class<?> c = cl.loadClass( "hidden.org.apache.maven.plugins.shade.Lib" );
Object o = c.newInstance();
assertEquals( "foo.bar/baz", c.getDeclaredField( "CONSTANT" ).get( o ) );
}
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:34,代码来源:DefaultShaderTest.java
示例4: testShaderWithExclusions
import org.apache.maven.plugins.shade.resource.ResourceTransformer; //导入依赖的package包/类
public void testShaderWithExclusions()
throws Exception
{
File jarFile = new File( getBasedir(), "target/unit/foo-bar.jar" );
Shader s = (Shader) lookup( Shader.ROLE, "default" );
Set<File> set = new LinkedHashSet<File>();
set.add( new File( getBasedir(), "src/test/jars/test-artifact-1.0-SNAPSHOT.jar" ) );
List<Relocator> relocators = new ArrayList<Relocator>();
relocators.add( new SimpleRelocator( "org.codehaus.plexus.util", "hidden", null, Arrays.asList(
"org.codehaus.plexus.util.xml.Xpp3Dom", "org.codehaus.plexus.util.xml.pull.*") ) );
List<ResourceTransformer> resourceTransformers = new ArrayList<ResourceTransformer>();
List<Filter> filters = new ArrayList<Filter>();
ShadeRequest shadeRequest = new ShadeRequest();
shadeRequest.setJars( set );
shadeRequest.setUberJar( jarFile );
shadeRequest.setFilters( filters );
shadeRequest.setRelocators( relocators );
shadeRequest.setResourceTransformers( resourceTransformers );
s.shade( shadeRequest );
ClassLoader cl = new URLClassLoader( new URL[]{ jarFile.toURI().toURL() } );
Class<?> c = cl.loadClass( "org.apache.maven.plugins.shade.Lib" );
Field field = c.getDeclaredField( "CLASS_REALM_PACKAGE_IMPORT" );
assertEquals( "org.codehaus.plexus.util.xml.pull", field.get( null ) );
Method method = c.getDeclaredMethod( "getClassRealmPackageImport", new Class[0] );
assertEquals( "org.codehaus.plexus.util.xml.pull", method.invoke( null, new Object[0] ) );
}
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:37,代码来源:ShadeMojoTest.java
示例5: resourceTransformed
import org.apache.maven.plugins.shade.resource.ResourceTransformer; //导入依赖的package包/类
private boolean resourceTransformed(List<ResourceTransformer> resourceTransformers, String name, InputStream is,
List<Relocator> relocators)
throws IOException {
for (ResourceTransformer transformer : resourceTransformers) {
if (transformer.canTransformResource(name)) {
getLogger().debug("Transforming " + name + " using " + transformer.getClass().getName());
transformer.processResource(name, is, relocators);
return true;
}
}
return false;
}
开发者ID:immutables,项目名称:maven-shade-plugin,代码行数:14,代码来源:DefaultShader.java
示例6: getResourceTransformers
import org.apache.maven.plugins.shade.resource.ResourceTransformer; //导入依赖的package包/类
public List<ResourceTransformer> getResourceTransformers()
{
return resourceTransformers;
}
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:5,代码来源:ShadeRequest.java
示例7: shadeJars
import org.apache.maven.plugins.shade.resource.ResourceTransformer; //导入依赖的package包/类
private void shadeJars( ShadeRequest shadeRequest, Set<String> resources, List<ResourceTransformer> transformers,
RelocatorRemapper remapper, JarOutputStream jos, Multimap<String, File> duplicates )
throws IOException, MojoExecutionException
{
for ( File jar : shadeRequest.getJars() )
{
getLogger().debug( "Processing JAR " + jar );
List<Filter> jarFilters = getFilters( jar, shadeRequest.getFilters() );
JarFile jarFile = newJarFile( jar, shadeRequest.isDisableJarFileVerification() );
try
{
for ( Enumeration<JarEntry> j = jarFile.entries(); j.hasMoreElements(); )
{
JarEntry entry = j.nextElement();
String name = entry.getName();
if ( "META-INF/INDEX.LIST".equals( name ) )
{
// we cannot allow the jar indexes to be copied over or the
// jar is useless. Ideally, we could create a new one
// later
continue;
}
if ( !entry.isDirectory() && !isFiltered( jarFilters, name ) )
{
shadeSingleJar( shadeRequest, resources, transformers, remapper, jos, duplicates, jar, jarFile,
entry, name );
}
}
}
finally
{
jarFile.close();
}
}
}
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:45,代码来源:DefaultShader.java
示例8: shadeSingleJar
import org.apache.maven.plugins.shade.resource.ResourceTransformer; //导入依赖的package包/类
private void shadeSingleJar( ShadeRequest shadeRequest, Set<String> resources,
List<ResourceTransformer> transformers, RelocatorRemapper remapper,
JarOutputStream jos, Multimap<String, File> duplicates, File jar, JarFile jarFile,
JarEntry entry, String name )
throws IOException, MojoExecutionException
{
InputStream in = null;
try
{
in = jarFile.getInputStream( entry );
String mappedName = remapper.map( name );
int idx = mappedName.lastIndexOf( '/' );
if ( idx != -1 )
{
// make sure dirs are created
String dir = mappedName.substring( 0, idx );
if ( !resources.contains( dir ) )
{
addDirectory( resources, jos, dir, shadeRequest.isConsistentDates() );
}
}
if ( name.endsWith( ".class" ) )
{
duplicates.put( name, jar );
addRemappedClass( remapper, jos, jar, name, in, shadeRequest.isConsistentDates() );
}
else if ( shadeRequest.isShadeSourcesContent() && name.endsWith( ".java" ) )
{
// Avoid duplicates
if ( resources.contains( mappedName ) )
{
return;
}
addJavaSource( resources, jos, mappedName, in, shadeRequest.getRelocators(),
shadeRequest.isConsistentDates() );
}
else
{
if ( !resourceTransformed( transformers, mappedName, in, shadeRequest.getRelocators() ) )
{
// Avoid duplicates that aren't accounted for by the resource transformers
if ( resources.contains( mappedName ) )
{
return;
}
addResource( resources, jos, mappedName, entry.getTime(), shadeRequest.isConsistentDates(), in );
}
}
in.close();
in = null;
}
finally
{
IOUtil.close( in );
}
}
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:62,代码来源:DefaultShader.java
示例9: goThroughAllJarEntriesForManifestTransformer
import org.apache.maven.plugins.shade.resource.ResourceTransformer; //导入依赖的package包/类
private void goThroughAllJarEntriesForManifestTransformer( ShadeRequest shadeRequest, Set<String> resources,
ResourceTransformer manifestTransformer,
JarOutputStream jos )
throws IOException
{
if ( manifestTransformer != null )
{
for ( File jar : shadeRequest.getJars() )
{
JarFile jarFile = newJarFile( jar, shadeRequest.isConsistentDates() );
try
{
for ( Enumeration<JarEntry> en = jarFile.entries(); en.hasMoreElements(); )
{
JarEntry entry = en.nextElement();
String resource = entry.getName();
if ( manifestTransformer.canTransformResource( resource ) )
{
resources.add( resource );
InputStream inputStream = jarFile.getInputStream( entry );
try
{
manifestTransformer.processResource( resource, inputStream,
shadeRequest.getRelocators() );
}
finally
{
inputStream.close();
}
break;
}
}
}
finally
{
jarFile.close();
}
}
if ( manifestTransformer.hasTransformedResource() )
{
manifestTransformer.modifyOutputStream( jos, shadeRequest.isConsistentDates() );
}
}
}
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:45,代码来源:DefaultShader.java
示例10: testShaderWithRelocatedClassname
import org.apache.maven.plugins.shade.resource.ResourceTransformer; //导入依赖的package包/类
public void testShaderWithRelocatedClassname()
throws Exception
{
DefaultShader s = newShader();
Set<File> set = new LinkedHashSet<File>();
set.add( new File( "src/test/jars/test-project-1.0-SNAPSHOT.jar" ) );
set.add( new File( "src/test/jars/plexus-utils-1.4.1.jar" ) );
List<Relocator> relocators = new ArrayList<Relocator>();
relocators.add( new SimpleRelocator( "org/codehaus/plexus/util/", "_plexus/util/__", null,
Arrays.<String> asList() ) );
List<ResourceTransformer> resourceTransformers = new ArrayList<ResourceTransformer>();
resourceTransformers.add( new ComponentsXmlResourceTransformer() );
List<Filter> filters = new ArrayList<Filter>();
File file = new File( "target/foo-relocate-class.jar" );
ShadeRequest shadeRequest = new ShadeRequest();
shadeRequest.setJars( set );
shadeRequest.setUberJar( file );
shadeRequest.setFilters( filters );
shadeRequest.setRelocators( relocators );
shadeRequest.setResourceTransformers( resourceTransformers );
s.shade( shadeRequest );
URLClassLoader cl = new URLClassLoader( new URL[] { file.toURI().toURL() } );
Class<?> c = cl.loadClass( "_plexus.util.__StringUtils" );
// first, ensure it works:
Object o = c.newInstance();
assertEquals( "", c.getMethod( "clean", String.class ).invoke( o, (String) null ) );
// now, check that its source file was rewritten:
final String[] source = { null };
final ClassReader classReader = new ClassReader( cl.getResourceAsStream( "_plexus/util/__StringUtils.class" ) );
classReader.accept( new ClassVisitor( Opcodes.ASM4 )
{
@Override
public void visitSource( String arg0, String arg1 )
{
super.visitSource( arg0, arg1 );
source[0] = arg0;
}
}, ClassReader.SKIP_CODE );
assertEquals( "__StringUtils.java", source[0] );
}
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:54,代码来源:DefaultShaderTest.java
示例11: shaderWithPattern
import org.apache.maven.plugins.shade.resource.ResourceTransformer; //导入依赖的package包/类
private void shaderWithPattern( String shadedPattern, File jar, String[] excludes )
throws Exception
{
DefaultShader s = newShader();
Set<File> set = new LinkedHashSet<File>();
set.add( new File( "src/test/jars/test-project-1.0-SNAPSHOT.jar" ) );
set.add( new File( "src/test/jars/plexus-utils-1.4.1.jar" ) );
List<Relocator> relocators = new ArrayList<Relocator>();
relocators.add( new SimpleRelocator( "org/codehaus/plexus/util", shadedPattern, null, Arrays.asList( excludes ) ) );
List<ResourceTransformer> resourceTransformers = new ArrayList<ResourceTransformer>();
resourceTransformers.add( new ComponentsXmlResourceTransformer() );
List<Filter> filters = new ArrayList<Filter>();
ShadeRequest shadeRequest = new ShadeRequest();
shadeRequest.setJars( set );
shadeRequest.setUberJar( jar );
shadeRequest.setFilters( filters );
shadeRequest.setRelocators( relocators );
shadeRequest.setResourceTransformers( resourceTransformers );
s.shade( shadeRequest );
}
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:31,代码来源:DefaultShaderTest.java
示例12: shaderWithPattern
import org.apache.maven.plugins.shade.resource.ResourceTransformer; //导入依赖的package包/类
public void shaderWithPattern( String shadedPattern, File jar )
throws Exception
{
Shader s = (Shader) lookup( Shader.ROLE );
Set<File> set = new LinkedHashSet<File>();
set.add( new File( getBasedir(), "src/test/jars/test-project-1.0-SNAPSHOT.jar" ) );
set.add( new File( getBasedir(), "src/test/jars/plexus-utils-1.4.1.jar" ) );
List<Relocator> relocators = new ArrayList<Relocator>();
relocators.add( new SimpleRelocator( "org/codehaus/plexus/util", shadedPattern, null, Arrays.asList(
"org/codehaus/plexus/util/xml/Xpp3Dom", "org/codehaus/plexus/util/xml/pull.*") ) );
List<ResourceTransformer> resourceTransformers = new ArrayList<ResourceTransformer>();
resourceTransformers.add( new ComponentsXmlResourceTransformer() );
List<Filter> filters = new ArrayList<Filter>();
ShadeRequest shadeRequest = new ShadeRequest();
shadeRequest.setJars( set );
shadeRequest.setUberJar( jar );
shadeRequest.setFilters( filters );
shadeRequest.setRelocators( relocators );
shadeRequest.setResourceTransformers( resourceTransformers );
s.shade( shadeRequest );
}
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:32,代码来源:ShadeMojoTest.java
示例13: setResourceTransformers
import org.apache.maven.plugins.shade.resource.ResourceTransformer; //导入依赖的package包/类
/**
* The transformers.
*
* @param resourceTransformers
*/
public void setResourceTransformers( List<ResourceTransformer> resourceTransformers )
{
this.resourceTransformers = resourceTransformers;
}
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:10,代码来源:ShadeRequest.java
注:本文中的org.apache.maven.plugins.shade.resource.ResourceTransformer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论