Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion get-version.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash -e

mvn help:evaluate -Dexpression=project.version -q -DforceStdout -pl .
mvn help:evaluate -Dexpression=project.version -DforceStdout --quiet --non-recursive -pl .
59 changes: 59 additions & 0 deletions js/libs/keycloak-js/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,63 @@
</plugin>
</plugins>
</build>
<profiles>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks unnecessarily complex, and adds some custom Maven registry settings just for this module. Why not just attach the tgz with:

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>${project.basedir}/assembly.xml
                                    <file>target/keycloak-js-${project.version}.tgz</file>
                                    <type>tar.gz</type>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

and change the configuration for maven-deploy-plugin to `true. That way it's just uploaded along the other artifacts.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can certainly do this. I just didn't want to alter original maven build behavior.

<profile>
<id>deploy-js-to-maven-repo</id>
<activation>
<property>
<name>deploy-js-to-maven-repo</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>get-npm-package-version</id>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<exportAntProperties>true</exportAntProperties>
<target>
<exec executable="jq">
<arg line="--raw-output '.version' package.json"/>
<redirector outputProperty="nodejs.package.version"/>
</exec>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<id>deploy-keycloak-js-adapter-to-maven-repo</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<generatePom>true</generatePom>
<artifactId>keycloak-js-adapter</artifactId>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<packaging>tgz</packaging>
<file>target/keycloak-js-${nodejs.package.version}.tgz</file>
<url>${maven.deploy.url}</url>
<repositoryId>${maven.repository.id}</repositoryId>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
20 changes: 14 additions & 6 deletions set-version.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
#!/bin/bash -e

NEW_VERSION=$1
NEW_NPM_VERSION=${2:-${1}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think we should not be using a seperate version for NPM. Instead the input versions should all adhere to valid semantic versions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line has nothing to do with using valid semantic versions. It allows our downstream build script to override the NPM version if needed (mainly for debug/investigation purpose).
Even if one uses set-version.sh with one parameter and specifies "non-semantic" version it will use it anyway (no validation of version is present).
Our production build script is using "./set-version.sh use_current".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would it need to do that? Wouldn't you just override all the versions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The internal build system assigns version to keycloak (and aligns dependencies) before start of maven build.
We have to use what was assigned. The problem is that assigned version is Maven compatible, but not npm compatible.
Therefore we need two of them. See my comment in set-version.sh script.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Therefore we need two of them. See my comment in set-version.sh script.

Or the version can be a valid semantic version, in which case it would work for both.


# Maven
mvn versions:set -DnewVersion=$NEW_VERSION -DgenerateBackupPoms=false -DgroupId=org.keycloak* -DartifactId=*
if [ $NEW_VERSION == 'use_current' ] ; then
# obtain NEW_VERSION from maven pom file
# - useful for downstream projects which already set the version in pom files
NEW_VERSION=$(./get-version.sh)
NEW_NPM_VERSION=$(echo $NEW_VERSION | awk -F '.' '{ print $1"."$2"."$3"+"$4 }')
else
Comment on lines +6 to +11

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow up from #23425 (comment).
This will assign NPM compatible version string. The third dot is changed to '+' as suggested by @jonkoops .

# Maven
mvn versions:set -DnewVersion=$NEW_VERSION -DgenerateBackupPoms=false -DgroupId=org.keycloak* -DartifactId=*
fi

# Docker
sed -i "s/ENV KEYCLOAK_VERSION .*/ENV KEYCLOAK_VERSION $NEW_VERSION/" quarkus/container/Dockerfile

# Documentation
cd docs/documentation
SHORT_VERSION=`echo $NEW_VERSION | awk -F '.' '{ print $1"."$2 }'`
SHORT_VERSION=`echo $NEW_NPM_VERSION | awk -F '.' '{ print $1"."$2 }'`
sed -i 's/:project_version: .*/:project_version: '$NEW_VERSION'/' topics/templates/document-attributes.adoc
sed -i 's/:project_versionMvn: .*/:project_versionMvn: '$NEW_VERSION'/' topics/templates/document-attributes.adoc
sed -i 's/:project_versionNpm: .*/:project_versionNpm: '$NEW_VERSION'/' topics/templates/document-attributes.adoc
sed -i 's/:project_versionNpm: .*/:project_versionNpm: '$NEW_NPM_VERSION'/' topics/templates/document-attributes.adoc
sed -i 's/:project_versionDoc: .*/:project_versionDoc: '$NEW_VERSION'/' topics/templates/document-attributes.adoc
cd -

# Keycloak JS
echo "$(jq '. += {"version": "'$NEW_VERSION'"}' js/libs/keycloak-js/package.json)" > js/libs/keycloak-js/package.json
echo "$(jq '. += {"version": "'$NEW_NPM_VERSION'"}' js/libs/keycloak-js/package.json)" > js/libs/keycloak-js/package.json

# Keycloak Admin Client
echo "$(jq '. += {"version": "'$NEW_VERSION'"}' js/libs/keycloak-admin-client/package.json)" > js/libs/keycloak-admin-client/package.json
echo "$(jq '. += {"version": "'$NEW_NPM_VERSION'"}' js/libs/keycloak-admin-client/package.json)" > js/libs/keycloak-admin-client/package.json