Using Sikuli in Maven projects

Asked by Robert Stagner

----------------------- solution for version 1.0.1 +
With version 1.0.1 and later, it is recommended, to use sikuli-java.jar with Java programming.

Use option 3 with setup and rename the resulting sikuli-java.jar to
sikuli-java-1.0.1.jar

and load it into your local Maven repository to use this dependency:
<dependency>
  <groupId>org.sikuli</groupId>
  <artifactId>sikuli-java</artifactId>
  <version>1.0.1</version>
</dependency>

-------------------------------------------------------------------------

the rest of this thread is related to RC3 !!

-------------------------------------------------------------------------

I am currently using Sikuli and really liking what I see. I have created a Maven project from within Eclipse. Within this project I've setup a POM file that leverages Cucumber-jvm as a dependency. I'm using Cucumber in conjunction with Sikuli to test a Windows app. So, far things are working well. When I want to run my tests, I do so from Eclipse using a JUnit test. I'm using the built-in Windows control panel application (control.exe) as the application under test. Here is a sample of my code

public class ControlPanelStepDefs {
 private String executable = "control.exe";
 private Screen scrn;
 private Match match;

 @Before
 public void setup() {
  scrn = new Screen();
 }

 @After
 public void teardown() {
  try {
   scrn.click("images/XButton.png");
  } catch (FindFailed e) {
   e.printStackTrace();
  }
 }

 @Given("^a user wants to access their Windows programs$")
 public void a_user_wants_to_access_their_Windows_programs() {
     // Express the Regexp above with the code you wish you had
 }

 @When("^the user opens the control panel$")
 public void the_user_opens_the_control_panel() {
  App.open(executable);
 }

 @When("^selects Programs from the computer's settings$")
 public void selects_Programs_from_the_computer_s_settings() {
     try {
   scrn.click("images/Programs.png");
  } catch (FindFailed e) {
   e.printStackTrace();
  }
 }

 @Then("^the Programs view is displayed$")
 public void the_Programs_view_is_displayed() {
     match = scrn.exists("images/DocLibrary.png");

     Assert.assertNotNull("FAILED assertion: the image, 'images/DocLibrary.png', does not exist.", match);
 }

}

When I run my test from the command-line using Maven like so

mvn clean test

It reports back that it cannot compile my code. I'm thinking that because the sikuli-script.jar file was added to the project as an external jar, it cannot compile the code because Maven can't find the jar in its local repositories. Has anyone encountered something like this. How would I run my project from the command line using Maven?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
RaiMan Edit question
Solved by:
Robert Stagner
Solved:
Last query:
Last reply:
Revision history for this message
anmol_bagga10 (anmol-bagga10) said :
#1

please include the sikuli dependecy for maven in pom.xml in maven project! i think that should solve your problem

Revision history for this message
anmol_bagga10 (anmol-bagga10) said :
#2

<dependency>

         <groupId>edu.mit.csail.uid.sikuli</groupId>

         <artifactId>sikuli-script</artifactId>

         <version>1.0-SNAPSHOT</version>

30

      </dependency>

Revision history for this message
anmol_bagga10 (anmol-bagga10) said :
#3

please delete 30, it has been entered wrongly

Revision history for this message
Robert Stagner (restagner) said :
#4

Great!! Let me give that a try. I'll let you know if it works.

Revision history for this message
Robert Stagner (restagner) said :
#5

I just added the dependency to my pom file (excluded 30) and it did not seem to work. Here is what Maven reported

1/25/12 11:48:34 AM PST: [WARN] The POM for edu.mit.csail.uid.sikuli:sikuli-script:jar:1.0.0-SNAPSHOT is missing, no dependency information available

And, I performed a search on Maven's central repository (http://search.maven.org) searching for "sikuli" and there were no results found. So, it would appear that the information is missing from Maven's repo. Any further information on how to solve this?

Revision history for this message
anmol_bagga10 (anmol-bagga10) said :
#6

try this man.
<dependency>

             <groupId>org.sikuli</groupId>

             <artifactId>sikuli-script</artifactId>
             <version>0.10.2</version>

         </dependency>

can u show me ur pom file..

Revision history for this message
anmol_bagga10 (anmol-bagga10) said :
#7

its 1 30 am in india and m not in office other wise i would have given u the right dependency in a flash.. aah m too sleepy also.
good night!!

Revision history for this message
RaiMan (raimund-hocke) said :
#8

Mavan's central repository will not answer on any Sikuli stuff, since it is not there. This must be handled in your local repository.

To solve a dependency like the above, I think you need a structure containing sikuli-script.jar in your local repository like
-- sikuli-script
---- sikuli-script
------ X-1.0rc3
-------- sikuli-script.jar

with this dependency in your pom:
<dependency>
      <groupId>org.sikuli</groupId>
      <artifactId>sikuli-script</artifactId>
      <version>X-1.0rc3</version>
</dependency>

Revision history for this message
Robert Stagner (restagner) said :
#9

@RaiMan

Ok, I'll see what we can do to achieve this -- I'm not all that familiar with Maven. I'll see if our developers or release engineer can help me out with this.

Revision history for this message
Robert Stagner (restagner) said :
#10

@RaiMan

I worked with one of our developers and placed a copy of the jar file within our local repo (artifactory). It works just fine. Thanks.

Revision history for this message
anmol_bagga10 (anmol-bagga10) said :
#11

What you can do is make a folder in your project say lib and put the sikuli-script.jar in that.
and include this dependency in ur pom file
<dependency>
        <groupId>org.sikuli</groupId>
        <artifactId>sikuli-api</artifactId>
        <version>1.0.2</version>
     <systemPath>${project.basedir}\lib\sikuli-script.jar</systemPath>
        <scope>system</scope>
</dependency>
I have checked this and this works fine.
Regards,
Anmol Bagga

Revision history for this message
emrah kara (emrah-karakoc) said :
#12

what is the dependency for the new Sikuli version, which is 1.0.1 ?
Would it be correct this way?

<dependency>
  <groupId>org.sikuli</groupId>
  <artifactId>sikuli-script</artifactId>
  <version>1.0.1</version>
</dependency>

Revision history for this message
RaiMan (raimund-hocke) said :
#13

@ emra
With version 1.0.1 and later, it is recommended, to use sikuli-java.jar with Java programming.

Use option 3 with setup and rename the resulting sikuli-java.jar to
sikuli-java-1.0.1.jar

and load it into your local Maven repository to use this dependency:
<dependency>
  <groupId>org.sikuli</groupId>
  <artifactId>sikuli-java</artifactId>
  <version>1.0.1</version>
</dependency>

Revision history for this message
emrah kara (emrah-karakoc) said :
#14

Thanks for your answer! it helped me alot :)

Revision history for this message
chandan (chandandeep-er) said :
#15

@RaiMan (raimund-hocke)

Hi ,
I am also facing the same issue. I am using build.gradle for dependency. problem is this i cant go with the approach having the jar files in project and then providing the path of jar files. is there any way out to write this in build.gradle

error is like
(path)java:7: error: package org.sikuli.script does not exist
import org.sikuli.script.FindFailed;

please let me know the way to write the dpendency in build.gradle for sikuli-script.

Thanks in advance