mirror of
https://github.com/anchore/syft.git
synced 2026-11-01 06:56:40 +01:00
reduce java packages to java-archive and jenkins-plugin
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
/packages/*
|
||||
*.fingerprint
|
||||
# maven when running in a volume may spit out directories like this
|
||||
**/\?/
|
||||
\?/
|
||||
@@ -0,0 +1,45 @@
|
||||
PKGSDIR=packages
|
||||
|
||||
ifndef PKGSDIR
|
||||
$(error PKGSDIR is not set)
|
||||
endif
|
||||
|
||||
all: $(PKGSDIR)/example-java-app-maven-0.1.0.jar $(PKGSDIR)/example-java-app-gradle-0.1.0.jar $(PKGSDIR)/example-jenkins-plugin.hpi
|
||||
|
||||
clean: clean-examples
|
||||
rm -f $(PKGSDIR)/*
|
||||
|
||||
clean-examples: clean-gradle clean-maven clean-jenkins
|
||||
|
||||
.PHONY: maven gradle clean clean-gradle clean-maven clean-jenkins clean-examples
|
||||
|
||||
# Maven...
|
||||
$(PKGSDIR)/example-java-app-maven-0.1.0.jar:
|
||||
./build-example-java-app-maven.sh $(PKGSDIR)
|
||||
|
||||
clean-maven:
|
||||
rm -rf example-java-app/target \
|
||||
example-java-app/dependency-reduced-pom.xml
|
||||
|
||||
# Gradle...
|
||||
$(PKGSDIR)/example-java-app-gradle-0.1.0.jar:
|
||||
./build-example-java-app-gradle.sh $(PKGSDIR)
|
||||
|
||||
clean-gradle:
|
||||
rm -rf example-java-app/.gradle \
|
||||
example-java-app/build
|
||||
|
||||
# Jenkins plugin
|
||||
$(PKGSDIR)/example-jenkins-plugin.hpi , $(PKGSDIR)/example-jenkins-plugin.jar:
|
||||
./build-example-jenkins-plugin.sh $(PKGSDIR)
|
||||
|
||||
clean-jenkins:
|
||||
rm -rf example-jenkins-plugin/target \
|
||||
example-jenkins-plugin/dependency-reduced-pom.xml \
|
||||
example-jenkins-plugin/*.exploding
|
||||
|
||||
# we need a way to determine if CI should bust the test cache based on the source material
|
||||
$(PKGSDIR).fingerprint: clean-examples
|
||||
mkdir -p $(PKGSDIR)
|
||||
find example-* -type f -exec sha256sum {} \; > $(PKGSDIR).fingerprint
|
||||
sha256sum $(PKGSDIR).fingerprint
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
set -uxe
|
||||
|
||||
# note: this can be easily done in a 1-liner, however circle CI does NOT allow volume mounts from the host in docker executors (since they are on remote hosts, where the host files are inaccessible)
|
||||
|
||||
PKGSDIR=$1
|
||||
CTRID=$(docker create -u "$(id -u):$(id -g)" -v /example-java-app -w /example-java-app gradle:jdk gradle build)
|
||||
|
||||
function cleanup() {
|
||||
docker rm "${CTRID}"
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
set +e
|
||||
|
||||
docker cp "$(pwd)/example-java-app" "${CTRID}:/"
|
||||
docker start -a "${CTRID}"
|
||||
mkdir -p "$PKGSDIR"
|
||||
docker cp "${CTRID}:/example-java-app/build/libs/example-java-app-gradle-0.1.0.jar" "$PKGSDIR"
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
set -uxe
|
||||
|
||||
# note: this can be easily done in a 1-liner, however circle CI does NOT allow volume mounts from the host in docker executors (since they are on remote hosts, where the host files are inaccessible)
|
||||
|
||||
PKGSDIR=$1
|
||||
CTRID=$(docker create -u "$(id -u):$(id -g)" -e MAVEN_CONFIG=/tmp/.m2 -v /example-java-app -w /example-java-app maven:openjdk mvn -Duser.home=/tmp -DskipTests package)
|
||||
|
||||
function cleanup() {
|
||||
docker rm "${CTRID}"
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
set +e
|
||||
|
||||
docker cp "$(pwd)/example-java-app" "${CTRID}:/"
|
||||
docker start -a "${CTRID}"
|
||||
mkdir -p "$PKGSDIR"
|
||||
docker cp "${CTRID}:/example-java-app/target/example-java-app-maven-0.1.0.jar" "$PKGSDIR"
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
set -uxe
|
||||
|
||||
# note: this can be easily done in a 1-liner, however circle CI does NOT allow volume mounts from the host in docker executors (since they are on remote hosts, where the host files are inaccessible)
|
||||
|
||||
PKGSDIR=$1
|
||||
CTRID=$(docker create -u "$(id -u):$(id -g)" -e MAVEN_CONFIG=/tmp/.m2 -v /example-jenkins-plugin -w /example-jenkins-plugin maven:openjdk mvn -Duser.home=/tmp -DskipTests package)
|
||||
|
||||
function cleanup() {
|
||||
docker rm "${CTRID}"
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
set +e
|
||||
|
||||
docker cp "$(pwd)/example-jenkins-plugin" "${CTRID}:/"
|
||||
docker start -a "${CTRID}"
|
||||
mkdir -p "$PKGSDIR"
|
||||
docker cp "${CTRID}:/example-jenkins-plugin/target/example-jenkins-plugin.hpi" "$PKGSDIR"
|
||||
docker cp "${CTRID}:/example-jenkins-plugin/target/example-jenkins-plugin.jar" "$PKGSDIR"
|
||||
@@ -0,0 +1,6 @@
|
||||
# maven build creates this when in a container volume
|
||||
/?/
|
||||
/.gradle/
|
||||
/build/
|
||||
target/
|
||||
dependency-reduced-pom.xml
|
||||
@@ -0,0 +1,31 @@
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'application'
|
||||
|
||||
mainClassName = 'hello.HelloWorld'
|
||||
|
||||
// tag::repositories[]
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
// end::repositories[]
|
||||
|
||||
// tag::jar[]
|
||||
jar {
|
||||
baseName = 'example-java-app-gradle'
|
||||
version = '0.1.0'
|
||||
}
|
||||
// end::jar[]
|
||||
|
||||
// tag::dependencies[]
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
dependencies {
|
||||
compile "joda-time:joda-time:2.2"
|
||||
testCompile "junit:junit:4.12"
|
||||
}
|
||||
// end::dependencies[]
|
||||
|
||||
// tag::wrapper[]
|
||||
// end::wrapper[]
|
||||
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.anchore</groupId>
|
||||
<artifactId>example-java-app-maven</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>0.1.0</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- tag::joda[] -->
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
<!-- end::joda[] -->
|
||||
<!-- tag::junit[] -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- end::junit[] -->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>hello.HelloWorld</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package hello;
|
||||
|
||||
public class Greeter {
|
||||
public String sayHello() {
|
||||
return "Hello world!";
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package hello;
|
||||
|
||||
import org.joda.time.LocalTime;
|
||||
|
||||
public class HelloWorld {
|
||||
public static void main(String[] args) {
|
||||
LocalTime currentTime = new LocalTime();
|
||||
System.out.println("The current local time is: " + currentTime);
|
||||
|
||||
Greeter greeter = new Greeter();
|
||||
System.out.println(greeter.sayHello());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.jenkins-ci.plugins</groupId>
|
||||
<artifactId>plugin</artifactId>
|
||||
<version>3.50</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
<groupId>io.jenkins.plugins</groupId>
|
||||
<artifactId>example-jenkins-plugin</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>hpi</packaging>
|
||||
<properties>
|
||||
<!-- Baseline Jenkins version you use to build the plugin. Users must have this version or newer to run. -->
|
||||
<jenkins.version>2.164.3</jenkins.version>
|
||||
<java.level>8</java.level>
|
||||
<!-- Other properties you may want to use:
|
||||
~ jenkins-test-harness.version: Jenkins Test Harness version you use to test the plugin. For Jenkins version >= 1.580.1 use JTH 2.0 or higher.
|
||||
~ hpi-plugin.version: The HPI Maven Plugin version used by the plugin..
|
||||
~ stapler-plugin.version: The Stapler Maven plugin version required by the plugin.
|
||||
-->
|
||||
</properties>
|
||||
<name>TODO Plugin</name>
|
||||
<!-- The default licence for Jenkins OSS Plugins is MIT. Substitute for the applicable one if needed. -->
|
||||
<licenses>
|
||||
<license>
|
||||
<name>MIT License</name>
|
||||
<url>https://opensource.org/licenses/MIT</url>
|
||||
</license>
|
||||
</licenses>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<!-- Pick up common dependencies for 2.164.x: https://github.com/jenkinsci/bom#usage -->
|
||||
<groupId>io.jenkins.tools.bom</groupId>
|
||||
<artifactId>bom-2.164.x</artifactId>
|
||||
<version>3</version>
|
||||
<scope>import</scope>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jenkins-ci.plugins</groupId>
|
||||
<artifactId>structs</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jenkins-ci.plugins.workflow</groupId>
|
||||
<artifactId>workflow-cps</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jenkins-ci.plugins.workflow</groupId>
|
||||
<artifactId>workflow-job</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jenkins-ci.plugins.workflow</groupId>
|
||||
<artifactId>workflow-basic-steps</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jenkins-ci.plugins.workflow</groupId>
|
||||
<artifactId>workflow-durable-task-step</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- If you want this to appear on the wiki page:
|
||||
<developers>
|
||||
<developer>
|
||||
<id>bhacker</id>
|
||||
<name>Bob Q. Hacker</name>
|
||||
<email>bhacker@nowhere.net</email>
|
||||
</developer>
|
||||
</developers> -->
|
||||
|
||||
<!-- Assuming you want to host on @jenkinsci:
|
||||
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git</developerConnection>
|
||||
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url>
|
||||
</scm>
|
||||
-->
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>repo.jenkins-ci.org</id>
|
||||
<url>https://repo.jenkins-ci.org/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>repo.jenkins-ci.org</id>
|
||||
<url>https://repo.jenkins-ci.org/public/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</project>
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
package io.jenkins.plugins.sample;
|
||||
|
||||
import hudson.Launcher;
|
||||
import hudson.Extension;
|
||||
import hudson.FilePath;
|
||||
import hudson.util.FormValidation;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.Run;
|
||||
import hudson.model.TaskListener;
|
||||
import hudson.tasks.Builder;
|
||||
import hudson.tasks.BuildStepDescriptor;
|
||||
import org.kohsuke.stapler.DataBoundConstructor;
|
||||
import org.kohsuke.stapler.QueryParameter;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import java.io.IOException;
|
||||
import jenkins.tasks.SimpleBuildStep;
|
||||
import org.jenkinsci.Symbol;
|
||||
import org.kohsuke.stapler.DataBoundSetter;
|
||||
|
||||
public class HelloWorldBuilder extends Builder implements SimpleBuildStep {
|
||||
|
||||
private final String name;
|
||||
private boolean useFrench;
|
||||
|
||||
@DataBoundConstructor
|
||||
public HelloWorldBuilder(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isUseFrench() {
|
||||
return useFrench;
|
||||
}
|
||||
|
||||
@DataBoundSetter
|
||||
public void setUseFrench(boolean useFrench) {
|
||||
this.useFrench = useFrench;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(Run<?, ?> run, FilePath workspace, Launcher launcher, TaskListener listener) throws InterruptedException, IOException {
|
||||
if (useFrench) {
|
||||
listener.getLogger().println("Bonjour, " + name + "!");
|
||||
} else {
|
||||
listener.getLogger().println("Hello, " + name + "!");
|
||||
}
|
||||
}
|
||||
|
||||
@Symbol("greet")
|
||||
@Extension
|
||||
public static final class DescriptorImpl extends BuildStepDescriptor<Builder> {
|
||||
|
||||
public FormValidation doCheckName(@QueryParameter String value, @QueryParameter boolean useFrench)
|
||||
throws IOException, ServletException {
|
||||
if (value.length() == 0)
|
||||
return FormValidation.error(Messages.HelloWorldBuilder_DescriptorImpl_errors_missingName());
|
||||
if (value.length() < 4)
|
||||
return FormValidation.warning(Messages.HelloWorldBuilder_DescriptorImpl_warnings_tooShort());
|
||||
if (!useFrench && value.matches(".*[éáàç].*")) {
|
||||
return FormValidation.warning(Messages.HelloWorldBuilder_DescriptorImpl_warnings_reallyFrench());
|
||||
}
|
||||
return FormValidation.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(Class<? extends AbstractProject> aClass) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return Messages.HelloWorldBuilder_DescriptorImpl_DisplayName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
<?jelly escape-by-default='true'?>
|
||||
<div>
|
||||
TODO
|
||||
</div>
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?jelly escape-by-default='true'?>
|
||||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
|
||||
<f:entry title="${%Name}" field="name">
|
||||
<f:textbox />
|
||||
</f:entry>
|
||||
<f:advanced>
|
||||
<f:entry title="${%French}" field="useFrench"
|
||||
description="${%FrenchDescr}">
|
||||
<f:checkbox />
|
||||
</f:entry>
|
||||
</f:advanced>
|
||||
</j:jelly>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
Name=Name
|
||||
French=French
|
||||
FrenchDescr=Check if we should say hello in French
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
Name=Nom
|
||||
French=Fran\u00e7ais
|
||||
FrenchDescr=V\u00e9rifie qu'on dit bien hello en fran\u00e7ais
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
<div>
|
||||
Your name.
|
||||
</div>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
<div>
|
||||
Votre nom.
|
||||
</div>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
<div>
|
||||
Use French?
|
||||
</div>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
<div>
|
||||
Utiliser le français ?
|
||||
</div>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
HelloWorldBuilder.DescriptorImpl.errors.missingName=Please set a name
|
||||
HelloWorldBuilder.DescriptorImpl.warnings.tooShort=Isn't the name too short?
|
||||
HelloWorldBuilder.DescriptorImpl.warnings.reallyFrench=Are you actually French?
|
||||
|
||||
HelloWorldBuilder.DescriptorImpl.DisplayName=Say hello world
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
HelloWorldBuilder.DescriptorImpl.errors.missingName=Veuillez saisir un nom
|
||||
HelloWorldBuilder.DescriptorImpl.warnings.tooShort=Le nom n'est-il pas trop court ?
|
||||
HelloWorldBuilder.DescriptorImpl.warnings.reallyFrench=\u00CAtes vous vraiment fran\u00E7ais ?
|
||||
|
||||
HelloWorldBuilder.DescriptorImpl.DisplayName=Dis hello world
|
||||
Reference in New Issue
Block a user