Skip to content

Commit

Permalink
Merge pull request #52 from thepieterdc/hotfix/version-in-ua
Browse files Browse the repository at this point in the history
Set version in UA
  • Loading branch information
thepieterdc authored Feb 1, 2019
2 parents ab5870f + 6037e2c commit 9dd53d3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
plugins {
id 'de.fuerstenau.buildconfig' version '1.1.8'
id 'idea'
id 'java'
id 'org.jetbrains.intellij' version '0.3.10'
Expand All @@ -11,6 +12,13 @@ sourceCompatibility = 1.8

def hasPyCharm = project.hasProperty('pycharmPath')

buildConfig {
appName 'ugent-dodona'
version = project.version
packageName = 'be.ugent.piedcler.dodona.plugin'
clsName = 'BuildConfig'
}

intellij {
version ideaVersion
pluginName 'ugent-dodona'
Expand Down
18 changes: 13 additions & 5 deletions src/main/java/be/ugent/piedcler/dodona/plugin/Api.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
* Interface to the API.
*/
public final class Api {
private static final String USER_AGENT = "DodonaPlugin/1.1.0";

@Nullable
private static DodonaClient instance;

/**
* Removes the instance of the dodona client, may be called by the
* Removes the instance of the Dodona client, may be called by the
* SettingsHelper.
*/
public static void clearInstance() {
Expand All @@ -35,16 +33,26 @@ public static void clearInstance() {
* the caller since the instance will become invalid upon changing the
* settings.
*
* @return
* @return Dodona instance
*/
public static DodonaClient getInstance() {
if (instance == null) {
instance = DodonaBuilder.builder()
.setApiToken(SettingsHelper.getApiKey())
.setBaseUrl(SettingsHelper.getDodonaUrl())
.setUserAgent(USER_AGENT)
.setUserAgent(getUserAgent())
.build();
}
return instance;
}

/**
* Gets the user agent to send in API calls.
*
* @return the user agent
*/
private static String getUserAgent() {
final String version = BuildConfig.VERSION;
return String.format("DodonaPlugin/JetBrains-%s", version);
}
}

0 comments on commit 9dd53d3

Please sign in to comment.