Plugin Development

53 views
Skip to first unread message

James Christian

unread,
Mar 21, 2015, 5:00:32 AM3/21/15
to scmma...@googlegroups.com
Hi, 
I want to develop a plugin in SCM-Manager, for that i have to store some values to repository, so in your context it'll be stored in repository.xml under <key><value> pair
But i dont know how to store and retrieve it with your Injection APIs

And I also want to create new XML files, like yours (e.g: repository.xml, users.xml)
So, i want to know how can i do that,
I already did learn what is Injection Dependency and what is Google Guice, but i really massed up with your APIs
Please Help me with this.

Sebastian Sdorra

unread,
Mar 25, 2015, 3:27:07 AM3/25/15
to scmma...@googlegroups.com
Hi,
You can get repositories from the RepositoryManager (https://docs.scm-manager.org/apidocs/latest/sonia/scm/repository/RepositoryManager.html). The RepositoryManager return Repository (https://docs.scm-manager.org/apidocs/latest/sonia/scm/repository/Repository.html) objects and you can fetch your key-value data from a repository with the getProperty method. Short example:

public class YourClass {

  @Inject
  public YourClass(RepositoryManager repositoryManager){
  Repository repository = repositoryManager.get("git", "yourgitrepository");
  String property = repository.getProperty("your-property");
  // do something with the property
  }

}

Storing configuration can be done with the Store API (https://docs.scm-manager.org/apidocs/latest/sonia/scm/store/package-summary.html). To store a single configuration file like users, repositories, etc you have to inject a StoreFactory (https://docs.scm-manager.org/apidocs/latest/sonia/scm/store/StoreFactory.html). From the factory you can retrieve a Store object (https://docs.scm-manager.org/apidocs/latest/sonia/scm/store/Store.html) which is able to store and load a JAXB (https://jaxb.java.net/guide/) class. Short example:

public class YourClass {

  private Store<YourConfig> store;

  @Inject
  public YourClass(StoreFactory storeFactory){
    // get the store from the factory
  store = storeFactory.get(YourConfig.class, "yours");
  }
  public void storeName(String name){
    YourConfig cfg = new YourConfig();
  cfg.setName("awesome name");
  store.set(cfg);
  }

}

@XmlRootElement
public class YourConfig {

  private String name;

  public void setName(String name){
    this.name = name;
  }

  public String getName(){
    return name;
  }

}

I hope this helps.

Sebastian




--
You received this message because you are subscribed to the Google Groups "scmmanager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scmmanager+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

James Christian

unread,
Mar 27, 2015, 10:10:41 AM3/27/15
to scmma...@googlegroups.com
Thank u very much, i already did that and it works really well,
But i got another question,
Your SCM-MANAGER has jgit and svnkit ,entirely work on JAVA, but it doesn't have javahg, then how i m going to use hg functions into my plugin
I want to user repository specific features such as what are the changesets?, and what are the commits and its messages?
So how i can do that with your API?
Do i have to use SCM specific jar api, for example : to get changeset for git repository, do i have to use jgit.jar API?
and for svn also??
How do i work same with mercurial?, do i have to load javahg dependency into my plugin project?

--
You received this message because you are subscribed to a topic in the Google Groups "scmmanager" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scmmanager/NWhxKUwvN68/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scmmanager+...@googlegroups.com.

Sebastian Sdorra

unread,
Mar 28, 2015, 8:10:16 AM3/28/15
to scmma...@googlegroups.com
Yo don't have to use repository type specific apis. There is a generic api which can be used to read svn,git and mercurial repositories. The main entry point for this api is RepositoryServiceFactory (https://docs.scm-manager.org/apidocs/latest/sonia/scm/repository/api/RepositoryServiceFactory.html). The javadoc of the service factory contains a simple example.

Sebastian

James Christian

unread,
Mar 29, 2015, 8:09:31 AM3/29/15
to scmma...@googlegroups.com
Sorry, i am asking a lot, but i can't use them, it has only little features, i want extra services such as push and pulll and commit,
and i tried with jGit, but at runtime it errors like classnotfoundexception : for jschException, but i already did that in maven

I tried other process like making classpath runtime, but it still cant access it,
I dont know how to do it, will you help me with it??

Sebastian Sdorra

unread,
Apr 13, 2015, 8:30:58 AM4/13/15
to scmma...@googlegroups.com
The jsch library is excluded in the core of scm-manager. Are you defined a direct dependency for jsch?

Sebastian

James Christian

unread,
Apr 13, 2015, 8:33:41 AM4/13/15
to scmma...@googlegroups.com
Yeah it is in core, but during plugin development it can't found, so i attached in classpath at your scm file and it worked.
I also mention you that i created one plug-in, how can i place in your plugin-market?

Sebastian Sdorra

unread,
Apr 18, 2015, 4:34:57 PM4/18/15
to scmma...@googlegroups.com
I've to check you plugin before it can be uploaded to the plugin center. Is your plugin opensource? Could you send me an link to the repository?

Sebastian
Reply all
Reply to author
Forward
0 new messages