Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Sbol version range #330

Merged
merged 8 commits into from
Sep 12, 2019
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ FROM adoptopenjdk/openjdk8-openj9

USER root
RUN apt-get -qq update \
&& apt-get -qq install -y curl maven wget unzip\
&& apt-get -qq install -y curl maven wget unzip xmlstarlet \
&& DEBIAN_FRONTEND=noninteractive apt-get -qq upgrade -y \
&& apt-get -qq clean \
&& rm -rf /tmp/* /var/lib/apt/lists/*

COPY ./LICENSE /licenses/
COPY ./project /project
COPY ./config /config

RUN /project/util/check_version build

WORKDIR /project/

RUN mkdir -p /mvn/repository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
FROM adoptopenjdk/openjdk8-openj9

RUN apt-get update && \
apt-get install -y maven unzip wget
apt-get install -y maven unzip wget xmlstarlet

COPY . /project

RUN /project/util/check_version build

RUN cd /project && mvn -B install dependency:go-offline -DskipTests

WORKDIR /project/user-app

RUN mvn -B install -DskipTests
Expand All @@ -21,4 +25,4 @@ COPY --chown=1001:0 --from=0 /config/ /config/
COPY --chown=1001:0 --from=0 /lib.index.cache/ /lib.index.cache/

EXPOSE 9080
EXPOSE 9443
EXPOSE 9443
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<groupId>dev.appsody</groupId>
<artifactId>java-spring-boot2-liberty</artifactId>
<version>0.1.7</version>
<version>0.1.8</version>
<packaging>pom</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import org.osgi.framework.VersionRange;
import org.osgi.framework.Version;

public class RangeIncludesVersion {

public static void main(String[] args) {
if ( args.length < 2 ) {
System.out.println("Must specify range and version");
System.exit(1);
}
String range = args[0];
String version = args[1];

boolean result = VersionRange.valueOf(range).includes(Version.valueOf(version));
System.exit( result ? 0 : 1 );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
# This is a small utility script that uses OSGi VersionRange and Version
# classes to verify whether or not a specified version matches is contained
# within a specified range.
#
cd "$( dirname "${BASH_SOURCE[0]}" )"

if [ $# -lt 1 ]; then
ACTION=range
else
ACTION=$1
shift
fi

range_check() {
java -cp .:org.osgi.core-6.0.0.jar RangeIncludesVersion "$1" "$2"
return $?
}

sniff() {
range_check "$1" "$2"
if [ $? -ne $3 ]; then
echo "Test |'$1' contains '$2'| should return $3. Got $?"
exit 1
fi
}

case "$ACTION" in
build)
wget -q https://repo1.maven.org/maven2/org/osgi/org.osgi.core/6.0.0/org.osgi.core-6.0.0.jar
javac -cp org.osgi.core-6.0.0.jar *.java

sniff "[0.3,0.4)" "0.3.7" 0
sniff "[0.3,0.4)" "0.4" 1
sniff "[0.3,0.4)" "0.2" 1
exit 0
;;
contains)
if [ $# -lt 2 ]; then
echo "Specify version information: check_version contains <range_spec> <version>"
exit 1
fi

range_check "$1" "$2"
exit $?
;;
esac

42 changes: 35 additions & 7 deletions experimental/java-spring-boot2-liberty/image/project/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,43 @@ eval $(mvn -q -Dexec.executable=echo -Dexec.args="${args}" --non-recursive -f ..
echo "Installing parent ${PARENT_GROUP_ID}:${PARENT_ARTIFACT_ID}:${PARENT_VERSION}"
mvn install -Dmaven.repo.local=/mvn/repository -Denforcer.skip=true -f ../pom.xml

# Get parent pom information
a_groupId=$(xmlstarlet sel -T -N x="http://maven.apache.org/POM/4.0.0" -t -v "/x:project/x:groupId" /project/pom.xml)
a_artifactId=$(xmlstarlet sel -T -N x="http://maven.apache.org/POM/4.0.0" -t -v "/x:project/x:artifactId" /project/pom.xml)
a_version=$(xmlstarlet sel -T -N x="http://maven.apache.org/POM/4.0.0" -t -v "/x:project/x:version" /project/pom.xml)
p_groupId=$(xmlstarlet sel -T -N x="http://maven.apache.org/POM/4.0.0" -t -v "/x:project/x:parent/x:groupId" pom.xml)
p_artifactId=$(xmlstarlet sel -T -N x="http://maven.apache.org/POM/4.0.0" -t -v "/x:project/x:parent/x:artifactId" pom.xml)
p_version_range=$(xmlstarlet sel -T -N x="http://maven.apache.org/POM/4.0.0" -t -v "/x:project/x:parent/x:version" pom.xml)

# Check child pom for required parent project
if ! grep -Gz "<parent>.*<groupId>${PARENT_GROUP_ID}</groupId>.*</parent>" pom.xml | grep -Gz "<parent>.*<artifactId>${PARENT_ARTIFACT_ID}</artifactId>.*</parent>" | grep -Gzq "<parent>.*<version>${PARENT_VERSION}</version>.*</parent>"
then
echo "Project is missing required parent:
if [ "${p_groupId}" != "${a_groupId}" ] || [ "${p_artifactId}" != "${a_artifactId}" ]; then
error "Project pom.xml is missing the required parent:

<parent>
<groupId>${PARENT_GROUP_ID}</groupId>
<artifactId>${PARENT_ARTIFACT_ID}</artifactId>
<version>${PARENT_VERSION}</version>
</parent>"
<groupId>${a_groupId}</groupId>
<artifactId>${a_artifactId}</artifactId>
<version>${a_range}</version>
<relativePath/>
</parent>
"
exit 1
fi

# Check parent version
if ! /project/util/check_version contains "$p_version_range" "$a_version"; then
echo "Version mismatch

The version of the appsody stack '${a_version}' does not match the
parent version specified in pom.xml '${p_version_range}'. Please update
the parent version in pom.xml, and test your changes.

<parent>
<groupId>${a_groupId}</groupId>
<artifactId>${a_artifactId}</artifactId>
<version>${a_range}</version>
<relativePath/>
</parent>
"
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion experimental/java-spring-boot2-liberty/stack.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Spring Boot® on Open Liberty
version: 0.1.7
version: 0.1.8
description: Spring Boot on Open Liberty & OpenJ9 using Maven
license: Apache-2.0
language: java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

<modelVersion>4.0.0</modelVersion>

<parent>
<parent><!--required parent POM-->
<groupId>dev.appsody</groupId>
<artifactId>java-spring-boot2-liberty</artifactId>
<version>0.1.7</version>
<version>[0.1, 0.2)</version>
<relativePath/>
</parent>

<groupId>dev.appsody.starter.java-spring-boot2-liberty</groupId>
Expand Down