Skip to content

Commit e487cb3

Browse files
author
Vincent Potucek
committed
try can use automatic resource management
1 parent 07abc3e commit e487cb3

7 files changed

Lines changed: 19 additions & 27 deletions

File tree

compat/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryPolicy.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,7 @@ public boolean checkOutOfDate(Date lastModified) {
132132

133133
@Override
134134
public String toString() {
135-
return "{enabled=" +
136-
enabled +
137-
", checksums=" +
138-
checksumPolicy +
139-
", updates=" +
140-
updatePolicy +
141-
'}';
135+
return "{enabled=" + enabled + ", checksums=" + checksumPolicy + ", updates=" + updatePolicy + '}';
142136
}
143137

144138
public ArtifactRepositoryPolicy merge(ArtifactRepositoryPolicy policy) {

compat/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ public void storeInLocalRepository(ArtifactRepository localRepository, ArtifactR
6969

7070
protected void updateRepositoryMetadata(ArtifactRepository localRepository, ArtifactRepository remoteRepository)
7171
throws IOException, XMLStreamException {
72-
File metadataFile = new File(localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata(this, remoteRepository));
72+
File metadataFile = new File(
73+
localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata(this, remoteRepository));
7374
Metadata metadata = this.metadata;
7475
if (metadataFile.exists()) {
7576
try (InputStream input = Files.newInputStream(metadataFile.toPath())) {
@@ -86,7 +87,7 @@ protected void updateRepositoryMetadata(ArtifactRepository localRepository, Arti
8687
// to delete on exit
8788
}
8889
}
89-
writeMetadata(metadata, metadataFile);
90+
writeMetadata(metadata, metadataFile);
9091
}
9192

9293
private void writeMetadata(Metadata metadata, File metadataFile) throws IOException, XMLStreamException {
@@ -145,10 +146,11 @@ public void merge(ArtifactMetadata metadata) {
145146
}
146147

147148
public String extendedToString() {
148-
return lineSeparator() + "Repository Metadata" + lineSeparator() + "--------------------------" +
149-
lineSeparator() + "GroupId: " + getGroupId() +
150-
lineSeparator() + "ArtifactId: " + getArtifactId() +
151-
lineSeparator() + "Metadata Type: " + getClass().getName();
149+
return lineSeparator() + "Repository Metadata" + lineSeparator() + "--------------------------"
150+
+ lineSeparator()
151+
+ "GroupId: " + getGroupId() + lineSeparator()
152+
+ "ArtifactId: " + getArtifactId() + lineSeparator()
153+
+ "Metadata Type: " + getClass().getName();
152154
}
153155

154156
public int getNature() {

compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/metadata/AbstractArtifactMetadata.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ public String getArtifactId() {
4848
}
4949

5050
public String extendedToString() {
51-
return lineSeparator() + "Artifact Metadata" + lineSeparator() + "--------------------------" +
52-
lineSeparator() + "GroupId: " + getGroupId() +
53-
lineSeparator() + "ArtifactId: " + getArtifactId() +
54-
lineSeparator() + "Metadata Type: " + getClass().getName();
51+
return lineSeparator() + "Artifact Metadata" + lineSeparator() + "--------------------------" + lineSeparator()
52+
+ "GroupId: " + getGroupId() + lineSeparator()
53+
+ "ArtifactId: " + getArtifactId() + lineSeparator()
54+
+ "Metadata Type: " + getClass().getName();
5555
}
5656
}

compat/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProblem.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ public Version getVersion() {
165165

166166
@Override
167167
public String toString() {
168-
return "[" + getSeverity() + "] " +
169-
getMessage() +
170-
" @ " + ModelProblemUtils.formatLocation(this, null);
168+
return "[" + getSeverity() + "] " + getMessage() + " @ " + ModelProblemUtils.formatLocation(this, null);
171169
}
172170
}

compat/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelData.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,7 @@ public void setVersion(String version) {
189189
* @return The effective identifier of the model, never {@code null}.
190190
*/
191191
public String getId() {
192-
return getGroupId() +
193-
':' +
194-
getArtifactId() +
195-
':' +
196-
getVersion();
192+
return getGroupId() + ':' + getArtifactId() + ':' + getVersion();
197193
}
198194

199195
@Override

compat/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemUtils.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ static String toId(Model model) {
9999
*/
100100
static String toId(String groupId, String artifactId, String version) {
101101
// not sure about his one. outsmart IDE
102-
return groupId != null && !groupId.isEmpty() ? groupId : !artifactId.isEmpty() ? artifactId : !version.isEmpty() ? version : "[unknown-version]";
102+
return groupId != null && !groupId.isEmpty()
103+
? groupId
104+
: !artifactId.isEmpty() ? artifactId : !version.isEmpty() ? version : "[unknown-version]";
103105
}
104106

105107
/**

compat/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public void setPluginContext(Map pluginContext) {
187187
this.pluginContext = pluginContext;
188188
}
189189

190-
protected void mkDirForParentFile(File file) {
190+
protected void mkDirForParentFile(File file) {
191191
getLog().info("[MAVEN-CORE-IT-LOG] Creating output file " + file);
192192
if (file.getParentFile().mkdirs()) {
193193
getLog().info("[MAVEN-CORE-IT-LOG] Created output file " + file);

0 commit comments

Comments
 (0)