Skip to content

Commit

Permalink
ecd-plugin#55 - Make sure plugin not fails on old version of Eclipse
Browse files Browse the repository at this point in the history
  • Loading branch information
helospark committed Nov 16, 2018
1 parent 12bbd64 commit c6794bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class JarClassExtractor
public static void extract( String archivePath, String packege, String className, boolean inner, String to )
throws IOException
{
if ( archivePath.endsWith( JRTUtil.JRT_FS_JAR ) )
if ( isClassInJrt( archivePath ) )
{
extractClassFromJrt( archivePath, packege, className, to );
}
Expand All @@ -43,6 +43,19 @@ public static void extract( String archivePath, String packege, String className
}
}

private static boolean isClassInJrt( String archivePath )
{
try
{
return archivePath.endsWith( JRTUtil.JRT_FS_JAR );
}
catch ( NoClassDefFoundError e )
{
// Compatible with pre-Oxygen Eclipse, where JRTUtil does not exist
return false;
}
}

private static void extractClassFromJrt( String archivePath, String packege, String className, String to )
throws IOException, FileNotFoundException
{
Expand All @@ -57,7 +70,6 @@ private static void extractClassFromJrt( String archivePath, String packege, Str
}
catch ( ClassFormatException e )
{
e.printStackTrace( );
throw new RuntimeException( "Unable to read JRT file", e );
}
}
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@

<repositories>
<repository>
<id>eclipse-juno</id>
<id>eclipse-oxygen</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/juno</url>
<url>http://download.eclipse.org/releases/oxygen</url>
</repository>
</repositories>

Expand Down

0 comments on commit c6794bc

Please sign in to comment.