Skip to content

Commit

Permalink
Version 0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lcbarcellos committed Mar 3, 2020
2 parents f5dc95b + a83ece1 commit f9c4f82
Show file tree
Hide file tree
Showing 10 changed files with 652 additions and 125 deletions.
102 changes: 88 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,30 @@

<groupId>br.ufes.inf.nemo</groupId>
<artifactId>ufo-protege-plugin</artifactId>
<version>0.0.1</version>
<version>0.0.2</version>
<packaging>bundle</packaging>

<name>UFO Protégé Plugin</name>
<description>Plugin for UFO semantic rules validation</description>
<scm>
<url>https://github.com/${github.repo.folder}</url>
<connection>scm:git:https://github.com/${github.repo.folder}.git</connection>
<developerConnection>scm:git:ssh://github.com/${github.repo.folder}.git</developerConnection>
</scm>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<github.organization>nemo-ufes</github.organization>
<github.repo.name>ufo-protege-plugin</github.repo.name>
<github.repo.folder>${github.organization}/${github.repo.name}</github.repo.folder>

<protege.run.config>${protege.home}/config.xml</protege.run.config>
<protege.osgi></protege.osgi>
<protege.launcher></protege.launcher>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<ufo-protege-plugin.update-url>https://raw.githubusercontent.com/nemo-ufes/ufo-protege-plugin/update/update.properties</ufo-protege-plugin.update-url>
</properties>

<dependencies>
Expand Down Expand Up @@ -87,9 +96,60 @@
</Include-Resource>
<Export-Package/>
<Embed-Dependency>rsyntaxtextarea,rhino</Embed-Dependency>
<Update-Url>${ufo-protege-plugin.update-url}</Update-Url>
</instructions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-update-files</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/update</outputDirectory>
<resources>
<resource>
<directory>${basedir}/scripts</directory>
<filtering>true</filtering>
<includes>
<include>release.sh</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>restore-permission</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<chmod file="${project.build.directory}/update/release.sh" perm="755"/>
<propertyfile file="${project.build.directory}/update/update.properties">
<entry key="id" value="${project.groupId}.${project.artifactId}"/>
<entry key="version" value="${project.version}"/>
<entry key="download" value="https://github.com/${github.repo.folder}/releases/download/v${project.version}/${project.build.finalName}.jar"/>
<entry key="name" value="${project.name}"/>
</propertyfile>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
Expand Down Expand Up @@ -117,26 +177,40 @@
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>remove-other-versions</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<delete>
<fileset dir="${protege.home}/plugins" includes="${project.groupId}.*.jar"/>
</delete>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>copy-file</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${protege.home}/plugins</outputDirectory>
<resources>
<resource>
<directory>${project.build.directory}</directory>
<filtering>false</filtering>
<includes>
<include>${project.build.finalName}.jar</include>
</includes>
</resource>
</resources>
<sourceFile>${project.build.directory}/${project.build.finalName}.jar</sourceFile>
<destinationFile>${protege.home}/plugins/${project.groupId}.${project.build.finalName}.jar</destinationFile>
</configuration>
</execution>
</executions>
Expand Down
74 changes: 74 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

github() {
curl --location \
https://api.github.com/repos/${github.repo.folder}/releases \
--header "Content-Type: application/json" \
--header "Authorization: bearer ${github.token}" \
--data "$1"
}

create_tag() {
git tag "v${project.version}"
git push origin "v${project.version}"
}

create_release() {
RELEASE_DATA=$( github '{
"tag_name": "v${project.version}",
"name": "Version ${project.version}",
"draft": false,
"prerelease": true
}' )
UPLOAD_URL_TEMPLATE=$( echo "$RELEASE_DATA" | jq -r '.upload_url' )
}

upload_file() {
UPLOAD_BASE_URL="${UPLOAD_URL_TEMPLATE/\{*\}/}"
UPLOAD_URL="${UPLOAD_BASE_URL}?name=${project.build.finalName}.jar"
UPLOAD_DATA=$( curl --location \
"${UPLOAD_URL}" \
--header "Content-Type: application/java-archive" \
--header "Authorization: bearer ${github.token}" \
--data-binary "@${project.build.directory}/${project.build.finalName}.jar"
)
DOWNLOAD_URL=$( echo "$UPLOAD_DATA" | jq -r '.browser_download_url' )
}

push_update() {

local WORKTREE="update-worktree"

cd "$( dirname "$0" )"
if [ -d "$WORKTREE" ]
then
rm -fr "$WORKTREE"
fi
git clone \
--no-tags \
--branch update \
--single-branch "${basedir}" \
"${WORKTREE}"
cp update.properties "${WORKTREE}"
cd "${WORKTREE}"

git add update.properties
git commit -m "Set update file to version ${project.version}"
git remote add github git@github.com:${github.repo.folder}.git
git push origin update:update
git push github update:update
}

run_command() {
local CMD="$1"
shift
echo === "$@" =======================
"$CMD" && echo --- OK /"$@" ------------------- ||
echo --- ERROR /"$@" ----------------
echo
}

run_command create_tag "Creating tag"
run_command create_release "Creating release"
run_command upload_file "Uploading plugin file"
run_command push_update "Uploading update information"
51 changes: 51 additions & 0 deletions src/main/java/br/ufes/inf/nemo/ufo/protege/HierarchyNode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package br.ufes.inf.nemo.ufo.protege;

import java.util.HashSet;
import java.util.Set;

/**
*
* @author luciano
*/
public class HierarchyNode {

private final String iri;
private final String parentIri;
private final int index;
private final Set<String> children = new HashSet<>();

public HierarchyNode(String iri, String parentIri, int index) {
this.iri = iri;
this.parentIri = parentIri;
this.index = index;
}

public String getIri() {
return iri;
}

public String getParentIri() {
return parentIri;
}

public int getIndex() {
return index;
}

public Set<String> getChildren() {
return children;
}

public boolean contains(String iri) {
return children.contains(iri);
}

public int compareTo(HierarchyNode other) {
return other == null ? -1 : Integer.signum(index - other.index);
}
}
Loading

0 comments on commit f9c4f82

Please sign in to comment.