Skip to content

Commit

Permalink
Add fields for project name and version to GradleProject.
Browse files Browse the repository at this point in the history
I must have had a reason for not including them originally, but I don't know what it was. The fields aren't always set, but the fields always exist, so why not record that information?
  • Loading branch information
sambsnyd committed Aug 6, 2024
1 parent a0314ce commit c4cb814
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rewrite-gradle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,10 @@ tasks.named<Copy>("processResources") {
into("META-INF/rewrite/classpath")
}
}

//Javadoc compiler will complain about the use of the internal types.
tasks.withType<Javadoc> {
exclude(
"**/GradleProject**"
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.openrewrite.gradle.marker;

import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.AllArgsConstructor;
import lombok.Value;
import lombok.With;
import org.openrewrite.internal.lang.Nullable;
Expand All @@ -32,13 +34,22 @@
*/
@SuppressWarnings("unused")
@Value
@AllArgsConstructor(onConstructor_ = { @JsonCreator })
public class GradleProject implements Marker, Serializable {
@With
UUID id;

@With
@Nullable
String group;

@With
String name;

@With
@Nullable
String version;

@With
String path;

Expand All @@ -53,6 +64,19 @@ public class GradleProject implements Marker, Serializable {

Map<String, GradleDependencyConfiguration> nameToConfiguration;

// Backwards compatibility to ease convoluted release process with rewrite-gradle-tooling-model
public GradleProject(
UUID id,
String name,
String path,
List<GradlePluginDescriptor> plugins,
List<MavenRepository> mavenRepositories,
List<MavenRepository> mavenPluginRepositories,
Map<String, GradleDependencyConfiguration> nameToConfiguration
) {
this(id, "", name, "", path, plugins, mavenRepositories, mavenPluginRepositories, nameToConfiguration);
}

public List<MavenRepository> getMavenPluginRepositories() {
return mavenPluginRepositories == null ? Collections.emptyList() : mavenPluginRepositories;
}
Expand Down Expand Up @@ -120,7 +144,9 @@ public GradleProject withNameToConfiguration(Map<String, GradleDependencyConfigu

return new GradleProject(
id,
group,
name,
version,
path,
plugins,
mavenRepositories,
Expand Down

0 comments on commit c4cb814

Please sign in to comment.