Add Maven build for JavaScript admin client (#17306)
Co-authored-by: Stian Thorgersen <stian@redhat.com>
This commit is contained in:
parent
2429d18d78
commit
9144207755
6 changed files with 194 additions and 29 deletions
|
@ -13,37 +13,72 @@ public class CopyDependencies {
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
String version = args[2];
|
String version = args[2];
|
||||||
|
|
||||||
Path repository = new File(args[0]).toPath().resolve("org").resolve("keycloak");
|
|
||||||
Path targetRoot = new File(args[1]).toPath().resolve(version);
|
Path targetRoot = new File(args[1]).toPath().resolve(version);
|
||||||
|
Path projectDir = targetRoot.getParent().getParent().getParent().getParent();
|
||||||
|
Path mavenRepository = new File(args[0]).toPath().resolve("org").resolve("keycloak");
|
||||||
|
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(CopyDependencies.class.getResourceAsStream("files")));
|
CopyDependencies dependencies = new CopyDependencies(version, projectDir, targetRoot, mavenRepository);
|
||||||
|
dependencies.copyFiles();
|
||||||
Path target = targetRoot;
|
|
||||||
for (String l = br.readLine(); l != null; l = br.readLine()) {
|
|
||||||
|
|
||||||
if (l.startsWith("./")) {
|
|
||||||
target = targetRoot.resolve(l.replace("./", "").replace('/', File.separatorChar));
|
|
||||||
if (!target.toFile().isDirectory()) {
|
|
||||||
target.toFile().mkdirs();
|
|
||||||
}
|
}
|
||||||
} else if (l.trim().length() > 0) {
|
|
||||||
|
private final String version;
|
||||||
|
private final String npmVersion;
|
||||||
|
private final Path targetDir;
|
||||||
|
private final Path projectDir;
|
||||||
|
private final Path mavenRepository;
|
||||||
|
|
||||||
|
public CopyDependencies(String version, Path projectDir, Path targetDir, Path mavenRepository) {
|
||||||
|
this.version = version;
|
||||||
|
this.npmVersion = version.equals("999-SNAPSHOT") ? "999.0.0-dev" : version;
|
||||||
|
this.targetDir = targetDir;
|
||||||
|
this.projectDir = projectDir;
|
||||||
|
this.mavenRepository = mavenRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void copyFiles() throws IOException {
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(CopyDependencies.class.getResourceAsStream("files")));
|
||||||
|
targetDir.toFile().mkdirs();
|
||||||
|
|
||||||
|
for (String l = br.readLine(); l != null; l = br.readLine()) {
|
||||||
|
if (l.trim().length() > 0) {
|
||||||
|
l = replaceVariables(l);
|
||||||
|
|
||||||
String[] t = l.trim().split(":");
|
String[] t = l.trim().split(":");
|
||||||
|
|
||||||
String artifactName = t[0];
|
String type = t[0];
|
||||||
String destName = t.length == 1 ? artifactName : t[1];
|
String artifactName = t[1];
|
||||||
|
String destinationName = t.length == 2 ? artifactName : t[2];
|
||||||
|
|
||||||
File artifactDir = repository.resolve(artifactName).resolve(version).toFile();
|
switch (type) {
|
||||||
|
case "mvn":
|
||||||
for (File f : artifactDir.listFiles((file, name) -> name.contains(".tar.gz") || name.contains(".zip"))) {
|
copyMaven(artifactName, destinationName);
|
||||||
Files.copy(f.toPath(), target.resolve(f.getName().replace(artifactName, destName)), StandardCopyOption.REPLACE_EXISTING);
|
break;
|
||||||
|
case "npm":
|
||||||
|
copyNpm(artifactName, destinationName);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(artifactName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
br.close();
|
br.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void copyMaven(String artifactName, String destinationName) throws IOException {
|
||||||
|
File artifactDir = mavenRepository.resolve(artifactName).resolve(version).toFile();
|
||||||
|
|
||||||
|
File[] files = artifactDir.listFiles((file, name) -> name.contains(".tar.gz") || name.contains(".tgz") || name.contains(".zip"));
|
||||||
|
|
||||||
|
for (File f : files) {
|
||||||
|
Files.copy(f.toPath(), targetDir.resolve(f.getName().replace(artifactName, destinationName)), StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void copyNpm(String artifactName, String destinationName) throws IOException {
|
||||||
|
Files.copy(projectDir.resolve(artifactName), targetDir.resolve(destinationName));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String replaceVariables(String input) {
|
||||||
|
return input.replaceAll("\\$\\$NPM_VERSION\\$\\$", npmVersion);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
./
|
mvn:keycloak-quarkus-dist:keycloak
|
||||||
keycloak-quarkus-dist:keycloak
|
mvn:keycloak-api-docs-dist:keycloak-api-docs
|
||||||
keycloak-api-docs-dist:keycloak-api-docs
|
|
||||||
|
|
||||||
keycloak-jetty94-adapter-dist:keycloak-oidc-jetty94-adapter
|
mvn:keycloak-jetty94-adapter-dist:keycloak-oidc-jetty94-adapter
|
||||||
keycloak-js-adapter-npm-dist:keycloak-oidc-js-adapter
|
mvn:keycloak-js-adapter-npm-dist:keycloak-oidc-js-adapter
|
||||||
keycloak-tomcat-adapter-dist:keycloak-oidc-tomcat-adapter
|
mvn:keycloak-js-admin-client:keycloak-js-admin-client
|
||||||
keycloak-wildfly-adapter-dist:keycloak-oidc-wildfly-adapter
|
mvn:keycloak-tomcat-adapter-dist:keycloak-oidc-tomcat-adapter
|
||||||
|
mvn:keycloak-wildfly-adapter-dist:keycloak-oidc-wildfly-adapter
|
||||||
|
|
||||||
keycloak-saml-jetty94-adapter-dist:keycloak-saml-jetty94-adapter
|
mvn:keycloak-saml-jetty94-adapter-dist:keycloak-saml-jetty94-adapter
|
||||||
keycloak-saml-tomcat-adapter-dist:keycloak-saml-tomcat-adapter
|
mvn:keycloak-saml-tomcat-adapter-dist:keycloak-saml-tomcat-adapter
|
||||||
keycloak-saml-wildfly-adapter-dist:keycloak-saml-wildfly-adapter
|
mvn:keycloak-saml-wildfly-adapter-dist:keycloak-saml-wildfly-adapter
|
||||||
|
|
||||||
|
npm:js/libs/keycloak-admin-client/target/keycloak-keycloak-admin-client-$$NPM_VERSION$$.tgz:keycloak-admin-client-$$NPM_VERSION$$.tgz
|
||||||
|
|
4
js/.gitignore
vendored
4
js/.gitignore
vendored
|
@ -36,3 +36,7 @@ assets
|
||||||
dist
|
dist
|
||||||
dist-ssr
|
dist-ssr
|
||||||
*.local
|
*.local
|
||||||
|
|
||||||
|
# Distribution
|
||||||
|
*.tgz
|
||||||
|
npm-dist
|
||||||
|
|
75
js/libs/keycloak-admin-client/pom.xml
Normal file
75
js/libs/keycloak-admin-client/pom.xml
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<artifactId>keycloak-js-parent</artifactId>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<version>999-SNAPSHOT</version>
|
||||||
|
<relativePath>../../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>keycloak-js-admin-client</artifactId>
|
||||||
|
|
||||||
|
<name>Keycloak JavaScript Admin Client</name>
|
||||||
|
<description>A JavaScript client to interact with Keycloak's Administration API.</description>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>create-target-dir</id>
|
||||||
|
<phase>prepare-package</phase>
|
||||||
|
<configuration>
|
||||||
|
<target>
|
||||||
|
<mkdir dir="./target"/>
|
||||||
|
</target>
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.github.eirslett</groupId>
|
||||||
|
<artifactId>frontend-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>npm-prepublish</id>
|
||||||
|
<goals>
|
||||||
|
<goal>npm</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<arguments>run prepublishOnly --workspace=@keycloak/keycloak-admin-client</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>npm-pack</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>npm</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<arguments>pack --workspace=@keycloak/keycloak-admin-client --pack-destination=libs/keycloak-admin-client/target</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<workingDirectory>../..</workingDirectory>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
49
js/pom.xml
Normal file
49
js/pom.xml
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<artifactId>keycloak-parent</artifactId>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<version>999-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>keycloak-js-parent</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<name>Keycloak JavaScript Parent</name>
|
||||||
|
<description>Parent of all JavaScript related code, sets up Node.js and NPM and installs dependencies for all projects in the workspace.</description>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>libs/keycloak-admin-client</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.github.eirslett</groupId>
|
||||||
|
<artifactId>frontend-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>install-node-and-npm</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>npm-ci</id>
|
||||||
|
<goals>
|
||||||
|
<goal>npm</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<arguments>ci --ignore-scripts</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<nodeVersion>${node.version}</nodeVersion>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
4
pom.xml
4
pom.xml
|
@ -187,7 +187,7 @@
|
||||||
<osgi.bundle.plugin.version>2.4.0</osgi.bundle.plugin.version>
|
<osgi.bundle.plugin.version>2.4.0</osgi.bundle.plugin.version>
|
||||||
<wildfly.plugin.version>2.0.1.Final</wildfly.plugin.version>
|
<wildfly.plugin.version>2.0.1.Final</wildfly.plugin.version>
|
||||||
<nexus.staging.plugin.version>1.6.5</nexus.staging.plugin.version>
|
<nexus.staging.plugin.version>1.6.5</nexus.staging.plugin.version>
|
||||||
<frontend.plugin.version>1.12.0</frontend.plugin.version>
|
<frontend.plugin.version>1.12.1</frontend.plugin.version>
|
||||||
<docker.maven.plugin.version>0.40.3</docker.maven.plugin.version>
|
<docker.maven.plugin.version>0.40.3</docker.maven.plugin.version>
|
||||||
<verifier.plugin.version>1.1</verifier.plugin.version>
|
<verifier.plugin.version>1.1</verifier.plugin.version>
|
||||||
<shade.plugin.version>3.4.1</shade.plugin.version>
|
<shade.plugin.version>3.4.1</shade.plugin.version>
|
||||||
|
@ -227,7 +227,7 @@
|
||||||
<server.output.dir.version>${project.version}</server.output.dir.version>
|
<server.output.dir.version>${project.version}</server.output.dir.version>
|
||||||
|
|
||||||
<!-- Frontend -->
|
<!-- Frontend -->
|
||||||
<node.version>v16.16.0</node.version>
|
<node.version>v18.14.2</node.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<url>http://keycloak.org</url>
|
<url>http://keycloak.org</url>
|
||||||
|
|
Loading…
Reference in a new issue