Skip to content

Commit

Permalink
grouper docker container: store jar files for ui, ws, and scim in the…
Browse files Browse the repository at this point in the history
…ir own directories
  • Loading branch information
Vivek Sachdeva committed Mar 21, 2020
1 parent 1d62578 commit 0d49e73
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 54 deletions.
1 change: 1 addition & 0 deletions grouper-container/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
35 changes: 35 additions & 0 deletions grouper-container/grouper-api-container/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edu.internet2.middleware.grouper</groupId>
<artifactId>grouper-container</artifactId>
<version>2.5.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>grouper-container</name>

<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>nexus-releases</id>
<url>https://oss.sonatype.org/content/repositories/releases/</url>
</repository>
<repository>
<!-- there is a slight delay between releasing a staged repo and showing up in the release repo;
fall back to the local content repo which shows up sooner -->
<id>nexus-services</id>
<url>https://oss.sonatype.org/service/local/repositories/releases/content/</url>
</repository>
</repositories>
<!-- Pass in Maven command line parameter -Dgrouper.version=a.b.c ... -->
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>grouper</artifactId>
<version>${grouper.version}</version>
</dependency>
</dependencies>

</project>
36 changes: 36 additions & 0 deletions grouper-container/grouper-scim-container/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edu.internet2.middleware.grouper</groupId>
<artifactId>grouper-container</artifactId>
<version>2.5.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>grouper-container</name>

<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>nexus-releases</id>
<url>https://oss.sonatype.org/content/repositories/releases/</url>
</repository>
<repository>
<!-- there is a slight delay between releasing a staged repo and showing up in the release repo;
fall back to the local content repo which shows up sooner -->
<id>nexus-services</id>
<url>https://oss.sonatype.org/service/local/repositories/releases/content/</url>
</repository>
</repositories>
<!-- Pass in Maven command line parameter -Dgrouper.version=a.b.c ... -->
<dependencies>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>grouper-ws-scim</artifactId>
<version>${grouper.version}</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,6 @@
</repositories>
<!-- Pass in Maven command line parameter -Dgrouper.version=a.b.c ... -->
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>grouper</artifactId>
<version>${grouper.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>grouper-ws</artifactId>
<version>${grouper.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>grouper-ws-scim</artifactId>
<version>${grouper.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>grouper-ui</artifactId>
Expand Down
35 changes: 35 additions & 0 deletions grouper-container/grouper-ws-container/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edu.internet2.middleware.grouper</groupId>
<artifactId>grouper-container</artifactId>
<version>2.5.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>grouper-container</name>

<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>nexus-releases</id>
<url>https://oss.sonatype.org/content/repositories/releases/</url>
</repository>
<repository>
<!-- there is a slight delay between releasing a staged repo and showing up in the release repo;
fall back to the local content repo which shows up sooner -->
<id>nexus-services</id>
<url>https://oss.sonatype.org/service/local/repositories/releases/content/</url>
</repository>
</repositories>
<!-- Pass in Maven command line parameter -Dgrouper.version=a.b.c ... -->
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>grouper-ws</artifactId>
<version>${grouper.version}</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -10454,35 +10454,6 @@ private void mainBuildContainerLogic() {
String grouperUntarredReleaseDir = untarredGrouperSourceCodeDir.getAbsolutePath().substring(0, untarredGrouperSourceCodeDir.getAbsolutePath().lastIndexOf(File.separator));
grouperUntarredReleaseDir = grouperUntarredReleaseDir + File.separator + "grouper-" + untarredGrouperSourceCodeDir.getName() ;

// go in grouper-container and run mvn dependency:copy-dependencies
List<File> grouperProjects = new ArrayList<File>();

grouperProjects.add(new File(grouperUntarredReleaseDir + File.separator + "grouper-container"));

List<String> commands = new ArrayList<String>();
addMavenCommands(commands);

commands.add("-DincludeScope=runtime");
commands.add("-Dgrouper.version="+this.version);

commands.add("dependency:copy-dependencies");

for (File file: grouperProjects) {
System.out.println("\n##################################");
System.out.println("Downloading third party jars for "+ file.getName()+" with command:\n"
+ convertCommandsIntoCommand(commands) + "\n");

CommandResult commandResult = GrouperInstallerUtils.execCommand(GrouperInstallerUtils.toArray(commands, String.class),
true, true, null, new File(file.getAbsolutePath()), null, true);

if (!GrouperInstallerUtils.isBlank(commandResult.getErrorText())) {
System.out.println("stderr: " + commandResult.getErrorText());
}
if (!GrouperInstallerUtils.isBlank(commandResult.getOutputText())) {
System.out.println("stdout: " + commandResult.getOutputText());
}
}

// now create an output directory (webapp) and tomee
String containerDirString = grouperContainerDirectory();
File containerTomeeDir = new File(containerDirString + "tomee");
Expand All @@ -10498,8 +10469,19 @@ private void mainBuildContainerLogic() {
webInfDir.mkdirs(); // should already be there
File webInfConfDir = new File(webInfDir+File.separator+"conf");
webInfConfDir.mkdirs();

File libDir = new File(webInfDir+File.separator+"lib");
libDir.mkdirs();

File libUiAndDaemonDir = new File(webInfDir+File.separator+"libUiAndDaemon");
libUiAndDaemonDir.mkdirs();

File libWsDir = new File(webInfDir+File.separator+"libWs");
libWsDir.mkdirs();

File libScimDir = new File(webInfDir+File.separator+"libScim");
libScimDir.mkdirs();

File modulesDir = new File(webInfDir+File.separator+"modules");
modulesDir.mkdirs();
File servicesDir = new File(webInfDir+File.separator+"services");
Expand All @@ -10509,24 +10491,73 @@ private void mainBuildContainerLogic() {
File binDir = new File(webInfDir+File.separator+"bin");
binDir.mkdirs();

// now copy all dependency jars into container/webapp/WEB-INF/lib
// go in grouper-container and run mvn dependency:copy-dependencies
Map<File, File> projectDirToOutputLibDir = new LinkedHashMap<File, File>();
projectDirToOutputLibDir.put(new File(grouperUntarredReleaseDir + File.separator + "grouper-container" + File.separator + "grouper-api-container"), libDir);
projectDirToOutputLibDir.put(new File(grouperUntarredReleaseDir + File.separator + "grouper-container" + File.separator + "grouper-uiDaemon-container"), libUiAndDaemonDir);
projectDirToOutputLibDir.put(new File(grouperUntarredReleaseDir + File.separator + "grouper-container" + File.separator + "grouper-ws-container"), libWsDir);
projectDirToOutputLibDir.put(new File(grouperUntarredReleaseDir + File.separator + "grouper-container" + File.separator + "grouper-scim-container"), libScimDir);

List<String> commands = new ArrayList<String>();
addMavenCommands(commands);

commands.add("-DincludeScope=runtime");
commands.add("-Dgrouper.version="+this.version);

commands.add("dependency:copy-dependencies");

for (File file: projectDirToOutputLibDir.keySet()) {
System.out.println("\n##################################");
System.out.println("Downloading third party jars for "+ file.getName()+" with command:\n"
+ convertCommandsIntoCommand(commands) + "\n");

CommandResult commandResult = GrouperInstallerUtils.execCommand(GrouperInstallerUtils.toArray(commands, String.class),
true, true, null, new File(file.getAbsolutePath()), null, true);

if (!GrouperInstallerUtils.isBlank(commandResult.getErrorText())) {
System.out.println("stderr: " + commandResult.getErrorText());
}
if (!GrouperInstallerUtils.isBlank(commandResult.getOutputText())) {
System.out.println("stdout: " + commandResult.getOutputText());
}
}

// now copy all dependency jars into corresponding container/webapp/WEB-INF/lib{""|UiAndDaemon|Ws|Scim|}
try {
for (File file: grouperProjects) {
Set<String> allGrouperApiJars = new HashSet<String>();
for (File file: projectDirToOutputLibDir.keySet()) {
File jarsDirectory = new File(file.getAbsolutePath()+File.separator+"target"+File.separator+"dependency");
GrouperInstallerUtils.copyDirectory(jarsDirectory, libDir, null, true);

if (allGrouperApiJars.size() == 0) { // we are relying on the first item in projectDirToOutputLibDir being the grouper api
for (File jarFile: findAllLibraryFiles(jarsDirectory.getAbsolutePath())) {
allGrouperApiJars.add(jarFile.getName());
}
// copy the grouper api jars into container/webapp/WEB-INF/lib
GrouperInstallerUtils.copyDirectory(jarsDirectory, projectDirToOutputLibDir.get(file), null, true);
continue;
}

// make sure the jar file is already not there
for (File jarFile: findAllLibraryFiles(jarsDirectory.getAbsolutePath())) {
if (allGrouperApiJars.contains(jarFile.getName()) == false) {
File destFile = new File(projectDirToOutputLibDir.get(file).getAbsolutePath() + File.separator + jarFile.getName());
GrouperInstallerUtils.copyFile(jarFile, destFile);
}
}

}
} catch (Exception e) {
throw new RuntimeException("Could not copy jars from dependency directories ", e);
}

// delete all grouper snapshots jars from WEB-INF/lib
List<File> allLibraryJars = findAllLibraryFiles(libDir.getAbsolutePath());

for (File file: allLibraryJars) {
if (file.getName().contains("grouper") && file.getName().contains("SNAPSHOT")) {
GrouperInstallerUtils.fileDelete(file);
}
}
// List<File> allLibraryJars = findAllLibraryFiles(libDir.getAbsolutePath());
//
// for (File file: allLibraryJars) {
// if (file.getName().contains("grouper") && file.getName().contains("SNAPSHOT")) {
// GrouperInstallerUtils.fileDelete(file);
// }
// }

// now copy grouper/conf, grouper-ws/conf, grouper-ui/conf and grouperClient/conf to classesDir

Expand Down Expand Up @@ -10605,6 +10636,9 @@ public boolean accept(File dir, String name) {

// take care of conflicting jars
reportOnConflictingJars(libDir.getAbsolutePath());
reportOnConflictingJars(libUiAndDaemonDir.getAbsolutePath());
reportOnConflictingJars(libWsDir.getAbsolutePath());
reportOnConflictingJars(libScimDir.getAbsolutePath());

// copy apache-tomee-webprofile-7.0.7 to tomee
// why can't uncompressed directory has the same name??? :((
Expand Down

0 comments on commit 0d49e73

Please sign in to comment.