Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit eddba00

Browse files
makes cleanupDanglingUnityFiles run before every unity task (#82)
* adds dangling unity assets cleanup task before every unity run * iupdate java minimum version to java 11
1 parent d80b34d commit eddba00

File tree

5 files changed

+46
-24
lines changed

5 files changed

+46
-24
lines changed

Dockerfile

+14-21
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,25 @@
1-
FROM openjdk:8-jdk
1+
ARG RUST_VERSION=1.50.0
22

3+
FROM rust:$RUST_VERSION
4+
ARG UVM_VERSION=2.2.0
35

4-
RUN mkdir -p /home/ci
5-
6-
# Create an app user so our program doesn't run as root.
7-
RUN groupadd -r ci &&\
8-
useradd -r -g ci -d /home/ci -s /sbin/nologin -c "Docker image user" ci
9-
10-
# Set the home directory to our app user's home.
11-
ENV HOME=/home/ci
126
ENV RUST_BACKTRACE=1
137
ENV RUST_LOG="warning, uvm_core=trace, uvm_jni=trace"
148
ENV IN_DOCKER="1"
159

16-
RUN apt-get update
17-
RUN apt-get install -y build-essential libssl-dev pkg-config openssl p7zip-full cpio -y
1810

19-
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
11+
RUN curl -Lo "unity-version-manager-$UVM_VERSION.tar.gz" "https://github.com/Larusso/unity-version-manager/archive/v$UVM_VERSION.tar.gz"
12+
RUN tar -xzf "unity-version-manager-$UVM_VERSION.tar.gz" && rm "unity-version-manager-$UVM_VERSION.tar.gz"
13+
14+
RUN cd "unity-version-manager-$UVM_VERSION" && PATH="${HOME}/.cargo/bin:$PATH" make install
2015

21-
ENV PATH="${HOME}/.cargo/bin:${PATH}"
16+
FROM openjdk:11-jdk-buster
17+
ARG USER_ID=1001
18+
ARG GROUP_ID=100
2219

23-
WORKDIR /home/ci/
20+
RUN useradd -u ${USER_ID} -g ${GROUP_ID} --create-home jenkins_agent
2421

25-
RUN curl -Lo unity-version-manager-2.2.0.tar.gz https://github.com/Larusso/unity-version-manager/archive/v2.2.0.tar.gz && \
26-
tar -xzf unity-version-manager-2.2.0.tar.gz && \
27-
cd unity-version-manager-2.2.0 && make install && \
28-
uvm install 2019.1.0a7 /home/ci/.local/share/Unity-2019.1.0a7
22+
USER jenkins_agent
23+
COPY --from=0 /usr/local/bin/uvm* ./usr/local/bin/
2924

30-
# Chown all the files to the app user.
31-
RUN chown -R ci:ci $HOME
32-
RUN chmod -R 777 $HOME
25+
RUN uvm install 2019.1.0a7 /home/jenkins_agent/.local/share/Unity-2019.1.0a7

Jenkinsfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ withCredentials([
55
string(credentialsId: 'atlas_plugins_sonar_token', variable: 'sonar_token'),
66
string(credentialsId: 'snyk-wooga-frontend-integration-token', variable: 'SNYK_TOKEN')
77
]) {
8-
buildGradlePlugin platforms: ['macos', 'windows', 'linux'], sonarToken: sonar_token
8+
buildGradlePlugin platforms: ['macos', 'windows', 'linux'],
9+
sonarToken: sonar_token,
10+
dockerArgs: [ dockerArgs: ['-v', '/home/jenkins_agent/.gradle:/home/jenkins_agent/.gradle'] ]
911
}

build.gradle

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
plugins {
19-
id 'net.wooga.plugins' version '5.0.0-rc.2'
19+
id 'net.wooga.plugins' version '5.0.0'
2020
id 'net.wooga.snyk' version '0.12.0'
2121
id 'net.wooga.snyk-gradle-plugin' version '0.6.0'
2222
id "net.wooga.cve-dependency-resolution" version "0.4.0"
@@ -25,6 +25,9 @@ plugins {
2525
group 'net.wooga.gradle'
2626
description = 'Plugin for wooga unity package development.'
2727

28+
java.sourceCompatibility = JavaVersion.VERSION_11
29+
java.targetCompatibility = JavaVersion.VERSION_11
30+
2831
pluginBundle {
2932
website = 'https://wooga.github.io/atlas-wdk-unity/'
3033
vcsUrl = 'https://github.com/wooga/atlas-wdk-unity'
@@ -53,7 +56,7 @@ cveHandler {
5356
dependencies {
5457
implementation 'org.apache.maven:maven-artifact:3.8.5'
5558
implementation "net.wooga.gradle:dotnet-sonarqube:[1,2["
56-
implementation "net.wooga.gradle:unity:[4,5["
59+
implementation "net.wooga.gradle:unity:[5,6["
5760
implementation "commons-io:commons-io:2.11.0"
5861
implementation 'com.wooga.gradle:gradle-commons:[1,2['
5962

src/main/groovy/wooga/gradle/wdk/unity/WdkUnityPlugin.groovy

+5
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ class WdkUnityPlugin implements Plugin<Project> {
228228
}
229229
}
230230

231+
def cleanupUnityFiles = project.tasks.named(UnityPlugin.Tasks.cleanupDanglingUnityFiles.toString())
232+
project.tasks.withType(UnityTask).configureEach {
233+
it.dependsOn(cleanupUnityFiles)
234+
}
235+
231236
// Make every other Unity task depend on the setup task defined by this plugin
232237
project.tasks.withType(UnityTask).configureEach { task ->
233238
if (task.name != RESOLVE_PACKAGES_TASK_NAME && task.name && !(task.name == UnityPlugin.Tasks.ensureProjectManifest.name())

src/test/groovy/wooga/gradle/wdk/unity/WdkUnityPluginSpec.groovy

+19
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ package wooga.gradle.wdk.unity
1919

2020
import nebula.test.ProjectSpec
2121
import org.gradle.api.DefaultTask
22+
import org.gradle.api.Task
2223
import spock.lang.Unroll
2324
import wooga.gradle.dotnetsonar.DotNetSonarqubePlugin
2425
import wooga.gradle.dotnetsonar.SonarScannerExtension
2526
import wooga.gradle.dotnetsonar.tasks.BuildSolution
2627
import wooga.gradle.unity.UnityPlugin
2728
import wooga.gradle.unity.UnityPluginExtension
29+
import wooga.gradle.unity.UnityTask
2830
import wooga.gradle.wdk.unity.tasks.ResourceCopyTask
2931

3032
class WdkUnityPluginSpec extends ProjectSpec {
@@ -68,6 +70,23 @@ class WdkUnityPluginSpec extends ProjectSpec {
6870
WdkUnityPlugin.SONARQUBE_TASK_NAME | DefaultTask
6971
}
7072

73+
def 'any UnityTask depends on #dependencies' () {
74+
given:
75+
assert !project.plugins.hasPlugin(PLUGIN_NAME)
76+
77+
when:
78+
project.plugins.apply(PLUGIN_NAME)
79+
and:
80+
def anyUnityTask = project.tasks.register("anyUnityTask", UnityTask).get()
81+
82+
then:
83+
anyUnityTask.getTaskDependencies().getDependencies(anyUnityTask).any { t ->
84+
dependencies.contains(t.name.replaceFirst(":",""))
85+
}
86+
where:
87+
dependencies = [UnityPlugin.Tasks.cleanupDanglingUnityFiles.toString()]
88+
}
89+
7190
@Unroll
7291
def "creates needed configuration #configurationName"() {
7392
given:

0 commit comments

Comments
 (0)