2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 package com
.intellij
.compiler
.ant
.j2ee
;
23 import com
.intellij
.compiler
.ant
.BuildProperties
;
24 import com
.intellij
.compiler
.ant
.CompositeGenerator
;
25 import com
.intellij
.compiler
.ant
.ExplodedAndJarTargetParameters
;
26 import com
.intellij
.compiler
.ant
.GenerationUtils
;
27 import com
.intellij
.compiler
.ant
.taskdefs
.AntCall
;
28 import com
.intellij
.compiler
.ant
.taskdefs
.Param
;
29 import com
.intellij
.compiler
.ant
.taskdefs
.Property
;
30 import com
.intellij
.compiler
.ant
.taskdefs
.Target
;
31 import com
.intellij
.openapi
.compiler
.make
.BuildConfiguration
;
32 import com
.intellij
.openapi
.module
.Module
;
33 import com
.intellij
.openapi
.vfs
.VirtualFileManager
;
34 import org
.jetbrains
.annotations
.Nullable
;
38 public class CompositeBuildTarget
extends CompositeGenerator
{
39 public CompositeBuildTarget(ExplodedAndJarTargetParameters parameters
,
40 final String targetName
, final String targetDescription
,
41 final String depends
, @Nullable String jarPath
) {
43 final File moduleBaseDir
= parameters
.getChunk().getBaseDir();
44 final Target buildTarget
= new Target(targetName
, depends
, targetDescription
, null);
45 final BuildConfiguration buildConfiguration
= parameters
.getBuildConfiguration();
47 final String baseDirProperty
= BuildProperties
.getModuleChunkBasedirProperty(parameters
.getChunk());
48 if (buildConfiguration
.isExplodedEnabled()) {
49 final String explodedPath
= buildConfiguration
.getExplodedPath();
50 if (explodedPath
!= null) {
51 String location
= GenerationUtils
.toRelativePath(VirtualFileManager
.extractPath(explodedPath
), moduleBaseDir
, baseDirProperty
,
52 parameters
.getGenerationOptions());
53 add(new Property(parameters
.getExplodedPathProperty(), location
));
56 final AntCall antCall
= new AntCall(parameters
.getBuildExplodedTargetName());
57 buildTarget
.add(antCall
);
58 antCall
.add(new Param(parameters
.getExplodedPathParameter(), BuildProperties
.propertyRef(parameters
.getExplodedPathProperty())));
61 if (jarPath
== null) {
62 jarPath
= getJarPath(buildConfiguration
);
65 if (jarPath
!= null) {
66 String location
= GenerationUtils
.toRelativePath(VirtualFileManager
.extractPath(jarPath
), moduleBaseDir
, baseDirProperty
,
67 parameters
.getGenerationOptions());
68 add(new Property(parameters
.getJarPathProperty(), location
));
70 final AntCall antCall
= new AntCall(parameters
.getBuildJarTargetName());
71 buildTarget
.add(antCall
);
72 antCall
.add(new Param(parameters
.getJarPathParameter(), BuildProperties
.propertyRef(parameters
.getJarPathProperty())));
78 protected static String
getJarPath(BuildConfiguration buildConfiguration
){
79 return buildConfiguration
.isJarEnabled() ? buildConfiguration
.getJarPath() : null;