Skip to content

Commit

Permalink
Merge pull request #6312 from apache/delivery
Browse files Browse the repository at this point in the history
Sync delivery to release190 for 19-rc5
  • Loading branch information
neilcsmith-net committed Aug 15, 2023
2 parents f1f01f0 + 69b6589 commit ba85468
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 13 deletions.
15 changes: 15 additions & 0 deletions extide/gradle/apichanges.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@ is the proper place.
<!-- ACTUAL CHANGES BEGIN HERE: -->

<changes>
<change id="gradle-wrapper-version">
<api name="general"/>
<summary>Method to set the Gradle version when initalizing the wrapper</summary>
<version major="2" minor="34"/>
<date day="14" month="8" year="2023"/>
<author login="neilcsmith"/>
<compatibility semantic="compatible" addition="yes"/>
<description>
<p>
Added additional <a href="@TOP@/org/netbeans/modules/gradle/spi/newproject/TemplateOperation.html#addWrapperInit-java.io.File-java.lang.String-">addWrapperInit</a>
method allowing to request a specific version or version label when initializing the Gradle wrapper.
</p>
</description>
<class package="org.netbeans.modules.gradle.spi.newproject" name="TemplateOperation"/>
</change>
<change id="java-runtime-manager">
<api name="general"/>
<summary>Adding JavaRuntimeManager abstracting the Gradle Runtime from Java Platform</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void removePropertyChangeListener(PropertyChangeListener listener) {
"# {1} - Supported Java Version",
"# {2} - Required Gradle Version",
"# {3} - Forced Gradle Version",
"TXT_JavaVersionMismatch=<html>The Java version: {0}, that is seletced for the project "
"TXT_JavaVersionMismatch=<html>The Java version: {0}, that is selected for the project "
+ "is not supported by Gradle {2}."
+ "The IDE will attempt to use Gradle {3} to gather the project information.<p>"
+ "Possible solutions:"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,29 @@ public void addConfigureProject(File projectDir, ProjectConfigurator configurato
steps.add(new ConfigureProjectStep(projectDir, configurator));
}

/**
* Initialize the Gradle wrapper in the target project. Equivalent to
* executing <code>gradle wrapper</code>.
*
* @param target project directory
*/
public void addWrapperInit(File target) {
steps.add(new InitGradleWrapper(target));
steps.add(new InitGradleWrapper(target, null));
}

/**
* Initialize the Gradle wrapper in the target project with the requested
* version of Gradle. Equivalent to executing
* <code>gradle wrapper --gradle-version $version</code>. The version may be
* the specific Gradle version required, or one of the labels supported by
* the wrapper task, eg. <code>latest</code>.
*
* @param target project directory
* @param version Gradle version or version label
* @since 2.34
*/
public void addWrapperInit(File target, String version) {
steps.add(new InitGradleWrapper(target, version));
}

/** * Begin creation of new project using Gradle's
Expand Down Expand Up @@ -443,9 +464,11 @@ public Set<FileObject> execute() {
private static final class InitGradleWrapper extends BaseOperationStep {

final File projectDir;
final String version;

public InitGradleWrapper(File projectDir) {
public InitGradleWrapper(File projectDir, String version) {
this.projectDir = projectDir;
this.version = version;
}

@Override
Expand All @@ -458,7 +481,13 @@ public String getMessage() {
public Set<FileObject> execute() {
GradleConnector gconn = GradleConnector.newConnector();
try (ProjectConnection pconn = gconn.forProjectDirectory(projectDir).connect()) {
pconn.newBuild().withArguments("--offline").forTasks("wrapper").run(); //NOI18N
List<String> args = new ArrayList<>();
args.add("wrapper"); //NOI18N
if (version != null) {
args.add("--gradle-version"); //NOI18N
args.add(version);
}
pconn.newBuild().withArguments("--offline").forTasks(args.toArray(new String[0])).run(); //NOI18N
} catch (GradleConnectionException | IllegalStateException ex) {
// Well for some reason we were not able to load Gradle.
// Ignoring that for now
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,16 @@ static void collectOperationsForType(Map<String, Object> params, TemplateOperati
final File loc = (File) params.get(CommonProjectActions.PROJECT_PARENT_FOLDER);
final File root = new File(loc, name);

ops.createGradleInit(root, type).basePackage(packageBase).projectName(name).add(); // NOI18N
ops.createGradleInit(root, type).basePackage(packageBase).projectName(name).dsl("groovy").add(); // NOI18N
ops.addProjectPreload(root);
ops.addProjectPreload(new File(root, subFolder));

Boolean initWrapper = (Boolean) params.get(PROP_INIT_WRAPPER);
if (initWrapper == null || initWrapper) {
ops.addWrapperInit(root);
// @TODO allow configuration of wrapper version
ops.addWrapperInit(root, "latest"); // NOI18N
} else {
// @TODO delete wrapper added by init?
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ TXT_Classes=Classes
TXT_Sources=Sources
TXT_Javadoc=Javadoc
TXT_JDKClasspath=Platform Classpath:
TXT_JDKModules=Platform Modules:
TXT_JDKSources=Platform Sources:
TXT_JDKJavadoc=Platform Javadoc:
TXT_JDKModules=JDK Modules:
TXT_JDKSources=JDK Sources:
TXT_JDKJavadoc=JDK Javadoc:
TXT_CanNotAddResolve=IDE cannot resolve the given path.
CTL_Add=Add JAR/Folder...
MNE_Add=J
Expand Down Expand Up @@ -77,10 +77,12 @@ MNE_PlatformHome=F
AD_PlatformName=N/A
AD_PlatformHome=N/A
MSG_BrokenProject=<html><p><font color=\"#A40000\">Error:</font> The specified \
folder does not contain a Java platform.</p>\
<p>If you want to specify a different folder for this platform, remove \
this platform and create a new one with exactly the same name pointing to the \
correct platform folder.</p></html>
folder does not contain a Java Development Kit.</p>\
<p>If you want to specify a different folder for this JDK, remove \
this entry and create a new one with exactly the same name pointing to the \
correct JDK folder.</p> \
<p>The default platform can not be removed since it represents the JDK used \
to run NetBeans (see etc/netbeans.conf).</p></html>

#Util
MSG_BrokenExtension=A nonexistent Java extension {0} in {1}
Expand Down

0 comments on commit ba85468

Please sign in to comment.