package: require plugins to be non-empty

This commit is contained in:
Max Weber
2021-03-24 22:17:34 -06:00
parent 490818bb0e
commit 36840b9cb7
3 changed files with 37 additions and 2 deletions

View File

@@ -28,7 +28,7 @@ jobs:
path: |
~/.gradle/caches/
~/.gradle/wrapper/
key: package-2.0.4
key: package-2.0.5
- name: prepare
run: |
pushd package
@@ -80,7 +80,7 @@ jobs:
path: |
~/.gradle/caches/
~/.gradle/wrapper/
key: upload-2.0.4
key: upload-2.0.5
- uses: actions/download-artifact@v2
with:
name: manifest_diff

View File

@@ -627,6 +627,21 @@ public class Plugin implements Closeable
.trimResults()
.splitToList(pluginsStr);
if (plugins.isEmpty())
{
throw PluginBuildException.of(this, "No plugin classes listed")
.withHelp(() ->
{
String m = "You must list your plugin class names in the plugin descriptor";
if (!pluginClasses.isEmpty())
{
m += "\nPerhaps you wanted plugins=" + String.join(", ", pluginClasses);
}
return m;
})
.withFileLine(propFile, "plugins=" + pluginsStr);
}
manifest.setPlugins(plugins.toArray(new String[0]));
for (String className : plugins)

View File

@@ -100,6 +100,26 @@ public class PluginTest
}
}
@Test
public void testEmptyPlugins() throws DisabledPluginException, PluginBuildException, IOException, InterruptedException
{
try (Plugin p = createExamplePlugin("empty-plugins"))
{
File propFile = new File(p.repositoryDirectory, "runelite-plugin.properties");
Properties props = Plugin.loadProperties(propFile);
props.setProperty("plugins", "");
writeProperties(props, propFile);
p.build(Util.readRLVersion());
p.assembleManifest();
Assert.fail();
}
catch (PluginBuildException e)
{
log.info("ok: ", e);
assertContains(e.getHelpText(), "com.example.ExamplePlugin");
}
}
@Test
public void testUnverifiedDependency() throws InterruptedException, DisabledPluginException, PluginBuildException, IOException
{