Skip to content

Commit bb237bc

Browse files
author
alexrobin
committed
Fix to correctly release modules from other repos and show them in the
download modules dialog
1 parent f59bc4a commit bb237bc

File tree

4 files changed

+126
-78
lines changed

4 files changed

+126
-78
lines changed

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
apply from: 'common.gradle'
22
apply from: 'release.gradle'
33

4+
description = 'OSH Core Modules'
5+
46

57
allprojects {
68
version = oshCoreVersion

release.gradle

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,37 @@ allprojects {
2121

2222

2323
subprojects {
24-
25-
if (project.hasProperty("bintray_user")) {
26-
// bintray publishing options
27-
bintray {
28-
user = bintray_user
29-
key = bintray_api_key
30-
31-
publications = ['mavenJava']
32-
dryRun = false // whether to run this as dry-run, without deploying
33-
publish = true // whether version should be auto published after an upload
34-
override = true // whether to override version artifacts already published
35-
36-
pkg {
37-
repo = 'osh'
38-
name = 'osh-core'
39-
userOrg = 'sensiasoft'
40-
desc = 'OpenSensorHub Core Packages'
41-
websiteUrl = 'https://github.com/opensensorhub/osh-core'
42-
issueTrackerUrl = 'https://github.com/opensensorhub/osh-core/issues'
43-
vcsUrl = 'git://github.com/opensensorhub/osh-core.git'
44-
licenses = ['MPL-2.0']
45-
labels = ['sensor', 'sensor hub', 'ogc', 'swe', 'iot']
46-
publicDownloadNumbers = true
47-
48-
//githubRepo = 'opensensorhub/osh-core'
49-
//githubReleaseNotesFile = 'RELEASE_NOTES.md'
24+
afterEvaluate { project ->
25+
// only publish with bintray if credentials are configured
26+
// and project is not a SNAPSHOT
27+
if (project.hasProperty("bintray_user") && !project.version.endsWith('SNAPSHOT')) {
28+
println project.name
29+
// bintray publishing options
30+
bintray {
31+
user = bintray_user
32+
key = bintray_api_key
33+
34+
publications = ['mavenJava']
35+
dryRun = false // whether to run this as dry-run, without deploying
36+
publish = true // whether version should be auto published after an upload
37+
override = true // whether to override version artifacts already published
38+
39+
pkg {
40+
repo = 'osh'
41+
name = rootProject.name
42+
userOrg = 'sensiasoft'
43+
if (rootProject.description != null)
44+
desc = rootProject.description
45+
websiteUrl = 'https://github.com/opensensorhub/' + rootProject.name
46+
issueTrackerUrl = 'https://github.com/opensensorhub/' + rootProject.name + '/issues'
47+
vcsUrl = 'git://github.com/opensensorhub/' + rootProject.name + '.git'
48+
licenses = ['MPL-2.0']
49+
labels = ['sensor', 'sensor hub', 'ogc', 'swe', 'iot']
50+
publicDownloadNumbers = true
51+
version {
52+
name = rootProject.version
53+
}
54+
}
5055
}
5156
}
5257
}
@@ -123,17 +128,19 @@ task releaseGithub {
123128
def milestone = repo.listMilestones(GHIssueState.ALL).find {
124129
it.title == 'v' + project.version
125130
}
126-
if (milestone == null)
127-
throw new GradleException('No milestone found for release version ' + project.version)
128-
129-
// append fixed issues
130-
def issues = repo.getIssues(GHIssueState.CLOSED, milestone)
131-
if (!issues.isEmpty())
132-
text += "Resolved Issues:\n\n"
133-
issues.each {
134-
text += " * **#" + it.number + "** " + it.title + "\n"
131+
if (milestone == null) {
132+
println 'No milestone found for release version ' + project.version
133+
}
134+
else {
135+
// append issues fixed for this milestone
136+
def issues = repo.getIssues(GHIssueState.CLOSED, milestone)
137+
if (!issues.isEmpty())
138+
text += "Resolved Issues:\n\n"
139+
issues.each {
140+
text += " * **#" + it.number + "** " + it.title + "\n"
141+
}
142+
println text
135143
}
136-
println text
137144

138145
// publish new release
139146
GHReleaseBuilder builder = repo.createRelease('v' + project.version);

sensorhub-webui-core/src/main/java/org/sensorhub/ui/DownloadModulesPopup.java

Lines changed: 75 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@
2020
import java.net.URL;
2121
import java.util.ArrayList;
2222
import java.util.Collection;
23+
import java.util.Iterator;
24+
import java.util.concurrent.ExecutorService;
25+
import java.util.concurrent.Executors;
2326
import org.vast.xml.DOMHelper;
2427
import com.google.gson.Gson;
2528
import com.google.gson.JsonArray;
2629
import com.google.gson.JsonElement;
2730
import com.google.gson.JsonObject;
2831
import com.google.gson.JsonParser;
2932
import com.google.gson.reflect.TypeToken;
33+
import com.vaadin.data.Item;
3034
import com.vaadin.server.ExternalResource;
3135
import com.vaadin.ui.Component;
3236
import com.vaadin.ui.HorizontalLayout;
@@ -58,18 +62,20 @@ public class DownloadModulesPopup extends Window
5862
private static final String BINTRAY_WEB_ROOT = "https://bintray.com/" + BINTRAY_SUBJECT + "/" + BINTRAY_REPO + "/";
5963
private static final String BINTRAY_CONTENT_ROOT = "https://dl.bintray.com/" + BINTRAY_SUBJECT + "/" + BINTRAY_REPO + "/";
6064
private static final String LINK_TARGET = "osh-bintray";
65+
private static final String LOADING_MSG = "Loading...";
6166

6267
TreeTable table;
68+
ExecutorService exec = Executors.newFixedThreadPool(2);
6369

6470

6571
static class BintrayArtifact
6672
{
6773
public String name;
6874
public String path;
6975
public String label;
70-
public String desc;
76+
public String desc = LOADING_MSG;
7177
public String version;
72-
public String author;
78+
public String author = LOADING_MSG;
7379
}
7480

7581

@@ -104,19 +110,33 @@ public DownloadModulesPopup()
104110
center();
105111

106112
// load info in separate thread
107-
Thread t = new Thread()
113+
exec.execute(new Runnable()
108114
{
109115
public void run()
110116
{
111117
try
112118
{
113-
for (final String name: getBintrayPackageNames())
119+
for (final String pkgName: getBintrayPackageNames())
114120
{
121+
// don't list core modules
122+
if (pkgName.equals("osh-core"))
123+
continue;
124+
115125
try
116126
{
117-
final BintrayPackage pkg = getBintrayPackageInfo(name);
118-
pkg.files = getBintrayPackageFiles(name);
127+
final BintrayPackage pkg = getBintrayPackageInfo(pkgName);
128+
pkg.files = getBintrayPackageFiles(pkgName);
129+
130+
// remove non-executable jar files
131+
Iterator<BintrayArtifact> it = pkg.files.iterator();
132+
while (it.hasNext())
133+
{
134+
String fName = it.next().name;
135+
if (!fName.endsWith("jar") || fName.endsWith("-sources.jar") || fName.endsWith("-javadoc.jar"))
136+
it.remove();
137+
}
119138

139+
// draw table in UI thread
120140
getUI().access(new Runnable() {
121141
public void run()
122142
{
@@ -127,35 +147,62 @@ public void run()
127147
table = new TreeTable();
128148
table.setSizeFull();
129149
table.setSelectable(false);
130-
table.addContainerProperty("name", Component.class, null);
131-
table.addContainerProperty("desc", String.class, null);
132-
table.addContainerProperty("version", String.class, null);
133-
table.addContainerProperty("author", String.class, null);
134-
table.setColumnHeaders(new String[] {"Add-On Name", "Description", "Version", "Author"});
135-
table.setColumnWidth("name", 300);
136-
table.setColumnExpandRatio("desc", 10);
150+
table.addContainerProperty(ModuleTypeSelectionPopup.PROP_NAME, Component.class, null);
151+
table.addContainerProperty(ModuleTypeSelectionPopup.PROP_VERSION, String.class, null);
152+
table.addContainerProperty(ModuleTypeSelectionPopup.PROP_DESC, String.class, null);
153+
table.addContainerProperty(ModuleTypeSelectionPopup.PROP_AUTHOR, String.class, null);
154+
table.setColumnHeaders(new String[] {"Package", "OSH Version", "Description", "Author"});
155+
table.setColumnWidth(ModuleTypeSelectionPopup.PROP_NAME, 300);
156+
table.setColumnExpandRatio(ModuleTypeSelectionPopup.PROP_DESC, 10);
137157
layout.addComponent(table, 0);
138158
}
139159

140160
// add package info
141161
String href = BINTRAY_WEB_ROOT + pkg.name;
142162
Link link = new Link(pkg.name, new ExternalResource(href), LINK_TARGET, 0, 0, null);
143-
Object parentId = table.addItem(new Object[] {link, pkg.desc, null, null}, null);
144-
145-
// add all jar files
163+
Object parentId = table.addItem(new Object[] {link, null, pkg.desc, null}, null);
164+
165+
// add artifacts to table
146166
for (BintrayArtifact f: pkg.files)
147167
{
148-
if (f.name.endsWith("jar") && !f.name.endsWith("-sources.jar") && !f.name.endsWith("-javadoc.jar"))
149-
{
150-
href = BINTRAY_CONTENT_ROOT + f.path;
151-
link = new Link(f.label, new ExternalResource(href), "_self", 0, 0, null);
152-
Object id = table.addItem(new Object[] {link, f.desc, f.version, f.author}, null);
153-
table.setParent(id, parentId);
154-
table.setChildrenAllowed(id, false);
155-
}
168+
href = BINTRAY_CONTENT_ROOT + f.path;
169+
link = new Link(f.name, new ExternalResource(href), "_self", 0, 0, null);
170+
Object id = table.addItem(new Object[] {link, f.version, f.desc, f.author}, f.name);
171+
table.setParent(id, parentId);
172+
table.setChildrenAllowed(id, false);
156173
}
157174

158175
getUI().push();
176+
177+
// also load info from POM in separate thread
178+
exec.execute(new Runnable()
179+
{
180+
public void run()
181+
{
182+
try
183+
{
184+
for (final BintrayArtifact f: pkg.files)
185+
{
186+
String pomUrl = BINTRAY_CONTENT_ROOT + f.path.replaceAll(".jar", ".pom");
187+
readInfoFromPom(pomUrl, f);
188+
189+
getUI().access(new Runnable() {
190+
public void run()
191+
{
192+
Item item = table.getItem(f.name);
193+
item.getItemProperty(ModuleTypeSelectionPopup.PROP_DESC).setValue(f.desc);
194+
item.getItemProperty(ModuleTypeSelectionPopup.PROP_AUTHOR).setValue(f.author);
195+
getUI().push();
196+
}
197+
});
198+
}
199+
}
200+
catch (Exception e)
201+
{
202+
203+
}
204+
}
205+
});
159206
}
160207
});
161208
}
@@ -164,7 +211,7 @@ public void run()
164211
getUI().access(new Runnable() {
165212
public void run()
166213
{
167-
table.addItem(new Object[] {null, "Error loading package " + name, null, null}, null);
214+
table.addItem(new Object[] {null, "Error loading package " + pkgName, null, null}, null);
168215
getUI().push();
169216
}
170217
});
@@ -191,8 +238,7 @@ public void run()
191238
});
192239
}
193240
}
194-
};
195-
t.start();
241+
});
196242
}
197243

198244

@@ -233,22 +279,15 @@ protected BintrayPackage getBintrayPackageInfo(String pkgName) throws Exception
233279

234280
protected Collection<BintrayArtifact> getBintrayPackageFiles(String pkgName) throws Exception
235281
{
236-
Collection<BintrayArtifact> files;
282+
final Collection<BintrayArtifact> files;
237283

238284
URL url = new URL(BINTRAY_API_ROOT + BINTRAY_PKG + pkgName + "/files");
239285
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())))
240286
{
241287
Gson gson = new Gson();
242288
Type collectionType = new TypeToken<Collection<BintrayArtifact>>(){}.getType();
243289
files = gson.fromJson(reader, collectionType);
244-
}
245-
246-
// also load info from POM
247-
for (BintrayArtifact file: files)
248-
{
249-
String pomUrl = BINTRAY_CONTENT_ROOT + file.path.replaceAll(".jar", ".pom");
250-
readInfoFromPom(pomUrl, file);
251-
}
290+
}
252291

253292
return files;
254293
}
@@ -263,8 +302,6 @@ protected void readInfoFromPom(String url, BintrayArtifact item) throws Exceptio
263302
String pomName = dom.getElementValue("name");
264303
if (pomName != null && !pomName.isEmpty())
265304
item.label = pomName;
266-
else
267-
item.label = item.name;
268305
item.desc = dom.getElementValue("description");
269306
item.author = dom.getElementValue("developers/developer/organization");
270307
}

sensorhub-webui-core/src/main/java/org/sensorhub/ui/ModuleTypeSelectionPopup.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@
4646
public class ModuleTypeSelectionPopup extends Window implements UIConstants
4747
{
4848
private static final long serialVersionUID = -5368554789542357015L;
49-
private static final String PROP_NAME = "name";
50-
private static final String PROP_VERSION = "version";
49+
static final String PROP_NAME = "name";
50+
static final String PROP_VERSION = "version";
51+
static final String PROP_DESC = "desc";
52+
static final String PROP_AUTHOR = "author";
5153

5254

5355
protected interface ModuleTypeSelectionCallback
@@ -99,8 +101,8 @@ protected void buildDialog(Collection<IModuleProvider> moduleProviders, final Mo
99101
table.setSelectable(true);
100102
table.addContainerProperty(PROP_NAME, String.class, null);
101103
table.addContainerProperty(PROP_VERSION, String.class, null);
102-
table.addContainerProperty("desc", String.class, null);
103-
table.addContainerProperty("author", String.class, null);
104+
table.addContainerProperty(PROP_DESC, String.class, null);
105+
table.addContainerProperty(PROP_AUTHOR, String.class, null);
104106
table.setColumnHeaders(new String[] {"Module Type", "Version", "Description", "Author"});
105107
table.setPageLength(10);
106108
table.setMultiSelect(false);

0 commit comments

Comments
 (0)