Skip to content

Commit

Permalink
Merge pull request #816 from dmatej/maven
Browse files Browse the repository at this point in the history
Fixed issues reported by maven when we tried to deploy a pre-release
  • Loading branch information
arjantijms authored Mar 28, 2023
2 parents c19b8db + e61844d commit 828057f
Show file tree
Hide file tree
Showing 14 changed files with 130 additions and 107 deletions.
2 changes: 1 addition & 1 deletion hk2-testing/hk2-junitrunner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<description>A utility for running HK2 tests</description>

<properties>
<links>http://junit.org/javadoc/latest/</links>
<links>https://junit.org/junit4/javadoc/latest/</links>
</properties>

<build>
Expand Down
5 changes: 1 addition & 4 deletions javadocs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<maven.site.skip>true</maven.site.skip>
<maven.site.skip>true</maven.site.skip>
<manifest.location></manifest.location> <!-- to make nullifiy the property -->
</properties>

Expand All @@ -53,9 +53,6 @@
</goals>
<configuration>
<outputDirectory>${project.build.directory}/staging/apidocs</outputDirectory>
<additionalOptions>
<additionalOption>${javadoc.options}</additionalOption>
</additionalOptions>
<sourcepath>
${basedir}/../hk2-api/src/main/java;
${basedir}/../hk2-locator/src/main/java;
Expand Down
4 changes: 4 additions & 0 deletions maven-plugins/consolidatedbundle-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-osgi</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@

package com.sun.enterprise.module.maven;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.artifact.Artifact;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
Expand All @@ -31,6 +26,11 @@
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;

/**
* Generates a consolidated OSGI bundle with a consolidated HK2 header
*
Expand All @@ -53,21 +53,21 @@ public class HK2GenerateMojo extends AbstractMojo {
/**
* Directory where the manifest will be written
*
* @parameter expression="${manifestLocation}"
* default-value="${project.build.outputDirectory}"
* @parameter property="manifestLocation" default-value="${project.build.outputDirectory}"
*/
protected File manifestLocation;
/**
* The maven project.
*
* @parameter expression="${project}"
* @parameter property="project"
* @required
* @readonly
*/
protected MavenProject project;

@SuppressWarnings("unchecked")
@Override
public void execute() throws MojoExecutionException {
@SuppressWarnings("unchecked")
Set<Artifact> dependencyArtifacts = project.getDependencyArtifacts();
if (dependencyArtifacts == null) {
return;
Expand Down
26 changes: 11 additions & 15 deletions maven-plugins/hk2-inhabitant-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,22 @@
<executions>
<execution>
<id>gendir</id>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<testExcludes>
<exclude>**/negative/*</exclude>
<exclude>**/InhabitantsGeneratorTest.java</exclude>
</testExcludes>
<outputDirectory>${project.build.testOutputDirectory}/gendir</outputDirectory>
</configuration>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
<execution>
<id>negative</id>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<testExcludes>
<exclude>generator</exclude>
Expand All @@ -75,9 +78,6 @@
</testIncludes>
<outputDirectory>${project.build.testOutputDirectory}/negative</outputDirectory>
</configuration>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
Expand All @@ -86,7 +86,7 @@
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>>gendir-package</id>
<id>gendir-package</id>
<goals>
<goal>test-jar</goal>
</goals>
Expand Down Expand Up @@ -126,17 +126,14 @@
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<version>${asm.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-tree</artifactId>
<version>${asm.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-util</artifactId>
<version>${asm.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.hk2</groupId>
Expand All @@ -148,15 +145,14 @@
<artifactId>maven-plugin-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${mvn.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -34,49 +35,49 @@
*/
public abstract class AbstractInhabitantsGeneratorMojo extends AbstractMojo {
private final static String WAR_PACKAGING = "war";

private final static String WEB_INF = "WEB-INF";
private final static String CLASSES = "classes";

/**
* @parameter expression="${project.build.directory}"
* @parameter property="project.build.directory"
*/
private File targetDirectory;

/**
* The maven project.
*
* @parameter expression="${project}" @required @readonly
* @parameter property="project" @required @readonly
*/
protected MavenProject project;

/**
* @parameter
*/
private boolean verbose;

/**
* @parameter default-value=true
*/
private boolean includeDate = true;
private final boolean includeDate = true;

/**
* @parameter
*/
private String locator;

/**
* @parameter expression="${supportedProjectTypes}" default-value="jar,ejb,war"
* @parameter property="supportedProjectTypes" default-value="jar,ejb,war"
*/
private String supportedProjectTypes;

protected abstract boolean getNoSwap();
protected abstract File getOutputDirectory();

protected boolean isWar() {
return WAR_PACKAGING.equals(project.getPackaging());
}

/**
* This method will compile the inhabitants file based on
* the classes just compiled
Expand All @@ -91,89 +92,89 @@ public void execute() throws MojoFailureException {
}
return;
}

if (!getOutputDirectory().exists()) {
if (!getOutputDirectory().mkdirs()) {
getLog().info("Could not create output directory " +
getOutputDirectory().getAbsolutePath());
return;
}
}

if (!getOutputDirectory().exists()) {
getLog().info("Exiting hk2-inhabitant-generator because could not find output directory " +
getOutputDirectory().getAbsolutePath());
return;
}

if (verbose) {
getLog().info("");
getLog().info("hk2-inhabitant-generator generating into location " + getOutputDirectory().getAbsolutePath());
getLog().info("");
}
LinkedList<String> arguments = new LinkedList<String>();

LinkedList<String> arguments = new LinkedList<>();

arguments.add(HabitatGenerator.FILE_ARG);
arguments.add(getOutputDirectory().getAbsolutePath());

if (verbose) {
arguments.add(HabitatGenerator.VERBOSE_ARG);
}

if (locator != null) {
arguments.add(HabitatGenerator.LOCATOR_ARG);
arguments.add(locator);
}

arguments.add(HabitatGenerator.SEARCHPATH_ARG);
arguments.add(getBuildClasspath());

if (getNoSwap()) {
arguments.add(HabitatGenerator.NOSWAP_ARG);
}

if (!includeDate) {
arguments.add(HabitatGenerator.NO_DATE_ARG);
}

if (isWar()) {
// For WAR files, the hk2-locator files goes under WEB-INF/classes/hk2-locator, not META-INF/hk2-locator

File outDir = new File(targetDirectory, project.getBuild().getFinalName());
outDir = new File(outDir, WEB_INF);
outDir = new File(outDir, CLASSES);
outDir = new File(outDir, HabitatGenerator.HK2_LOCATOR);

arguments.add(HabitatGenerator.DIRECTORY_ARG);
arguments.add(outDir.getAbsolutePath());
}

String argv[] = arguments.toArray(new String[arguments.size()]);

int result = HabitatGenerator.embeddedMain(argv);
if (result != 0) {
throw new MojoFailureException("Could not generate inhabitants file for " + getOutputDirectory());
}
}

@SuppressWarnings("unchecked")
private String getBuildClasspath() {
StringBuilder sb = new StringBuilder();

sb.append(project.getBuild().getOutputDirectory());
sb.append(File.pathSeparator);

if (!getOutputDirectory().getAbsolutePath().equals(
project.getBuild().getOutputDirectory())) {

sb.append(getOutputDirectory().getAbsolutePath());
sb.append(File.pathSeparator);
}

List<Artifact> artList = new ArrayList<Artifact>(project.getArtifacts());
List<Artifact> artList = new ArrayList<>(project.getArtifacts());
Iterator<Artifact> i = artList.iterator();

if (i.hasNext()) {
sb.append(i.next().getFile().getPath());

Expand All @@ -182,7 +183,7 @@ private String getBuildClasspath() {
sb.append(i.next().getFile().getPath());
}
}

String classpath = sb.toString();
if(verbose){
getLog().info("");
Expand All @@ -192,5 +193,5 @@ private String getBuildClasspath() {
getLog().info("");
}
return classpath;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@

/**
* Generates inhabitant
*
*
* @goal generate-inhabitants
* @phase process-classes
* @phase process-classes
* @threadSafe true
* @requiresDependencyResolution test
*/
public class InhabitantsGeneratorMojo extends AbstractInhabitantsGeneratorMojo {

/**
* @parameter expression="${project.build.outputDirectory}"
* @parameter property="project.build.outputDirectory"
*/
private File outputDirectory;

/**
* @parameter default-value="true"
*/
Expand Down
Loading

0 comments on commit 828057f

Please sign in to comment.