Permalink
Browse files

added osgi manifest

  • Loading branch information...
1 parent b656f8a commit 59075275d2a76f44014951db216ec56acd346f2b @pulse00 committed Sep 6, 2012
View
@@ -27,5 +27,6 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
View
@@ -15,9 +15,20 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>
View
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: composer
+Bundle-SymbolicName: composer
+Bundle-Version: 1.0.0.qualifier
+Export-Package: com.dubture.composer;uses:="com.google.gson",
+ com.dubture.composer.core.packagist;uses:="com.dubture.composer",
+ com.dubture.composer.test;uses:="junit.framework"
+Require-Bundle: com.google.gson;bundle-version="2.1.0",
+ org.apache.commons.httpclient;bundle-version="3.1.0"
View
@@ -0,0 +1,5 @@
+source.. = src/main/java/,\
+ src/main/resources/,\
+ src/test/java/
+bin.includes = META-INF/,\
+ .
View
19 pom.xml
@@ -38,4 +38,23 @@
<url>http://travis-ci.org/#!/pulse00/Composer-Java-Bindings</url>
</ciManagement>
<url>https://github.com/pulse00/Composer-Java-Bindings</url>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>com.dubture.composer.Searcher</mainClass>
+ </manifest>
+ </archive>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
@@ -26,9 +26,10 @@
* @author Robert Gruendler <r.gruendler@gmail.com>
*
*/
-public class PHPPackage
+public class PHPPackage implements PackageInterface
{
- public String name;
+
+ public String name;
public String type;
public String description;
public String homepage;
@@ -100,25 +101,17 @@ public static Gson getBuilder()
}
- /**
- * Returns the first available version by default.
- * TODO: check the specs about how to resolve this ...
- *
- * @return String the default version
- */
+ /* (non-Javadoc)
+ * @see com.dubture.composer.PackageInterface#getDefaultVersion()
+ */
public String getDefaultVersion()
{
return versions.keySet().iterator().next();
}
- /**
- *
- * Returns the package name suitable for passing it to "composer.phar require"
- *
- * @param version
- * @return String the package/version combination
- * @throws Exception
- */
+ /* (non-Javadoc)
+ * @see com.dubture.composer.PackageInterface#getPackageName(java.lang.String)
+ */
public String getPackageName(String version) throws Exception
{
if (!versions.containsKey(version)) {
@@ -140,4 +133,129 @@ public String getPackageName(String version) throws Exception
public PHPPackage phpPackage;
}
+
+
+ /* (non-Javadoc)
+ * @see com.dubture.composer.PackageInterface#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.dubture.composer.PackageInterface#getType()
+ */
+ public String getType() {
+ return type;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.dubture.composer.PackageInterface#getDescription()
+ */
+ public String getDescription() {
+ return description;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.dubture.composer.PackageInterface#getHomepage()
+ */
+ public String getHomepage() {
+ return homepage;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.dubture.composer.PackageInterface#getUrl()
+ */
+ public String getUrl() {
+ return url;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.dubture.composer.PackageInterface#getFullPath()
+ */
+ public String getFullPath() {
+ return fullPath;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.dubture.composer.PackageInterface#getRequire()
+ */
+ public Map<String, String> getRequire() {
+ return require;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.dubture.composer.PackageInterface#getRequireDev()
+ */
+ public Map<String, String> getRequireDev() {
+ return requireDev;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.dubture.composer.PackageInterface#getAutoload()
+ */
+ public Autoload getAutoload() {
+ return autoload;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.dubture.composer.PackageInterface#getTargetDir()
+ */
+ public String getTargetDir() {
+ return targetDir;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.dubture.composer.PackageInterface#getVersion()
+ */
+ public String getVersion() {
+ return version;
+ }
+
+
+ public String getVersionNormalized() {
+ return versionNormalized;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.dubture.composer.PackageInterface#getLicense()
+ */
+ public License getLicense() {
+ return license;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.dubture.composer.PackageInterface#getKeywords()
+ */
+ public String[] getKeywords() {
+ return keywords;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.dubture.composer.PackageInterface#getVersions()
+ */
+ public Map<String, PHPPackage> getVersions() {
+ return versions;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.dubture.composer.PackageInterface#getAuthors()
+ */
+ public Author[] getAuthors() {
+ return authors;
+ }
}
@@ -0,0 +1,55 @@
+package com.dubture.composer;
+
+import java.util.Map;
+
+public interface PackageInterface {
+
+ /**
+ * Returns the first available version by default.
+ * TODO: check the specs about how to resolve this ...
+ *
+ * @return String the default version
+ */
+ public abstract String getDefaultVersion();
+
+ /**
+ *
+ * Returns the package name suitable for passing it to "composer.phar require"
+ *
+ * @param version
+ * @return String the package/version combination
+ * @throws Exception
+ */
+ public abstract String getPackageName(String version) throws Exception;
+
+ public abstract String getName();
+
+ public abstract String getType();
+
+ public abstract String getDescription();
+
+ public abstract String getHomepage();
+
+ public abstract String getUrl();
+
+ public abstract String getFullPath();
+
+ public abstract Map<String, String> getRequire();
+
+ public abstract Map<String, String> getRequireDev();
+
+ public abstract Autoload getAutoload();
+
+ public abstract String getTargetDir();
+
+ public abstract String getVersion();
+
+ public abstract License getLicense();
+
+ public abstract String[] getKeywords();
+
+ public abstract Map<String, PHPPackage> getVersions();
+
+ public abstract Author[] getAuthors();
+
+}
@@ -15,6 +15,7 @@
import com.dubture.composer.ComposerConstants;
import com.dubture.composer.PHPPackage;
+import com.dubture.composer.PackageInterface;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.stream.JsonReader;
@@ -26,20 +27,20 @@ public SearchResultDownloader()
super(ComposerConstants.searchURL);
}
- public List<? extends PHPPackage> searchPackages(String query) throws IOException
+ public List<PackageInterface> searchPackages(String query) throws IOException
{
- List<PHPPackage> packages = new ArrayList<PHPPackage>();
+ List<PackageInterface> packages = new ArrayList<PackageInterface>();
setUrl(String.format(ComposerConstants.searchURL, query));
SearchResult result = loadPackages(getUrl());
- packages = result.results;
-
int limit = 5;
int current = 0;
//TODO: implement paging results
while(result.next != null && result.next.length() > 0) {
result = loadPackages(result.next);
+
+ System.err.println("search has " + result.total + " hits");
if ( (result.results != null && result.results.size() == 0) || result.next == null || current++ > limit) {
break;
}
@@ -52,6 +53,7 @@ public SearchResultDownloader()
protected SearchResult loadPackages(String url) throws IOException {
setUrl(url);
+ System.err.println("downloading packages from " + url);
InputStream resource = downloadResource();
InputStreamReader reader = new InputStreamReader(resource);
JsonReader jsonReader = new JsonReader(reader);
@@ -7,13 +7,15 @@
******************************************************************************/
package com.dubture.composer.test;
+import java.io.IOException;
import java.util.List;
import junit.framework.TestCase;
import org.junit.Test;
import com.dubture.composer.PHPPackage;
+import com.dubture.composer.PackageInterface;
import com.dubture.composer.core.packagist.PackageDownloader;
import com.dubture.composer.core.packagist.SearchResultDownloader;
@@ -42,21 +44,26 @@ public void testPackage() {
public void testSearch() {
try {
- SearchResultDownloader downloader = new SearchResultDownloader();
- List<? extends PHPPackage> packages = downloader.searchPackages("html");
-
- assertNotNull(packages);
- assertTrue(packages.size() > 0);
-
- for (PHPPackage phpPackage : packages) {
- assertNotNull(phpPackage);
- assertNotNull(phpPackage.name);
- assertNotNull(phpPackage.description);
- }
-
+ assertSearchResult("html");
+ assertSearchResult("react");
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
+
+ protected void assertSearchResult(String query) throws IOException {
+
+ SearchResultDownloader downloader = new SearchResultDownloader();
+ List<PackageInterface> packages = downloader.searchPackages(query);
+
+ assertNotNull(packages);
+ assertTrue(packages.size() > 0);
+
+ for (PackageInterface phpPackage : packages) {
+ assertNotNull(phpPackage);
+ assertNotNull(phpPackage.getName());
+ assertNotNull(phpPackage.getDescription());
+ }
+ }
}

0 comments on commit 5907527

Please sign in to comment.