Skip to content

Commit

Permalink
First project samples in Git
Browse files Browse the repository at this point in the history
  • Loading branch information
freddy33 committed Sep 18, 2011
0 parents commit c3a0042
Show file tree
Hide file tree
Showing 33 changed files with 889 additions and 0 deletions.
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sample projects for training and testing CI setup with Artifactory
15 changes: 15 additions & 0 deletions gradle-example/api/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
configurations {
spi
}

dependencies {
compile project(':shared')
compile module("commons-lang:commons-lang:2.4") {
dependency("commons-io:commons-io:1.2")
}
compile group: 'org.apache.wicket', name: 'wicket', version: '1.3.7'

}

// Just a smoke test that using this option does not lead to any exception
compileJava.options.compilerArgs = ['-Xlint:unchecked']
38 changes: 38 additions & 0 deletions gradle-example/api/src/main/java/org/gradle/api/PersonList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2011 JFrog Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.gradle.api;

import org.gradle.apiImpl.Impl;
import org.gradle.shared.Person;

import java.util.ArrayList;


public class PersonList {
private ArrayList<Person> persons = new ArrayList<Person>();

public void doSomethingWithImpl() {
org.apache.commons.lang.builder.ToStringBuilder stringBuilder;
try {
Class.forName("org.apache.commons.io.FileUtils");
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
new Impl().implMethod();
}

}
19 changes: 19 additions & 0 deletions gradle-example/api/src/main/java/org/gradle/api/package.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!--
~ Copyright (C) 2011 JFrog Ltd.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<html>
<body><p>These are the API classes</p></body>
</html>
26 changes: 26 additions & 0 deletions gradle-example/api/src/main/java/org/gradle/apiImpl/Impl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (C) 2011 JFrog Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.gradle.apiImpl;


public class Impl {

public void implMethod() {
double a = 4.0 * 4;
}

}
76 changes: 76 additions & 0 deletions gradle-example/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* There are 2 ways to activate the Artifactory Build-Info plugin.
* 1. use apply from directly from the build.gradle as shown below.
* 2. use the init script "gradle --init-script init.gradle" ATTENTION: Check the URL inside this init.gradle
* 3. Copy the init.gradle to your ~/.gradle directory and execute normally. ATTENTION: Now the Artifactory URL will
* always be applied to all your projects.
*
* Check the URL that apply uses to get the remote script
*
*/

import java.text.DateFormat
import java.text.SimpleDateFormat

def globalVersion = new Version(currentVersion)

allprojects {
apply plugin: 'artifactory'
group = 'org.gradle'
version = globalVersion
status = version.status
}

subprojects {
apply plugin: 'maven'
apply plugin: 'java'

dependencies {
testCompile 'junit:junit:4.7'
}
manifest.mainAttributes(provider: 'gradle')
}

artifactory {
contextUrl = 'http://repo.jfrog.org/artifactory'
publish {
defaults {
publishConfigs('archives', 'published')
properties = ['build.status': "$it.project.status".toString()]
}
}
resolve {
repoKey = 'gradle'
}
}

dependsOnChildren()

class Version {
String originalVersion
String thisVersion
String status
Date buildTime

Version(String versionValue) {
buildTime = new Date()
originalVersion = versionValue
if (originalVersion.endsWith('-SNAPSHOT')) {
status = 'integration'
thisVersion = originalVersion.substring(0,originalVersion.length()-'-SNAPSHOT'.length()) + getTimestamp()
} else {
status = 'release'
}
}

String getTimestamp() {
// Convert local file timestamp to UTC
def format = new SimpleDateFormat('yyyyMMddHHmmss')
format.setCalendar(Calendar.getInstance(TimeZone.getTimeZone('UTC')));
return format.format(buildTime)
}

String toString() {
thisVersion
}
}
1 change: 1 addition & 0 deletions gradle-example/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
currentVersion=1.0-SNAPSHOT
14 changes: 14 additions & 0 deletions gradle-example/init.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

gradle.projectsLoaded {
rootProject.allprojects {
buildscript {
repositories {
mavenRepo(urls: 'http://repo.jfrog.org/artifactory/gradle-plugins').setChecksums('sha1')
}
dependencies {
classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.3')
}
}
}
}

7 changes: 7 additions & 0 deletions gradle-example/services/webservice/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apply plugin: 'war'

dependencies {
compile project(':shared'), 'commons-collections:commons-collections:3.2@jar', 'commons-io:commons-io:1.2', 'commons-lang:commons-lang:2.4@jar'
compile group: 'org.apache.wicket', name: 'wicket', version: '1.3.7'
compile project(':api')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (C) 2011 JFrog Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.gradle.webservice;

import org.apache.commons.collections.list.GrowthList;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.gradle.api.PersonList;
import org.gradle.shared.Person;

public class TestTest {
private String name;

public void method() {
FilenameUtils.separatorsToUnix("my/unix/filename");
ToStringBuilder.reflectionToString(new Person("name"));
new GrowthList();
new PersonList().doSomethingWithImpl(); // compile with api-spi, runtime with api
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gradle.webservice;

import junit.framework.TestCase;

/**
* @author Hans Dockter
*/
public class TestTestTest extends TestCase {
public void testClasspath() {
new TestTest().method();
}

public void testApiCompileClasspath() {
new org.gradle.api.PersonList();
}
}
1 change: 1 addition & 0 deletions gradle-example/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include "shared", "api", "services:webservice"
42 changes: 42 additions & 0 deletions gradle-example/shared/src/main/java/org/gradle/shared/Person.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2011 JFrog Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.gradle.shared;

import java.io.IOException;
import java.util.Properties;

public class Person {
private String name;

public Person(String name) {
this.name = name;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String readProperty() throws IOException {
Properties properties = new Properties();
properties.load(getClass().getClassLoader().getResourceAsStream("org/gradle/shared/main.properties"));
return properties.getProperty("main");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2011 JFrog Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* These are the shared classes.
*/
package org.gradle.shared;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Copyright (C) 2011 JFrog Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

main=mainValue
34 changes: 34 additions & 0 deletions ivy-example/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ***************************************************************
# * Licensed to the Apache Software Foundation (ASF) under one
# * or more contributor license agreements. See the NOTICE file
# * distributed with this work for additional information
# * regarding copyright ownership. The ASF licenses this file
# * to you under the Apache License, Version 2.0 (the
# * "License"); you may not use this file except in compliance
# * with the License. You may obtain a copy of the License at
# *
# * http://www.apache.org/licenses/LICENSE-2.0
# *
# * Unless required by applicable law or agreed to in writing,
# * software distributed under the License is distributed on an
# * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# * KIND, either express or implied. See the License for the
# * specific language governing permissions and limitations
# * under the License.
# ***************************************************************
lib.dir = ${basedir}/lib
build.dir = ${basedir}/build
classes.dir = ${build.dir}/classes
src.dir = ${basedir}/src

repository.dir=${basedir}/../repository
ivy.local.default.root=${repository.dir}/local
ivy.shared.default.root=${repository.dir}/shared

ivy.file = ${basedir}/ivy.xml
ivy.settings.file=${basedir}/../ivysettings.xml

jar.file = ${build.dir}/${ant.project.name}.jar
main.class.name = ${ant.project.name}.Main
ivy.cache.dir=/home/tomer/.ivy2/cache
module.version.target = 1.0
Loading

0 comments on commit c3a0042

Please sign in to comment.