Skip to content

Commit

Permalink
source attach: fix issues - add tests - remove jaxb/plexus/nexus/cvs
Browse files Browse the repository at this point in the history
  • Loading branch information
nbauma109 committed May 9, 2024
1 parent d6ac7c8 commit 2e94c09
Show file tree
Hide file tree
Showing 27 changed files with 347 additions and 342 deletions.
2 changes: 1 addition & 1 deletion org.sf.feeling.decompiler.jd/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</classpathentry>
<classpathentry exported="true" kind="lib" path="lib/bcel-6.7.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-lang3-3.12.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-io-2.16.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-io-2.16.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jd-util-1.1.16.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jd-core-1.2.26.jar"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
Expand Down
2 changes: 1 addition & 1 deletion org.sf.feeling.decompiler.jd/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Export-Package: org.sf.feeling.decompiler.jd.actions,
Bundle-ClassPath: .,
lib/bcel-6.7.0.jar,
lib/commons-lang3-3.12.0.jar,
lib/commons-io-2.16.0.jar,
lib/commons-io-2.16.1.jar,
lib/jd-util-1.1.16.jar,
lib/jd-core-1.2.26.jar
Automatic-Module-Name: org.sf.feeling.decompiler.jd
22 changes: 22 additions & 0 deletions org.sf.feeling.decompiler.source.attach.tests/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry exported="true" kind="lib" path="target/lib/commons-io-2.16.1.jar"/>
<classpathentry kind="src" output="bin" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
2 changes: 2 additions & 0 deletions org.sf.feeling.decompiler.source.attach.tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/bin/
/.settings/
34 changes: 34 additions & 0 deletions org.sf.feeling.decompiler.source.attach.tests/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.sf.feeling.decompiler.source.attach.tests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
32 changes: 32 additions & 0 deletions org.sf.feeling.decompiler.source.attach.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Enhanced Class Decompiler Source Attach
Bundle-SymbolicName: org.sf.feeling.decompiler.source.attach.tests;singleton:=true
Bundle-Version: 2024.3.1
Bundle-Activator: org.sf.feeling.decompiler.source.attach.SourceAttachPlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.expressions,
org.eclipse.jdt.core,
org.eclipse.jdt.ui,
org.eclipse.core.resources,
org.eclipse.core.databinding,
org.eclipse.jface.databinding,
org.eclipse.core.databinding.beans,
org.sf.feeling.decompiler,
org.apache.ant,
org.eclipse.jgit;resolution:=optional,
com.jcraft.jsch;resolution:=optional,
org.eclipse.m2e.jdt;resolution:=optional,
org.junit,
org.eclipse.jdt.junit4.runtime,
org.eclipse.jdt.junit.core,
org.eclipse.jdt.junit.runtime,
org.sf.feeling.decompiler.source.attach
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Bundle-Vendor: ECD Project Team
Bundle-ClassPath: target/lib/commons-io-2.16.1.jar,
.
Automatic-Module-Name: org.sf.feeling.decompiler.source.attach.tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
target/lib/,\

16 changes: 16 additions & 0 deletions org.sf.feeling.decompiler.source.attach.tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.github.ecd-plugin</groupId>
<artifactId>com.github.ecd-plugin.ecd</artifactId>
<version>2024.3.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>org.sf.feeling.decompiler.source.attach.tests</artifactId>
<packaging>eclipse-test-plugin</packaging>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package org.sf.feeling.decompiler.source.attach.finder;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.sf.feeling.decompiler.util.HashUtils;

public abstract class AbstractSourceCodeFinderTests {

protected void testFindCommonsIo(String serviceUrl) throws Exception {
String gavUrl = "https://repo1.maven.org/maven2/commons-io/commons-io/2.16.0/";
String fileName = "commons-io-2.16.0";
testFind(serviceUrl, gavUrl, fileName);
}

protected void testFindSlf4jNop(String serviceUrl) throws Exception {
String gavUrl = "https://repo1.maven.org/maven2/org/slf4j/slf4j-nop/2.1.0-alpha1/";
String fileName = "slf4j-nop-2.1.0-alpha1";
testFind(serviceUrl, gavUrl, fileName);
}

protected void testFindAsmUtil(String serviceUrl) throws Exception {
String gavUrl = "https://repo1.maven.org/maven2/org/ow2/asm/asm-util/9.7/";
String fileName = "asm-util-9.7";
testFind(serviceUrl, gavUrl, fileName);
}

protected void testFindJunit(String serviceUrl) throws Exception {
String gavUrl = "https://maven.alfresco.com/nexus/content/groups/public/junit/junit/4.11-20120805-1225/";
String fileName = "junit-4.11-20120805-1225";
testFind(serviceUrl, gavUrl, fileName);
}

protected void testFind(String serviceUrl, String gavUrl, String fileName)
throws MalformedURLException, IOException {
AbstractSourceCodeFinder directLinkSourceCodeFinder = newSourceCodeFinder(serviceUrl);
List<SourceFileResult> results = new ArrayList<>();
File downloadDir = new File("target");
File jarFile = new File(downloadDir, fileName + ".jar");
URL url = new URL(gavUrl + fileName + ".jar");
File srcFile = new File(downloadDir, fileName + "-sources.jar");
URL srcUrl = new URL(gavUrl + fileName + "-sources.jar");
FileUtils.copyURLToFile(url, jarFile);
FileUtils.copyURLToFile(srcUrl, srcFile);
if (jarFile.exists()) {
String sha1 = HashUtils.sha1Hash(jarFile);
directLinkSourceCodeFinder.find(jarFile.getAbsolutePath(), sha1, results);
assertNotNull(results);
assertEquals(1, results.size());
String expectedSha1 = HashUtils.sha1Hash(srcFile);
String actualSha1 = HashUtils.sha1Hash(new File(results.get(0).getSource()));
assertEquals(expectedSha1, actualSha1);
}
}

protected abstract AbstractSourceCodeFinder newSourceCodeFinder(String serviceUrl);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.sf.feeling.decompiler.source.attach.finder;

import static org.sf.feeling.decompiler.source.attach.finder.SourceCodeFinderFacade.HTTPS_REPO_GRAILS_ORG_GRAILS;

import org.junit.Test;

public class ArtifactorySourceCodeFinderTest extends AbstractSourceCodeFinderTests {

@Test
public void testFindGrails() throws Exception {
testFindAsmUtil(HTTPS_REPO_GRAILS_ORG_GRAILS);
}

@Override
protected AbstractSourceCodeFinder newSourceCodeFinder(String serviceUrl) {
return new ArtifactorySourceCodeFinder(serviceUrl);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.sf.feeling.decompiler.source.attach.finder;

import org.junit.Test;

public class MavenRepoSourceCodeFinderTest extends AbstractSourceCodeFinderTests {

@Test
public void testFindSlf4jNop() throws Exception {
testFindAsmUtil(null);
}

@Override
protected AbstractSourceCodeFinder newSourceCodeFinder(String serviceUrl) {
return new MavenRepoSourceCodeFinder();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.sf.feeling.decompiler.source.attach.finder;

import static org.sf.feeling.decompiler.source.attach.finder.SourceCodeFinderFacade.HTTPS_REPOSITORY_CLOUDERA_COM_ARTIFACTORY;

import org.junit.Test;

public class Nexus3SourceCodeFinderTest extends AbstractSourceCodeFinderTests {

@Test
public void testFindCloudera() throws Exception {
testFindCommonsIo(HTTPS_REPOSITORY_CLOUDERA_COM_ARTIFACTORY);
}

@Override
protected AbstractSourceCodeFinder newSourceCodeFinder(String serviceUrl) {
return new Nexus3SourceCodeFinder(serviceUrl);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.sf.feeling.decompiler.source.attach.finder;

import static org.sf.feeling.decompiler.source.attach.finder.SourceCodeFinderFacade.HTTPS_MAVEN_ALFRESCO_COM_NEXUS_INDEX_HTML;
import static org.sf.feeling.decompiler.source.attach.finder.SourceCodeFinderFacade.HTTPS_MAVEN_NUXEO_ORG_NEXUS_INDEX_HTML;
import static org.sf.feeling.decompiler.source.attach.finder.SourceCodeFinderFacade.HTTPS_NEXUS_XWIKI_ORG_NEXUS_INDEX_HTML;
import static org.sf.feeling.decompiler.source.attach.finder.SourceCodeFinderFacade.HTTPS_OSS_SONATYPE_ORG_INDEX_HTML;
import static org.sf.feeling.decompiler.source.attach.finder.SourceCodeFinderFacade.HTTPS_REPOSITORY_APACHE_ORG_INDEX_HTML;
import static org.sf.feeling.decompiler.source.attach.finder.SourceCodeFinderFacade.HTTPS_REPOSITORY_OW2_ORG_NEXUS_INDEX_HTML;

import org.junit.Test;

public class NexusSourceCodeFinderTest extends AbstractSourceCodeFinderTests {

@Test
public void testOSS() throws Exception {
testFindSlf4jNop(HTTPS_OSS_SONATYPE_ORG_INDEX_HTML);
}

@Test
public void testApache() throws Exception {
testFindCommonsIo(HTTPS_REPOSITORY_APACHE_ORG_INDEX_HTML);
}

@Test
public void testOW2() throws Exception {
testFindAsmUtil(HTTPS_REPOSITORY_OW2_ORG_NEXUS_INDEX_HTML);
}

@Test
public void testNuxeo() throws Exception {
testFindSlf4jNop(HTTPS_MAVEN_NUXEO_ORG_NEXUS_INDEX_HTML);
}

@Test
public void testAlfresco() throws Exception {
testFindJunit(HTTPS_MAVEN_ALFRESCO_COM_NEXUS_INDEX_HTML);
}

@Test
public void testXWiki() throws Exception {
testFindAsmUtil(HTTPS_NEXUS_XWIKI_ORG_NEXUS_INDEX_HTML);
}

@Override
protected AbstractSourceCodeFinder newSourceCodeFinder(String serviceUrl) {
return new NexusSourceCodeFinder(serviceUrl);
}
}
10 changes: 1 addition & 9 deletions org.sf.feeling.decompiler.source.attach/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry exported="true" kind="lib" path="lib/cvsclient-20060125.jar"/>
<classpathentry exported="true" kind="lib" path="lib/plexus-utils-4.0.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/nexus-indexer-lucene-model-2.14.20-02.jar"/>
<classpathentry exported="true" kind="lib" path="lib/nexus-restlet1x-model-2.15.1-02.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jaxb-api-2.3.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jaxb-impl-2.3.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jaxb-runtime-2.3.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/activation-1.1.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-io-2.16.0.jar"/>
<classpathentry exported="true" kind="lib" path="target/lib/commons-io-2.16.1.jar"/>
<classpathentry kind="src" output="bin" path="src">
<attributes>
<attribute name="optional" value="true"/>
Expand Down
10 changes: 1 addition & 9 deletions org.sf.feeling.decompiler.source.attach/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,7 @@ Require-Bundle: org.eclipse.ui,
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Bundle-Vendor: ECD Project Team
Bundle-ClassPath: lib/cvsclient-20060125.jar,
lib/plexus-utils-4.0.0.jar,
lib/nexus-indexer-lucene-model-2.14.20-02.jar,
lib/nexus-restlet1x-model-2.15.1-02.jar,
lib/jaxb-api-2.3.1.jar,
lib/jaxb-impl-2.3.8.jar,
lib/jaxb-runtime-2.3.3.jar,
lib/activation-1.1.1.jar,
lib/commons-io-2.16.0.jar,
Bundle-ClassPath: target/lib/commons-io-2.16.1.jar,
.
Export-Package: org.sf.feeling.decompiler.source.attach,
org.sf.feeling.decompiler.source.attach.attacher,
Expand Down
10 changes: 2 additions & 8 deletions org.sf.feeling.decompiler.source.attach/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
lib/,\
plugin.properties,\
lib/commons-io-2.16.0.jar,\
lib/nexus-indexer-lucene-model-2.14.20-02.jar,\
lib/jaxb-api-2.3.1.jar,\
lib/activation-1.1.1.jar,\
lib/jaxb-impl-2.3.8.jar,\
lib/jaxb-runtime-2.3.3.jar
target/lib/,\
plugin.properties

Loading

0 comments on commit 2e94c09

Please sign in to comment.