mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
support 'optional' license attribute for plugin-descriptor tag (MP-2910 Free functionality in paid plugins)
GitOrigin-RevId: 68c14424805b1effca53e9f6ddd82f567c122670
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b5236c05d5
commit
d59d3bbe18
@@ -14,4 +14,7 @@ public class ProductDescriptor {
|
||||
|
||||
@Attribute("release-version")
|
||||
public int releaseVersion;
|
||||
|
||||
@Attribute("optional")
|
||||
public boolean optional;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ public final class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor, Plu
|
||||
private @Nullable String myProductCode;
|
||||
private @Nullable Date myReleaseDate;
|
||||
private int myReleaseVersion;
|
||||
private boolean myIsLicenseOptional;
|
||||
private String myResourceBundleBaseName;
|
||||
private String myChangeNotes;
|
||||
private String myVersion;
|
||||
@@ -306,6 +307,7 @@ public final class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor, Plu
|
||||
myProductCode = StringUtil.nullize(child.getAttributeValue("code"));
|
||||
myReleaseDate = parseReleaseDate(child.getAttributeValue("release-date"), context.parentContext);
|
||||
myReleaseVersion = StringUtil.parseInt(child.getAttributeValue("release-version"), 0);
|
||||
myIsLicenseOptional = Boolean.valueOf(child.getAttributeValue("optional", "false"));
|
||||
break;
|
||||
|
||||
case "vendor":
|
||||
@@ -725,6 +727,10 @@ public final class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor, Plu
|
||||
return myReleaseVersion;
|
||||
}
|
||||
|
||||
public boolean isLicenseOptional() {
|
||||
return myIsLicenseOptional;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginId @NotNull [] getDependentPluginIds() {
|
||||
return myDependencies;
|
||||
|
||||
@@ -80,6 +80,11 @@ public final class DefaultPluginDescriptor implements IdeaPluginDescriptor {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLicenseOptional() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReleaseVersion() {
|
||||
return 0;
|
||||
|
||||
@@ -43,6 +43,8 @@ public interface PluginDescriptor {
|
||||
|
||||
int getReleaseVersion();
|
||||
|
||||
boolean isLicenseOptional();
|
||||
|
||||
PluginId @NotNull [] getDependentPluginIds();
|
||||
|
||||
PluginId @NotNull [] getOptionalDependentPluginIds();
|
||||
|
||||
@@ -25,6 +25,7 @@ public final class PluginNode implements IdeaPluginDescriptor {
|
||||
private String productCode;
|
||||
private Date releaseDate;
|
||||
private int releaseVersion;
|
||||
private boolean licenseOptional;
|
||||
private String version;
|
||||
private String vendor;
|
||||
private String description;
|
||||
@@ -111,6 +112,15 @@ public final class PluginNode implements IdeaPluginDescriptor {
|
||||
this.releaseVersion = releaseVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLicenseOptional() {
|
||||
return licenseOptional;
|
||||
}
|
||||
|
||||
public void setLicenseOptional(boolean optional) {
|
||||
this.licenseOptional = optional;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCategory() {
|
||||
return category;
|
||||
|
||||
+7
@@ -44,6 +44,7 @@ public final class PluginDownloader {
|
||||
private final @Nullable String myProductCode;
|
||||
private final Date myReleaseDate;
|
||||
private final int myReleaseVersion;
|
||||
private final boolean myLicenseOptional;
|
||||
private final String myDescription;
|
||||
private final List<PluginId> myDepends;
|
||||
|
||||
@@ -63,6 +64,7 @@ public final class PluginDownloader {
|
||||
myProductCode = descriptor.getProductCode();
|
||||
myReleaseDate = descriptor.getReleaseDate();
|
||||
myReleaseVersion = descriptor.getReleaseVersion();
|
||||
myLicenseOptional = descriptor.isLicenseOptional();
|
||||
myDescription = descriptor.getDescription();
|
||||
myDepends = descriptor instanceof PluginNode ? ((PluginNode)descriptor).getDepends() : Arrays.asList(descriptor.getDependentPluginIds());
|
||||
|
||||
@@ -109,6 +111,10 @@ public final class PluginDownloader {
|
||||
return myReleaseVersion;
|
||||
}
|
||||
|
||||
public boolean isLicenseOptional() {
|
||||
return myLicenseOptional;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BuildNumber getBuildNumber() {
|
||||
return myBuildNumber;
|
||||
@@ -378,6 +384,7 @@ public final class PluginDownloader {
|
||||
node.setProductCode(downloader.getProductCode());
|
||||
node.setReleaseDate(downloader.getReleaseDate());
|
||||
node.setReleaseVersion(downloader.getReleaseVersion());
|
||||
node.setLicenseOptional(downloader.isLicenseOptional());
|
||||
node.setVersion(downloader.getPluginVersion());
|
||||
node.setRepositoryName(host);
|
||||
node.setDownloadUrl(downloader.myPluginUrl);
|
||||
|
||||
@@ -142,12 +142,13 @@ class PluginDescriptorTest {
|
||||
<idea-plugin>
|
||||
<id>bar</id>
|
||||
<vendor>JetBrains</vendor>
|
||||
<product-descriptor code="IJ" release-date="20190811" release-version="42"/>
|
||||
<product-descriptor code="IJ" release-date="20190811" release-version="42" optional="true"/>
|
||||
</idea-plugin>""")
|
||||
val descriptor = loadDescriptorInTest(pluginFile.parent.parent)
|
||||
assertThat(descriptor).isNotNull()
|
||||
assertThat(descriptor.vendor).isEqualTo("JetBrains")
|
||||
assertThat(SimpleDateFormat("yyyyMMdd", Locale.US).format(descriptor.releaseDate)).isEqualTo("20190811")
|
||||
assertThat(descriptor.isLicenseOptional).isTrue()
|
||||
}
|
||||
|
||||
@Suppress("PluginXmlValidity")
|
||||
|
||||
Reference in New Issue
Block a user