Skip to content

Commit

Permalink
Split liquibase-core and liquibase-commercial jar files (#3050)
Browse files Browse the repository at this point in the history
- Include liquibase-commercial.jar as a separate artifact in the CLI internal/lib dir
- Move liquibase.jar in the CLI to internal/lib
- Updated release logic for new liquibase-core/liquibase-commerical jars
- Updated "XSD not found" error message to include missing extensions

Co-authored-by: ap-liquibase <apierre@liquibase.com>
  • Loading branch information
nvoxland and ap-liquibase committed Jul 20, 2022
1 parent eb62560 commit bbbd3a8
Show file tree
Hide file tree
Showing 28 changed files with 490 additions and 460 deletions.
23 changes: 13 additions & 10 deletions .github/util/re-version.sh
Expand Up @@ -43,22 +43,22 @@ mkdir -p $outdir
(cd $scriptDir && javac ManifestReversion.java)

#### Update jars
declare -a jars=("liquibase-0-SNAPSHOT.jar" "liquibase-0-SNAPSHOT-sources.jar" "liquibase-cdi-0-SNAPSHOT.jar" "liquibase-cdi-0-SNAPSHOT-sources.jar" "liquibase-maven-plugin-0-SNAPSHOT.jar" "liquibase-maven-plugin-0-SNAPSHOT-sources.jar")
declare -a jars=("liquibase-core-0-SNAPSHOT.jar" "liquibase-core-0-SNAPSHOT-sources.jar" "liquibase-commercial-0-SNAPSHOT.jar" "liquibase-cdi-0-SNAPSHOT.jar" "liquibase-cdi-0-SNAPSHOT-sources.jar" "liquibase-maven-plugin-0-SNAPSHOT.jar" "liquibase-maven-plugin-0-SNAPSHOT-sources.jar")

for jar in "${jars[@]}"
do
## MANIFEST.MF settings
unzip -q $workdir/$jar META-INF/* -d $workdir

java -cp $scriptDir ManifestReversion $workdir/META-INF/MANIFEST.MF $version
find $workdir/META-INF -name pom.xml -exec sed -i -e "s/<version>0-SNAPSHOT<\/version>/<version>$version<\/version>/" {} \;
find $workdir/META-INF -name pom.properties -exec sed -i -e "s/0-SNAPSHOT/$version/" {} \;
find $workdir/META-INF -name plugin*.xml -exec sed -i -e "s/<version>0-SNAPSHOT<\/version>/<version>$version<\/version>/" {} \;
find $workdir/META-INF -name pom.xml -exec sed -i -e "s/<version>0-SNAPSHOT<\/version>/<version>$version<\/version>/g" {} \;
find $workdir/META-INF -name pom.properties -exec sed -i -e "s/0-SNAPSHOT/$version/g" {} \;
find $workdir/META-INF -name plugin*.xml -exec sed -i -e "s/<version>0-SNAPSHOT<\/version>/<version>$version<\/version>/g" {} \;
(cd $workdir && jar -uMf $jar META-INF)
rm -rf $workdir/META-INF

## Fix up liquibase.build.properties
if [ $jar == "liquibase-0-SNAPSHOT.jar" ]; then
if [[ $jar == "liquibase-core-0-SNAPSHOT.jar" || $jar == "liquibase-commercial-0-SNAPSHOT.jar" ]]; then
unzip -q $workdir/$jar liquibase.build.properties -d $workdir
sed -i -e "s/build.version=.*/build.version=$version/" $workdir/liquibase.build.properties
(cd $workdir && jar -uf $jar liquibase.build.properties)
Expand All @@ -79,15 +79,15 @@ do
done

#### Update javadoc jars
declare -a javadocJars=("liquibase-0-SNAPSHOT-javadoc.jar" "liquibase-cdi-0-SNAPSHOT-javadoc.jar" "liquibase-maven-plugin-0-SNAPSHOT-javadoc.jar")
declare -a javadocJars=("liquibase-core-0-SNAPSHOT-javadoc.jar" "liquibase-cdi-0-SNAPSHOT-javadoc.jar" "liquibase-maven-plugin-0-SNAPSHOT-javadoc.jar")

for jar in "${javadocJars[@]}"
do
mkdir $workdir/rebuild
unzip -q $workdir/$jar -d $workdir/rebuild

find $workdir/rebuild -name "*.html" -exec sed -i -e "s/0-SNAPSHOT/$version/" {} \;
find $workdir/rebuild -name "*.xml" -exec sed -i -e "s/<version>0-SNAPSHOT<\/version>/<version>$version<\/version>/" {} \;
find $workdir/rebuild -name "*.html" -exec sed -i -e "s/0-SNAPSHOT/$version/g" {} \;
find $workdir/rebuild -name "*.xml" -exec sed -i -e "s/<version>0-SNAPSHOT<\/version>/<version>$version<\/version>/g" {} \;

(cd $workdir/rebuild && jar -uf ../$jar *)
rm -rf $workdir/rebuild
Expand Down Expand Up @@ -132,12 +132,15 @@ done


##### update zip/tar files
cp $outdir/liquibase-$version.jar $workdir/liquibase.jar ##save versioned jar as unversioned to include in zip/tar
mkdir -p $workdir/internal/lib
cp $outdir/liquibase-core-$version.jar $workdir/internal/lib/liquibase-core.jar ##save versioned jar as unversioned to include in zip/tar
cp $outdir/liquibase-commercial-$version.jar $workdir/internal/lib/liquibase-commercial.jar ##save versioned jar as unversioned to include in zip/tar

## Extract tar.gz and rebuild it back into the tar.gz and zip
mkdir $workdir/tgz-repackage
(cd $workdir/tgz-repackage && tar -xzf $workdir/liquibase-0-SNAPSHOT.tar.gz)
cp $workdir/liquibase.jar $workdir/tgz-repackage/liquibase.jar
cp $workdir/internal/lib/liquibase-core.jar $workdir/tgz-repackage/internal/lib/liquibase-core.jar
cp $workdir/internal/lib/liquibase-commercial.jar $workdir/tgz-repackage/internal/lib/liquibase-commercial.jar
find $workdir/tgz-repackage -name "*.txt" -exec sed -i -e "s/0-SNAPSHOT/$version/" {} \;
(cd $workdir/tgz-repackage && tar -czf $outdir/liquibase-$version.tar.gz *)
(cd $workdir/tgz-repackage && zip -qr $outdir/liquibase-$version.zip *)
33 changes: 23 additions & 10 deletions .github/workflows/build.yml
Expand Up @@ -320,22 +320,22 @@ jobs:
env:
GPG_PASSWORD: ${{ secrets.GPG_PASSPHRASE }}

- name: Download liquibase-pro
- name: Download liquibase-commercial
uses: liquibase/action-download-artifact@v2-liquibase
with:
github_token: ${{ secrets.BOT_TOKEN }}
workflow: build.yml
workflow_conclusion: success
branch: "${{ needs.setup.outputs.proBranchName }}"
name: liquibase-pro-modules
path: download/liquibase-pro
name: liquibase-commercial-modules
path: download/liquibase-commercial
repo: liquibase/liquibase-pro

- name: Install Built Modules
run: |
(find . -name *-SNAPSHOT.jar -exec mvn -B org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dfile={} \;)
(find . -name *-SNAPSHOT-sources.jar -exec mvn -B org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dclassifier=sources -Dfile={} \;)
mvn -B org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dfile=download/liquibase-pro/liquibase-pro-0-SNAPSHOT.jar
mvn -B org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dfile=download/liquibase-commercial/liquibase-commercial-0-SNAPSHOT.jar
- name: Build & Sign Artifacts
env:
Expand All @@ -355,7 +355,7 @@ jobs:
echo "Saving windows key"
echo "$INSTALL4J_WINDOWS_KEY" | base64 -d > liquibase-dist/target/keys/datical_windows.pfx
mvn -B -pl liquibase-dist -P liquibase-pro source:jar package
mvn -B -pl liquibase-dist -P liquibase-commercial source:jar package
## extract tar content for other artifacts
mkdir -p liquibase-dist/target/liquibase-0-SNAPSHOT
Expand All @@ -372,8 +372,11 @@ jobs:
mkdir -p artifacts
cp liquibase-dist/target/liquibase-0-SNAPSHOT.tar.gz artifacts
cp liquibase-dist/target/liquibase-0-SNAPSHOT.zip artifacts
cp liquibase-dist/target/liquibase-0-SNAPSHOT.jar artifacts
cp liquibase-dist/target/liquibase-0-SNAPSHOT-sources.jar artifacts
cp liquibase-dist/target/liquibase-0-SNAPSHOT.jar artifacts/liquibase-core-0-SNAPSHOT.jar
cp liquibase-dist/target/liquibase-0-SNAPSHOT-sources.jar artifacts/liquibase-core-0-SNAPSHOT-sources.jar
cp target/liquibase-0-SNAPSHOT-javadoc.jar artifacts/liquibase-core-0-SNAPSHOT-javadoc.jar
cp liquibase-dist/target/liquibase-*-installer-* artifacts
cp liquibase-maven-plugin/target/liquibase-maven-plugin-0-SNAPSHOT.jar artifacts
Expand All @@ -383,19 +386,29 @@ jobs:
cp liquibase-cdi/target/liquibase-cdi-0-SNAPSHOT.jar artifacts
cp liquibase-cdi/target/liquibase-cdi-0-SNAPSHOT-sources.jar artifacts
cp liquibase-cdi/target/liquibase-cdi-0-SNAPSHOT-javadoc.jar artifacts
echo "Source code not available for liquibase-commercial" > /tmp/readme.source.txt
(cd /tmp && jar cf liquibase-commercial-0-SNAPSHOT-sources.jar readme.source.txt)
cp target/liquibase-0-SNAPSHOT-javadoc.jar artifacts
echo "Javadocs not available for liquibase-commercial" > /tmp/readme.javadocs.txt
(cd /tmp && jar cf liquibase-commercial-0-SNAPSHOT-javadoc.jar readme.javadocs.txt)
cp download/liquibase-commercial/liquibase-commercial-0-SNAPSHOT.jar artifacts
cp /tmp/liquibase-commercial-0-SNAPSHOT-sources.jar artifacts
cp /tmp/liquibase-commercial-0-SNAPSHOT-javadoc.jar artifacts
.github/util/sign-artifacts.sh artifacts
##prepare branch-named convenience artifacts directories
mkdir artifacts-named
cp liquibase-dist/target/liquibase-0-SNAPSHOT.tar.gz artifacts-named/liquibase-${{ needs.setup.outputs.thisBranchFileName }}.tar.gz
cp liquibase-dist/target/liquibase-0-SNAPSHOT.jar artifacts-named/liquibase-${{ needs.setup.outputs.thisBranchFileName }}.jar
cp liquibase-dist/target/liquibase-0-SNAPSHOT.jar artifacts-named/liquibase-core-${{ needs.setup.outputs.thisBranchFileName }}.jar
cp liquibase-maven-plugin/target/liquibase-maven-plugin-0-SNAPSHOT.jar artifacts-named/liquibase-maven-plugin-${{ needs.setup.outputs.thisBranchFileName }}.jar
cp liquibase-cdi/target/liquibase-cdi-0-SNAPSHOT.jar artifacts-named/liquibase-cdi-${{ needs.setup.outputs.thisBranchFileName }}.jar
cp liquibase-extension-testing/target/liquibase-extension-testing-0-SNAPSHOT.jar artifacts-named/liquibase-extension-testing-${{ needs.setup.outputs.thisBranchFileName }}.jar
cp liquibase-extension-testing/target/liquibase-extension-testing-0-SNAPSHOT-deps.jar artifacts-named/liquibase-extension-testing-${{ needs.setup.outputs.thisBranchFileName }}-deps.jar
cp download/liquibase-commercial/liquibase-commercial-0-SNAPSHOT.jar artifacts-named/liquibase-commercial-${{ needs.setup.outputs.thisBranchFileName }}.jar
- name: Archive Packages
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -474,7 +487,7 @@ jobs:
}
if (failedCheckingUs) {
console.log("Rerun liquibase-pro that was waiting on us");
console.log("Rerun liquibase-commercial that was waiting on us");
//octokit removed the retryWorkflow function
github.request("POST "+currentBranchInfo.runRerunUrl);
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/create-release.yml
Expand Up @@ -73,7 +73,8 @@ jobs:
.github/util/sign-artifacts.sh re-version/out
mkdir re-version/final
mv re-version/out/liquibase-${{ needs.setup.outputs.version }}.jar re-version/final
mv re-version/out/liquibase-core-${{ needs.setup.outputs.version }}.jar re-version/final
mv re-version/out/liquibase-commercial-${{ needs.setup.outputs.version }}.jar re-version/final
mv re-version/out/liquibase-${{ needs.setup.outputs.version }}.tar.gz re-version/final
mv re-version/out/liquibase-${{ needs.setup.outputs.version }}.zip re-version/final
Expand Down
32 changes: 24 additions & 8 deletions .github/workflows/release-published.yml
Expand Up @@ -73,9 +73,9 @@ jobs:
unzip liquibase-additional-*.zip
##extracts and sign poms
unzip -j liquibase-${version}.jar META-INF/maven/org.liquibase/liquibase-core/pom.xml
mv pom.xml liquibase-${version}.pom
gpg --batch --pinentry-mode=loopback --passphrase "$GPG_PASSWORD" -ab liquibase-${version}.pom
unzip -j liquibase-core-${version}.jar META-INF/maven/org.liquibase/liquibase-core/pom.xml
mv pom.xml liquibase-core-${version}.pom
gpg --batch --pinentry-mode=loopback --passphrase "$GPG_PASSWORD" -ab liquibase-core-${version}.pom
unzip -j liquibase-maven-plugin-${version}.jar META-INF/maven/org.liquibase/liquibase-maven-plugin/pom.xml
mv pom.xml liquibase-maven-plugin-${version}.pom
Expand All @@ -87,15 +87,31 @@ jobs:
sed -i -e "s/<description>/<name>Liquibase CDI Plugin<\/name><description>/" liquibase-cdi-${version}.pom ## name didn't end up in pom. Hack it in for now
gpg --batch --pinentry-mode=loopback --passphrase "$GPG_PASSWORD" -ab liquibase-cdi-${version}.pom
unzip -j liquibase-commercial-${version}.jar META-INF/maven/org.liquibase/liquibase-commercial/pom.xml
mv pom.xml liquibase-commercial-${version}.pom
gpg --batch --pinentry-mode=loopback --passphrase "$GPG_PASSWORD" -ab liquibase-commercial-${version}.pom
mvn -B org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy-file \
-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ \
-DrepositoryId=sonatype-nexus-staging \
-DpomFile=liquibase-${version}.pom \
-DpomFile=liquibase-core-${version}.pom \
-DgeneratePom=false \
-Dfile=liquibase-${version}.jar \
-Dsources=liquibase-${version}-sources.jar \
-Djavadoc=liquibase-${version}-javadoc.jar \
-Dfiles=liquibase-${version}.jar.asc,liquibase-${version}-sources.jar.asc,liquibase-${version}-javadoc.jar.asc,liquibase-${version}.pom.asc \
-Dfile=liquibase-core-${version}.jar \
-Dsources=liquibase-core-${version}-sources.jar \
-Djavadoc=liquibase-core-${version}-javadoc.jar \
-Dfiles=liquibase-core-${version}.jar.asc,liquibase-core-${version}-sources.jar.asc,liquibase-core-${version}-javadoc.jar.asc,liquibase-core-${version}.pom.asc \
-Dtypes=jar.asc,jar.asc,jar.asc,pom.asc \
-Dclassifiers=,sources,javadoc,
mvn -B org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy-file \
-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ \
-DrepositoryId=sonatype-nexus-staging \
-DpomFile=liquibase-commercial-${version}.pom \
-DgeneratePom=false \
-Dfile=liquibase-commercial-${version}.jar \
-Dsources=liquibase-commercial-${version}-sources.jar \
-Djavadoc=liquibase-commercial-${version}-javadoc.jar \
-Dfiles=liquibase-commercial-${version}.jar.asc,liquibase-commercial-${version}-sources.jar.asc,liquibase-commercial-${version}-javadoc.jar.asc,liquibase-commercial-${version}.pom.asc \
-Dtypes=jar.asc,jar.asc,jar.asc,pom.asc \
-Dclassifiers=,sources,javadoc,
Expand Down
Expand Up @@ -1142,7 +1142,7 @@ public String[] getVersion() throws Exception {
continue;
}
final File file = new File(url.toURI());
if (file.getName().equals("liquibase.jar")) {
if (file.getName().equals("liquibase-core.jar")) {
continue;
}
if (file.exists() && file.getName().toLowerCase().endsWith(".jar")) {
Expand Down Expand Up @@ -1195,9 +1195,11 @@ private LibraryInfo getLibraryInfo(File pathEntryFile) throws IOException {
libraryInfo.file = pathEntryFile;

final Manifest manifest = jarFile.getManifest();
libraryInfo.name = getValue(manifest, "Bundle-Name", "Implementation-Title", "Specification-Title");
libraryInfo.version = getValue(manifest, "Bundle-Version", "Implementation-Version", "Specification-Version");
libraryInfo.vendor = getValue(manifest, "Bundle-Vendor", "Implementation-Vendor", "Specification-Vendor");
if (manifest != null) {
libraryInfo.name = getValue(manifest, "Bundle-Name", "Implementation-Title", "Specification-Title");
libraryInfo.version = getValue(manifest, "Bundle-Version", "Implementation-Version", "Specification-Version");
libraryInfo.vendor = getValue(manifest, "Bundle-Vendor", "Implementation-Vendor", "Specification-Vendor");
}

if (libraryInfo.name == null) {
libraryInfo.name = pathEntryFile.getName().replace(".jar", "");
Expand Down
Expand Up @@ -38,7 +38,7 @@ public static void main(final String[] args) throws Exception {
File liquibaseHome = new File(liquibaseHomeEnv);

List<URL> urls = new ArrayList<>();
urls.add(new File(liquibaseHome, "liquibase.jar").toURI().toURL());
urls.add(new File(liquibaseHome, "internal/lib/liquibase-core.jar").toURI().toURL()); //make sure liquibase-core.jar is first in the list

File[] libDirs = new File[]{
new File("./liquibase_libs"),
Expand All @@ -60,7 +60,7 @@ public static void main(final String[] args) throws Exception {
}

for (File lib : files) {
if (lib.getName().toLowerCase(Locale.US).endsWith(".jar")) {
if (lib.getName().toLowerCase(Locale.US).endsWith(".jar") && !lib.getName().toLowerCase(Locale.US).equals("liquibase-core.jar")) {
try {
urls.add(lib.toURI().toURL());
debug("Added " + lib.getAbsolutePath() + " to classpath");
Expand Down Expand Up @@ -90,7 +90,7 @@ public static void main(final String[] args) throws Exception {
if (parentLoaderSetting.equalsIgnoreCase("system")) {
//loading with the regular system classloader includes liquibase.jar in the parent.
//That causes the parent classloader to load LiquibaseCommandLine which makes it not able to access files in the child classloader
//The system classloader's parent is the boot classloader, which keeps the only classloader with liquibase.jar the same as the rest of the classes it needs to access.
//The system classloader's parent is the boot classloader, which keeps the only classloader with liquibase-core.jar the same as the rest of the classes it needs to access.
parentLoader = ClassLoader.getSystemClassLoader().getParent();

} else if (parentLoaderSetting.equalsIgnoreCase("thread")) {
Expand Down
Expand Up @@ -56,9 +56,9 @@ public InputSource resolveEntity(String name, String publicId, String baseURI, S

if (streams.isEmpty()) {
if (GlobalConfiguration.SECURE_PARSING.getCurrentValue()) {
String errorMessage = "Unable to resolve xml entity " + systemId + " locally: " +
String errorMessage = "Unable to resolve xml entity " + systemId + ". " +
GlobalConfiguration.SECURE_PARSING.getKey() + " is set to 'true' which does not allow remote lookups. " +
"Set it to 'false' to allow remote lookups of xsd files.";
"Check for spelling or capitalization errors and missing extensions such as liquibase-commercial in your XSD definition. Or, set it to 'false' to allow remote lookups of xsd files.";
throw new XSDLookUpException(errorMessage);
} else {
log.fine("Unable to resolve XML entity locally. Will load from network.");
Expand Down Expand Up @@ -110,7 +110,7 @@ private void warnForMismatchedXsdVersion(String systemId) {

/**
* ResourceAccessor to use if the standard one does not have the XSD files in it.
* Returns a ClassLoaderResourceAccessor that checks the system classloader which should include the liquibase.jar.
* Returns a ClassLoaderResourceAccessor that checks the system classloader which should include the liquibase-core.jar.
*/
protected ResourceAccessor getFallbackResourceAccessor() {
if (fallbackResourceAccessor == null) {
Expand Down
Expand Up @@ -6,7 +6,7 @@ setlocal enabledelayedexpansion
rem %~dp0 is expanded pathname of the current script under NT
rem %~p0 is the directory of the current script

if exist %~p0\..\liquibase.jar SET LIQUIBASE_HOME=%~p0..
if exist %~p0\..\liquibase.bat SET LIQUIBASE_HOME=%~p0..

if "%LIQUIBASE_HOME%"=="" (
FOR /F "tokens=* USEBACKQ" %%g IN (`where liquibase.bat`) do (SET "LIQUIBASE_HOME=%%~dpg")
Expand Down
Expand Up @@ -80,7 +80,7 @@ class XMLChangeLogSAXParserTest extends Specification {

then:
def e = thrown(ChangeLogParseException)
e.message.contains("Unable to resolve xml entity file:///invalid.txt locally: liquibase.secureParsing is set to 'true' which does not allow remote lookups. Set it to 'false' to allow remote lookups of xsd files")
e.message.contains("Unable to resolve xml entity file:///invalid.txt. liquibase.secureParsing is set to 'true'")
}

def "allows liquibase.secureParsing=false to disable secure parsing"() {
Expand Down

0 comments on commit bbbd3a8

Please sign in to comment.