mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+11
-6
@@ -87,17 +87,24 @@ public abstract class AbstractConfigUtils {
|
||||
return getSDKJarVersion(jarPath, Pattern.compile(jarRegex), manifestPath);
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public static String getSDKJarVersion(String jarPath, final Pattern jarPattern, String manifestPath) {
|
||||
return getSDKJarVersion(jarPath, jarPattern, manifestPath, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return value of Implementation-Version attribute in jar manifest
|
||||
* <p/>
|
||||
*
|
||||
* @param jarPath directory containing jar file
|
||||
* @param jarPattern filename pattern for jar file
|
||||
* @param jarPattern filename pattern for jar file
|
||||
* @param manifestPath path to manifest file in jar file
|
||||
* @param versionGroup group number to get from matcher
|
||||
* @return value of Implementation-Version attribute, null if not found
|
||||
*/
|
||||
@Nullable
|
||||
public static String getSDKJarVersion(String jarPath, final Pattern jarPattern, String manifestPath) {
|
||||
public static String getSDKJarVersion(String jarPath, final Pattern jarPattern, String manifestPath, int versionGroup) {
|
||||
try {
|
||||
File[] jars = LibrariesUtil.getFilesInDirectoryByPattern(jarPath, jarPattern);
|
||||
if (jars.length != 1) {
|
||||
@@ -123,8 +130,8 @@ public abstract class AbstractConfigUtils {
|
||||
}
|
||||
|
||||
final Matcher matcher = jarPattern.matcher(jars[0].getName());
|
||||
if (matcher.matches() && matcher.groupCount() == 1) {
|
||||
return matcher.group(1);
|
||||
if (matcher.matches() && matcher.groupCount() >= versionGroup) {
|
||||
return matcher.group(versionGroup);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -165,6 +172,4 @@ public abstract class AbstractConfigUtils {
|
||||
public Library[] getSDKLibrariesByModule(final Module module) {
|
||||
return LibrariesUtil.getLibrariesByCondition(module, LIB_SEARCH_CONDITION);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+7
-5
@@ -40,7 +40,9 @@ import java.util.regex.Pattern;
|
||||
* @author ilyas
|
||||
*/
|
||||
public abstract class GroovyConfigUtils extends AbstractConfigUtils {
|
||||
@NonNls public static final Pattern GROOVY_ALL_JAR_PATTERN = Pattern.compile("groovy-all(-(\\d(\\.\\d)*))?\\.jar");
|
||||
|
||||
@NonNls public static final Pattern GROOVY_ALL_JAR_PATTERN = Pattern.compile("groovy-all(-minimal)?(-(\\d+(\\.\\d+)*))?\\.jar");
|
||||
public static final int VERSION_GROUP_NUMBER = 3; // version will be in third group in GROOVY_ALL_JAR_PATTERN
|
||||
@NonNls public static final Pattern GROOVY_JAR_PATTERN = Pattern.compile("groovy(-(\\d(\\.\\d)*))?\\.jar");
|
||||
|
||||
public static final String NO_VERSION = "<no version>";
|
||||
@@ -79,15 +81,15 @@ public abstract class GroovyConfigUtils extends AbstractConfigUtils {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getSDKVersion(@NotNull final String path) {
|
||||
String groovyJarVersion = getSDKJarVersion(path + "/lib", GROOVY_JAR_PATTERN, MANIFEST_PATH);
|
||||
String groovyJarVersion = getSDKJarVersion(path + "/lib", GROOVY_JAR_PATTERN, MANIFEST_PATH, VERSION_GROUP_NUMBER);
|
||||
if (groovyJarVersion == null) {
|
||||
groovyJarVersion = getSDKJarVersion(path + "/lib", GROOVY_ALL_JAR_PATTERN, MANIFEST_PATH);
|
||||
groovyJarVersion = getSDKJarVersion(path + "/lib", GROOVY_ALL_JAR_PATTERN, MANIFEST_PATH, VERSION_GROUP_NUMBER);
|
||||
}
|
||||
if (groovyJarVersion == null) {
|
||||
groovyJarVersion = getSDKJarVersion(path + "/embeddable", GROOVY_ALL_JAR_PATTERN, MANIFEST_PATH);
|
||||
groovyJarVersion = getSDKJarVersion(path + "/embeddable", GROOVY_ALL_JAR_PATTERN, MANIFEST_PATH, VERSION_GROUP_NUMBER);
|
||||
}
|
||||
if (groovyJarVersion == null) {
|
||||
groovyJarVersion = getSDKJarVersion(path, GROOVY_ALL_JAR_PATTERN, MANIFEST_PATH);
|
||||
groovyJarVersion = getSDKJarVersion(path, GROOVY_ALL_JAR_PATTERN, MANIFEST_PATH, VERSION_GROUP_NUMBER);
|
||||
}
|
||||
return groovyJarVersion == null ? UNDEFINED_VERSION : groovyJarVersion;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user