Skip to content

Commit

Permalink
Maven settings filtered now
Browse files Browse the repository at this point in the history
- to be able to customize local maven repo path on jenkins

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Sep 15, 2022
1 parent e71dbf3 commit e44db70
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<artifactId>download-maven-plugin</artifactId>
<executions>
<execution>
<id>download-pages-tck</id>
<id>download-tck</id>
<phase>generate-resources</phase>
<goals>
<goal>wget</goal>
Expand Down
4 changes: 3 additions & 1 deletion appserver/tests/tck/tck-runner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@
<ant.home>${env.ANT_HOME}</ant.home>
<jdk.home>${env.JAVA_HOME}</jdk.home>
<glassfish.version>${project.version}</glassfish.version>
<maven.repo.local>${user.home}/.m2/repository</maven.repo.local>
<tck.version>${project.version}</tck.version>
</properties>

<dependencies>
<dependency>
<groupId>org.glassfish.main.tests.tck</groupId>
<artifactId>jakarta-ant-based-tck</artifactId>
<version>${project.version}</version>
<version>${tck.version}</version>
<type>zip</type>
<scope>runtime</scope>
</dependency>
Expand Down Expand Up @@ -96,6 +97,7 @@
<directory>src/test/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</testResource>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ public File getAntDirectory() {
}


/**
* @return configured maven settings.xml file.
*/
public File getSettingsXml() {
return new File(cfg.getProperty("settingsXmlFile"));
}


/**
* @return version of the GlassFish zip artifact.
*/
Expand Down Expand Up @@ -170,4 +178,13 @@ public boolean isHarnessLoggingEnabled() {
public boolean isAsadminLoggingEnabled() {
return Boolean.parseBoolean(cfg.getProperty("log.asadmin"));
}


/**
* Prints internal properties to string.
*/
@Override
public String toString() {
return this.cfg.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class TckRunner {
*/
public TckRunner(final TckConfiguration cfg) {
this.cfg = cfg;
LOG.log(Level.INFO, "TckRunner configuration: \n{0}", cfg);
}


Expand All @@ -69,12 +70,17 @@ public TckRunner(final TckConfiguration cfg) {
*/
public void prepareWorkspace() {
LOG.log(Level.INFO, "Preparing workspace at {0}", cfg.getTargetDir());
ZipResolver zipResolver = new ZipResolver(cfg.getTargetDir());
ZipResolver zipResolver = new ZipResolver(cfg.getTargetDir(), cfg.getSettingsXml());
if (cfg.getJakartaeeDir().exists()) {
LOG.log(Level.INFO, "Jakarta EE was already installed, unzipping to {0} skipped.", cfg.getJakartaeeDir());
} else {
zipResolver.unzipDependency("org.glassfish.main.tests.tck", "jakarta-ant-based-tck", cfg.getTckVersion());
cfg.getJakartaeetckCommand().toFile().setExecutable(true);
File command = cfg.getJakartaeetckCommand().toFile();
if (command.exists()) {
command.setExecutable(true);
} else {
throw new IllegalStateException("The TCK runnable doesn't exist: " + command);
}
}
glassfishZip = zipResolver.getZipFile("org.glassfish.main.distributions", "glassfish", cfg.getGlassFishVersion());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

Expand All @@ -35,6 +37,7 @@
* @author David Matejcek
*/
public class ZipResolver {
private static final Logger LOG = System.getLogger(ZipResolver.class.getName());

private final MavenResolverSystem resolver;
private final File targetDirectory;
Expand All @@ -43,10 +46,11 @@ public class ZipResolver {
* Initializes the resolver.
*
* @param targetDirectory - this directory will be used for the output.
* @param settingsXml - Maven configuration
*/
public ZipResolver(final File targetDirectory) {
this.resolver = Maven.configureResolver().withMavenCentralRepo(false).workOffline()
.fromClassloaderResource("settings.xml");
public ZipResolver(final File targetDirectory, final File settingsXml) {
LOG.log(Level.DEBUG, "ZipResolver(targetDirectory={0}, settingsXml={1})", targetDirectory, settingsXml);
this.resolver = Maven.configureResolver().withMavenCentralRepo(false).workOffline().fromFile(settingsXml);
this.targetDirectory = targetDirectory;
}

Expand All @@ -55,6 +59,7 @@ public ZipResolver(final File targetDirectory) {
* @return the artifact ZIP file in user's default local Maven repository.
*/
public File getZipFile(String groupId, String artifactId, String version) {
LOG.log(Level.INFO, "getZipFile(groupId={0}, artifactId={1}, version={2})", groupId, artifactId, version);
return resolve(groupId, artifactId, version).asSingleFile();
}

Expand All @@ -63,6 +68,7 @@ public File getZipFile(String groupId, String artifactId, String version) {
* Resolves the ZIP dependency and unzips it to the target directory given in constructor.
*/
public void unzipDependency(String groupId, String artifactId, String version) {
LOG.log(Level.INFO, "unzipDependency(groupId={0}, artifactId={1}, version={2})", groupId, artifactId, version);
MavenFormatStage tckZip = resolve(groupId, artifactId, version);
try (ZipInputStream zis = new ZipInputStream(tckZip.asSingleInputStream())) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
It is possible because all required dependencies should be already downloaded
by the tck-download maven submodules.
-->
<interactiveMode>false</interactiveMode>
<localRepository>${maven.repo.local}</localRepository>
</settings>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ tck.version=${tck.version}

target.directory=${project.build.directory}
pomFile=${basedir}/pom.xml
settingsXmlFile=${project.build.testOutputDirectory}/settings.xml

ant.directory=${ant.home}
jdk.directory=${jdk.home}
Expand Down

0 comments on commit e44db70

Please sign in to comment.