Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant get this artifact from jitpack #22

Open
ai-for-java opened this issue May 17, 2023 · 4 comments
Open

Cant get this artifact from jitpack #22

ai-for-java opened this issue May 17, 2023 · 4 comments

Comments

@ai-for-java
Copy link

Hello,

How do I get this library in maven?
Could you please help?

This is what I have in my pom.xml:
<dependency> <groupId>com.github.serpapi</groupId> <artifactId>google-search-results-java</artifactId> <version>2.0.3</version> </dependency>

and:
<repositories> <repository> <id>jitpack.io</id> <url>https://www.jitpack.io</url> </repository> </repositories>

But I am always getting this error:
[ERROR] Failed to execute goal on project xxx: Could not resolve dependencies for project xxx: The following artifacts could not be resolved: com.github.serpapi:google-search-results-java:jar:2.0.3 (absent): Could not find artifact com.github.serpapi:google-search-results-java:jar:2.0.3 in jitpack.io (https://www.jitpack.io)

Thank you!

@HamaWhiteGG
Copy link

I have encountered the same issue and hope it can be resolved. Thank you.

@steelcityamir
Copy link

Any update on this? I am also experiencing this issue.

@HamaWhiteGG
Copy link

@CodebyAmir
Temporary Solution, I copied this code into my project langchain-java and pushed it to the Maven repository.
https://github.com/HamaWhiteGG/langchain-java

You can use the following Maven dependency:

<!-- https://mvnrepository.com/artifact/io.github.hamawhitegg/serpapi-client -->
<dependency>
    <groupId>io.github.hamawhitegg</groupId>
    <artifactId>serpapi-client</artifactId>
    <version>0.1.7</version>
</dependency>

Note that it requires Java 17 or later(Because my entire project is using Java 17.).

Here is an example code:

SerpApiSearch search = new GoogleSearch();

Map<String, String> parameter = new HashMap<>();
parameter.put("engine", "google");
parameter.put("google_domain", "google.com");
parameter.put("gl", "us");
parameter.put("hl", "en");
parameter.put("q", "High temperature in SF yesterday");

search.setParameter(parameter);

JsonObject result = search.getJson();
String searchResult = result.getAsJsonArray("organic_results")
  .get(0)
  .getAsJsonObject()
  .get("snippet")
  .getAsString();

System.out.println(searchResult);

The output is like:

See weather overview. San Francisco Temperature Yesterday. Maximum temperature yesterday: 69 °F (at 2:56 pm) Minimum temperature yesterday: 54 °F (at 4:56 am)

@ilyazub
Copy link

ilyazub commented Nov 14, 2023

@jvmvik, may #3 fix the artifacts downloading?

Edit:

@ai-for-java @CodebyAmir @HamaWhiteGG Follow the next steps to get artifacts from the jitpack:

  1. Add repository
<repositories>
  <repository>
      <id>jitpack.io</id>
      <url>https://jitpack.io</url>
  </repository>
</repositories>
  1. Add classifier to the dependency. (The package name contains the suffix: google-search-results-java-2.0.3-sources.jar.)
<dependency>
      <groupId>com.github.serpapi</groupId>
      <artifactId>google-search-results-java</artifactId>
      <version>2.0.3</version>
      <classifier>sources</classifier>
  </dependency>
  1. Compile the project following the Maven's magic
mvn clean install dependency:copy-dependencies package && javac -classpath .:target/dependency/* -d . $(find . -type f -name '*.java')`
  1. Run the code
java -cp .:target/dependency/* Main

Full example:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants