Skip to content

Commit

Permalink
[ARCHETYPE-658] Upgrade Groovy from 2.x to 4.0.22
Browse files Browse the repository at this point in the history
  • Loading branch information
slachiewicz committed Aug 20, 2024
1 parent 5f6c22f commit dbe0461
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 30 deletions.
7 changes: 3 additions & 4 deletions archetype-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@
<artifactId>archetype-descriptor</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.16</version>
<scope>compile</scope>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>4.0.21</version>
</dependency>
<dependency>
<groupId>org.apache.ivy</groupId>
Expand Down
2 changes: 1 addition & 1 deletion maven-archetype-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-script-interpreter</artifactId>
<version>1.2</version>
<version>1.5</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import groovy.json.JsonException // Should error on this line if test fails.

import java.nio.file.Files
import java.nio.file.Paths

def p = Paths.get(request.getOutputDirectory(), request.getArtifactId(), 'test.txt')
Files.createFile(p)
Files.createFile(p)
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,18 @@
import java.io.File;
import java.io.IOException;

import org.apache.maven.plugin.logging.Log;
import org.apache.maven.shared.invoker.InvocationOutputHandler;
import org.apache.maven.shared.scriptinterpreter.ExecutionLogger;
import org.apache.maven.shared.scriptinterpreter.FileLoggerMirrorHandler;
import org.slf4j.Logger;

/**
* @since 2.2
*/
class FileLogger extends org.apache.maven.shared.scriptinterpreter.FileLogger
implements InvocationOutputHandler, ExecutionLogger {
implements InvocationOutputHandler, ExecutionLogger, FileLoggerMirrorHandler {

Logger logger;
/**
* Creates a new logger that writes to the specified file.
*
Expand All @@ -67,7 +69,13 @@ class FileLogger extends org.apache.maven.shared.scriptinterpreter.FileLogger
* @param log The mojo logger to additionally output messages to, may be <code>null</code> if not used.
* @throws java.io.IOException If the output file could not be created.
*/
FileLogger(File outputFile, Log log) throws IOException {
super(outputFile, log);
FileLogger(File outputFile, Logger log) throws IOException {
super(outputFile);
logger = log;
}

@Override
public void consumeOutput(String message) {
logger.info(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
import org.apache.maven.shared.invoker.InvocationResult;
import org.apache.maven.shared.invoker.Invoker;
import org.apache.maven.shared.invoker.MavenInvocationException;
import org.apache.maven.shared.scriptinterpreter.RunFailureException;
import org.apache.maven.shared.scriptinterpreter.ScriptException;
import org.apache.maven.shared.scriptinterpreter.ScriptRunner;
import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate;
import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver;
Expand All @@ -74,6 +74,7 @@
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.WriterFactory;
import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
import org.slf4j.LoggerFactory;

/**
* <p>Execute the archetype integration tests, consisting in generating projects from the current archetype and optionally
Expand Down Expand Up @@ -661,22 +662,14 @@ private void invokePostArchetypeGenerationGoals(String goals, File basedir, File
getLog().info("No post-archetype-generation goals to invoke.");
}
// verify result
ScriptRunner scriptRunner = new ScriptRunner(getLog());
scriptRunner.setScriptEncoding(encoding);
try (ScriptRunner scriptRunner = new ScriptRunner()) {
scriptRunner.setScriptEncoding(encoding);

Map<String, Object> context = new LinkedHashMap<>();
context.put("projectDir", basedir);
Map<String, Object> context = new LinkedHashMap<>();
context.put("projectDir", basedir);

try {
scriptRunner.run(
"post-build script",
goalFile.getParentFile(),
postBuildHookScript,
context,
logger,
"failure post script",
true);
} catch (RunFailureException e) {
scriptRunner.run("post-build script", goalFile.getParentFile(), postBuildHookScript, context, logger);
} catch (ScriptException e) {
throw new IntegrationTestFailure("post build script failure failure: " + e.getMessage(), e);
}
}
Expand All @@ -688,7 +681,7 @@ private FileLogger setupLogger(File basedir) throws IOException {
File outputLog = new File(basedir, "build.log");

if (streamLogs) {
logger = new FileLogger(outputLog, getLog());
logger = new FileLogger(outputLog, LoggerFactory.getLogger(getClass()));
} else {
logger = new FileLogger(outputLog);
}
Expand Down

0 comments on commit dbe0461

Please sign in to comment.