diff --git a/distribution/downloads/src/main/java/CopyDependencies.java b/distribution/downloads/src/main/java/CopyDependencies.java index 6ab527e57b..5fde9e4349 100644 --- a/distribution/downloads/src/main/java/CopyDependencies.java +++ b/distribution/downloads/src/main/java/CopyDependencies.java @@ -13,37 +13,72 @@ public class CopyDependencies { public static void main(String[] args) throws IOException { 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 projectDir = targetRoot.getParent().getParent().getParent().getParent(); + Path mavenRepository = new File(args[0]).toPath().resolve("org").resolve("keycloak"); + CopyDependencies dependencies = new CopyDependencies(version, projectDir, targetRoot, mavenRepository); + dependencies.copyFiles(); + } + + 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(); - Path target = targetRoot; for (String l = br.readLine(); l != null; l = br.readLine()) { + if (l.trim().length() > 0) { + l = replaceVariables(l); - if (l.startsWith("./")) { - target = targetRoot.resolve(l.replace("./", "").replace('/', File.separatorChar)); - if (!target.toFile().isDirectory()) { - target.toFile().mkdirs(); - } - } else if (l.trim().length() > 0) { String[] t = l.trim().split(":"); - String artifactName = t[0]; - String destName = t.length == 1 ? artifactName : t[1]; + String type = t[0]; + String artifactName = t[1]; + String destinationName = t.length == 2 ? artifactName : t[2]; - File artifactDir = repository.resolve(artifactName).resolve(version).toFile(); - - for (File f : artifactDir.listFiles((file, name) -> name.contains(".tar.gz") || name.contains(".zip"))) { - Files.copy(f.toPath(), target.resolve(f.getName().replace(artifactName, destName)), StandardCopyOption.REPLACE_EXISTING); + switch (type) { + case "mvn": + copyMaven(artifactName, destinationName); + break; + case "npm": + copyNpm(artifactName, destinationName); + break; } - - System.out.println(artifactName); } } 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); + } + } diff --git a/distribution/downloads/src/main/resources/files b/distribution/downloads/src/main/resources/files index eb08e2194e..2f3bdeacff 100644 --- a/distribution/downloads/src/main/resources/files +++ b/distribution/downloads/src/main/resources/files @@ -1,12 +1,14 @@ -./ - keycloak-quarkus-dist:keycloak - keycloak-api-docs-dist:keycloak-api-docs +mvn:keycloak-quarkus-dist:keycloak +mvn:keycloak-api-docs-dist:keycloak-api-docs - keycloak-jetty94-adapter-dist:keycloak-oidc-jetty94-adapter - keycloak-js-adapter-npm-dist:keycloak-oidc-js-adapter - keycloak-tomcat-adapter-dist:keycloak-oidc-tomcat-adapter - keycloak-wildfly-adapter-dist:keycloak-oidc-wildfly-adapter +mvn:keycloak-jetty94-adapter-dist:keycloak-oidc-jetty94-adapter +mvn:keycloak-js-adapter-npm-dist:keycloak-oidc-js-adapter +mvn:keycloak-js-admin-client:keycloak-js-admin-client +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 - keycloak-saml-tomcat-adapter-dist:keycloak-saml-tomcat-adapter - keycloak-saml-wildfly-adapter-dist:keycloak-saml-wildfly-adapter +mvn:keycloak-saml-jetty94-adapter-dist:keycloak-saml-jetty94-adapter +mvn:keycloak-saml-tomcat-adapter-dist:keycloak-saml-tomcat-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 diff --git a/js/.gitignore b/js/.gitignore index f6d2019bea..38d18ce2fb 100644 --- a/js/.gitignore +++ b/js/.gitignore @@ -36,3 +36,7 @@ assets dist dist-ssr *.local + +# Distribution +*.tgz +npm-dist diff --git a/js/libs/keycloak-admin-client/pom.xml b/js/libs/keycloak-admin-client/pom.xml new file mode 100644 index 0000000000..5fb6792ac0 --- /dev/null +++ b/js/libs/keycloak-admin-client/pom.xml @@ -0,0 +1,75 @@ + + + 4.0.0 + + + keycloak-js-parent + org.keycloak + 999-SNAPSHOT + ../../pom.xml + + + keycloak-js-admin-client + + Keycloak JavaScript Admin Client + A JavaScript client to interact with Keycloak's Administration API. + pom + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + org.apache.maven.plugins + maven-antrun-plugin + + + create-target-dir + prepare-package + + + + + + + run + + + + + + com.github.eirslett + frontend-maven-plugin + + + npm-prepublish + + npm + + + run prepublishOnly --workspace=@keycloak/keycloak-admin-client + + + + npm-pack + package + + npm + + + pack --workspace=@keycloak/keycloak-admin-client --pack-destination=libs/keycloak-admin-client/target + + + + + ../.. + + + + + \ No newline at end of file diff --git a/js/pom.xml b/js/pom.xml new file mode 100644 index 0000000000..3a42d4892d --- /dev/null +++ b/js/pom.xml @@ -0,0 +1,49 @@ + + + 4.0.0 + + + keycloak-parent + org.keycloak + 999-SNAPSHOT + ../pom.xml + + + keycloak-js-parent + pom + + Keycloak JavaScript Parent + Parent of all JavaScript related code, sets up Node.js and NPM and installs dependencies for all projects in the workspace. + + + libs/keycloak-admin-client + + + + + + com.github.eirslett + frontend-maven-plugin + + + + install-node-and-npm + + + + npm-ci + + npm + + + ci --ignore-scripts + + + + + ${node.version} + + + + + diff --git a/pom.xml b/pom.xml index e662211ed0..f72e1a8406 100644 --- a/pom.xml +++ b/pom.xml @@ -187,7 +187,7 @@ 2.4.0 2.0.1.Final 1.6.5 - 1.12.0 + 1.12.1 0.40.3 1.1 3.4.1 @@ -227,7 +227,7 @@ ${project.version} - v16.16.0 + v18.14.2 http://keycloak.org