Пример #1
0
  public void setup() {
    if (hasDotGit()) {
      LOGGER.info("Git is already configured");
      return;
    }
    if (person == null) {
      person = new PersonIdent("Roo Git Add-On", "*****@*****.**");
    }
    try {
      final String repositoryPath = pathResolver.getFocusedIdentifier(Path.ROOT, Constants.DOT_GIT);
      final Repository repository =
          new FileRepositoryBuilder().readEnvironment().setGitDir(new File(repositoryPath)).build();
      repository.create();
    } catch (final Exception e) {
      throw new IllegalStateException("Could not initialize Git repository", e);
    }
    setConfig("user", "name", person.getName());
    setConfig("user", "email", person.getEmailAddress());

    setConfig("remote \"origin\"", "fetch", "+refs/heads/*:refs/remotes/origin/*");
    setConfig("branch \"master\"", "remote", "origin");
    setConfig("branch \"master\"", "merge", "refs/heads/master");

    final String gitIgnore =
        pathResolver.getFocusedIdentifier(Path.ROOT, Constants.GITIGNORE_FILENAME);

    if (!fileManager.exists(gitIgnore)) {
      InputStream inputStream = null;
      OutputStream outputStream = null;
      try {
        inputStream = FileUtils.getInputStream(getClass(), "gitignore-template");
        outputStream = fileManager.createFile(gitIgnore).getOutputStream();
        IOUtils.copy(inputStream, outputStream);
      } catch (final IOException e) {
        throw new IllegalStateException(
            "Could not install " + Constants.GITIGNORE_FILENAME + " file in project", e);
      } finally {
        IOUtils.closeQuietly(inputStream);
        IOUtils.closeQuietly(outputStream);
      }
    }
  }
Пример #2
0
 public InputStream getMessageBundle() {
   return FileUtils.getInputStream(getClass(), "messages_it.properties");
 }
Пример #3
0
 public InputStream getFlagGraphic() {
   return FileUtils.getInputStream(getClass(), "it.png");
 }